10 82 02 10 03
10 46 00 01 10 03
10 4B 5A 00 01 10 03
10 6D 64 40 4A 74 CE 3F C9 7F 37 40 2F 9B BD 40 0F 78 36 09 1A 1C 05 08 0F 10 03
10 82 02 10 03
10 5C 18 00 02 00 00 00 00 00 48 ED C7 CB 3E 9B 15 5D 40 87 F1 54 00 00 00 01 10 03
10 5C 09 08 01 02 40 AC CC CD 48 ED C7 CB 3F 9F 79 1B 40 87 0C 68 00 00 00 01 10 03
10 5C 1A 10 01 02 41 03 33 33 48 ED C7 CB 3F B3 84 83 3F DA 0D EE 00 00 00 01 10 03
10 5C 1C 18 01 02 41 03 33 33 48 ED C7 CB 3F 67 0C 74 3F D3 97 93 00 00 00 01 10 03
10 5C 05 20 01 02 40 C6 66 66 48 ED C7 CB 3F 1B 37 E0 40 4F D8 66 00 00 00 01 10 03
10 5C 08 28 01 02 40 D9 99 9A 48 ED C7 CB 3F 14 C4 19 3F 86 49 FA 00 00 00 01 10 03
10 5C 15 30 02 00 00 00 00 00 48 ED C7 CB 3E 7D 55 84 40 A5 9A BD 00 00 00 01 10 03
10 5C 0F 38 01 02 40 26 66 66 48 ED C7 CB 3F 75 01 93 40 A1 75 DA 00 00 00 01 10 03
10 41 48 ED C7 CB 06 C3 41 80 00 00 10 03
10 8F 20 00 00 00 00 00 00 00 1D 06 A6 18 25 60 AA 3A FE A6 B9 31 00 03 8B 80 00 00 01 18 06 00 06 C3 09 5D 1A 53 1C 46 05 5A 08 09 0F 35 00 00 00 00 17 01 FE 00 3C 00 FC 03 10 03
10 6D 64 40 4A 74 CE 3F C9 7F 37 40 2F 9B BD 40 0F 78 36 09 1A 1C 05 08 0F 10 03
'-- Read data from the GPS
Hseropen 9600
getdata:
Hserin data(0) '10
Hserin data(1) '46
If data(0) = 0x10 And data(1) = 0x46 Then 'Status Packet
Hserin data(2)
Hserin data(3)
Hserin data(4)
Hserin data(5)
Lcdcmdout LcdLine1Pos(1)
Lcdout #data(2), " ", #data(3), " ", #data(4), " ", #data(5), " "
Else
Lcdcmdout LcdLine1Pos(1)
Lcdout "Waiting"
Endif
WaitMs 500
Goto getdata
'General Configuration
Define CONF_WORD = 0x33c4 'for internal 8MHz osc
'Oscillator/Clock Configuration for internal 8MHz osc
Define CLOCK_FREQUENCY = 8
OSCCON = 0x71
'Debug Option
Dim debug As Bit
debug = True
debug = False
'Variable Declarations
'>>I/O
Symbol out_rs232 = RB7 'rs232 output (HW UART)
Symbol in_rs232 = RB5 'rs232 input (HW UART)
Const _trisa = %11111111
Const _trisb = %01011111
Const _trisc = %11111111
'>>Variables
Dim gps_array(6) As Byte
Dim _true As Bit
Dim _false As Bit
_true = True
_false = False
Const stx_byte1 = 0x10
Const stx_byte2 = 0x46
Const etx_byte1 = 0x03
'Main Program
'-- Read data from the GPS
Hseropen 9600
Dim idx As Byte
Dim gps_byte As Byte
idx = 0
gps_byte = 0
'scan through gps bytes
While _true
Select Case idx
Case 0 'if first byte matches store it and increment counter, otherwise reset counter
Hserin gps_byte 'get gps byte
If gps_byte = stx_byte1 Then
gps_array(idx) = gps_byte
idx = idx + 1
Else
idx = 0
Endif
Case 1 'if second byte matches store it and increment counter, otherwise reset counter
Hserin gps_byte 'get gps byte
If gps_byte = stx_byte2 Then
gps_array(idx) = gps_byte
idx = idx + 1
Else
idx = 0
Endif
Case 5 'if last byte matches store it and display, reset counter either way
Hserin gps_byte 'get gps byte
If gps_byte = etx_byte1 Then
gps_array(idx) = gps_byte
Call display_gps_sentence()
Endif
idx = 0
Case Else 'store byte and increment counter
Hserin gps_byte 'get gps byte
gps_array(idx) = gps_byte
idx = idx + 1
EndSelect
Wend
End
Proc display_gps_sentence()
Dim idx As Byte
For idx = 0 To 5
Hserout gps_array(idx), " "
Next idx
Hserout CrLf
You appear to be reading the output of the GPS in TISP format.
Can I suggest that it may be easier to use NMEA 0183 format which appears to be available from this GPS module.
The NMEA messages all start with the $ symbol, and end with [CR[]LF], and the data fields within the message are comma separated.
I assume that you have the manual for this GPS?
If not, it can be downloaded from here:
https://data.manualslib.com/pdf/19/...oors/sk8.pdf?fb3088076d870a90bea6fc21b4d45460
JimB
$GPBOD - Bearing, origin to destination
$GPBWC - Bearing and distance to waypoint, great circle
$GPGGA - Global Positioning System Fix Data
$GPGLL - Geographic position, latitude / longitude
$GPGSA - GPS DOP and active satellites
$GPGSV - GPS Satellites in view
$GPHDT - Heading, True
$GPR00 - List of waypoints in currently active route
$GPRMA - Recommended minimum specific Loran-C data
$GPRMB - Recommended minimum navigation info
$GPRMC - Recommended minimum specific GPS/Transit data
$GPRTE - Routes
$GPTRF - Transit Fix Data
$GPSTN - Multiple Data ID
$GPVBW - Dual Ground / Water Speed
$GPVTG - Track made good and ground speed
$GPWPL - Waypoint location
$GPXTE - Cross-track error, Measured
$GPZDA - Date & Time
eg3. $GPGLL,5133.81,N,00042.25,W*75
1 2 3 4 5
1 5133.81 Current latitude
2 N North/South
3 00042.25 Current longitude
4 W East/West
5 *75 checksum
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital
'Define the comms for the LCD display.
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 'Use the high order bits'
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_EREG = PORTA
Define LCD_EBIT = 0
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20
Define SEROUT_DELAYUS = 1000
Symbol txcr_pin = PORTA.7
Dim i As Byte 'used for loops
Dim j As Byte 'used for loops
Dim pos As Byte 'used for lcd position
Dim ch As Byte 'used to hold individual character
Dim times_sent As Byte 'used to check number of times sent before waiting
Dim data(5) As Byte 'Array to store raw Data (Remember 0-3)
startup:
Lcdinit LcdCurBlink
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Pos(1)
Lcdout "Pause ...... "
WaitMs 50
Lcdcmdout LcdClear
'-- Read data from the GPS#
Dim gps_array(6) As Byte
Dim _true As Bit
Dim _false As Bit
_true = True
_false = False
Const stx_byte1 = 0x10
Const stx_byte2 = 0x46
Const etx_byte1 = 0x03
Hseropen 9600
Dim idx As Byte
Dim gps_byte As Byte
idx = 0
gps_byte = 0
While _true
'scan through gps bytes
Select Case idx
Lcdcmdout LcdLine2Pos(1)
Lcdout "idx - ", #idx
Case 0 'if first byte matches store it and increment counter, otherwise reset counter
Hserin gps_byte 'get gps byte
If gps_byte = stx_byte1 Then
gps_array(idx) = gps_byte
idx = idx + 1
Else
idx = 0
Endif
Case 1 'if second byte matches store it and increment counter, otherwise reset counter
Hserin gps_byte 'get gps byte
If gps_byte = stx_byte2 Then
gps_array(idx) = gps_byte
idx = idx + 1
Else
idx = 0
Endif
Case 5 'if last byte matches store it and display, reset counter either way
Hserin gps_byte 'get gps byte
If gps_byte = etx_byte1 Then
gps_array(idx) = gps_byte
Call display_gps_sentence()
Endif
idx = 0
Case Else 'store byte and increment counter
Hserin gps_byte 'get gps byte
gps_array(idx) = gps_byte
idx = idx + 1
EndSelect
Wend
End
Proc display_gps_sentence()
Dim idx As Byte
pos = 1
For idx = 0 To 5
'Hserout gps_array(idx), " "
Lcdcmdout LcdLine1Pos(pos)
Lcdout #gps_array(idx), " "
pos = pos + 3
Next idx
'Hserout CrLf
Return
Lcdcmdout LcdLine2Pos(1)
Lcdout "idx - ", #idx
Hi alec_t.
The case works perfectly in simulation and does exactly what it should. The 5 is looking at the 5th element of the packet once the other cases have been fulfilled. Setting the idx back to zero each time if not.
...
Regards - Paul
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?