Brian Please Help!
Please post all code for “Find Field Track Routine”
I already tested your code and it successfully finding “GPRMC” string and storing data in 65 elements array (memory of PIC16F872 doesn’t allow to create bigger array).
But still cannot figure out how to find right field and extract numeric data from the string.
This is a sample of string I have:
$G,092713.867,A,4913.0722,N,12256.9039,W,1.16,73.6 5,291206,,*20
$G,092714.867,A,4913.0712,N,12256.9078,W,0.81,78.5 6,291206,,*25 and so on
Maybe I made mistake in my code?
'---------------- Definitions---------------------------------------------
define OSC 20
'------------- Define LCD registers and bits------------------------------
Define LCD_DREG PORTB 'Set LCD data port
Define LCD_DBIT 0 'Set starting data bit
Define LCD_RSREG PORTB 'Set LCD register select port
Define LCD_RSBIT 4 'Set LCD register select bit
Define LCD_EREG PORTB 'Set LCD enable port
Define LCD_EBIT 5 'Set LCD enable bit
'------------- Define DEBUG registers and bits----------------------------
define DEBUG_REG PORTC 'Set DEBUD port
DEFINE DEBUG_BIT 3 'Set DEBUG pin
DEFINE DEBUG_BAUD 4800 'Set DEBUG baud rate
DEFINE DEBUG_MODE 0 'Set DEBUG mode
'------------Allocate Variables for GPS-----------------------------------
TimeOut CON 3000 'Time out delay
baudGPS CON 16572 '16572 - 4800 baud inverted
ParseCycle var byte ' Parse counter
commacount var byte 'Commas counter
e var byte
GPSdata var byte[65] ' Data array
TEMPdata var byte ' Temp debug data
'--------------------- Pins definitions-----------------------------------
GPSin VAR PORTc.7 'pin
'-----------------------Program routine-----------------------------------
GetData:
serin2 gpsin,baudgps, timeout, nogps,[WAIT("$GPRMC")] ' find start of string
for ParseCycle = 0 to 64
serin2 gpsin, baudgps, [GPSdata[ParseCycle]]
next ParseCycle
'for parsecycle = 0 to 64 'test routine
'TEMPdata = gpsdata[parsecycle] 'test routine
'Debug TEMPdata 'test routine
FindTrackField:
commacount = 0
for ParseCycle = 0 to 64
e = GPSdata[ParseCycle]
if e = "," then commacount = commacount + 1
if commacount = 8 then gosub gettrack 'Track follows 8th comma
debug e
'debug " Gps data value ", gpsdata '10 gives MagVar - 8 gives Track
next ParseCycle
goto getdata
Nogps:
LCDOut $FE, 1 'Clear Screen
LCDOut "No GPS"
low portc.0
Pause 2300
high portc.0 'error LED flashes
pause 2300
low portc.0
goto getdata
gettrack:
lcdout $FE, $01
lcdout $fe, 1, "Time" 'not finished line
lcdout $fe, $c0, "Speed " 'not finished line
return
Brian, please push me forward one more time.
Vladimir
Bookmarks