GPS -- NMEA Input & Parsing
Here's a sample of the NMEA sentence that I'm dealing with:
$GPGLL,3330.6092,N,11200.6777,W,202110.595,A*27
All I want is the stuff in RED.·
I haven't tried it before, but I used STR to capture it all, using SKIPs, and more STRs.· At the end I read it out to a LCD.
I don't know if I'm writing the input with the STR right.· I have the feeling that I can't use it and then re-use it without the pointer being re-set, too.· The resulting output to the LCD basically repeats all three lines.··
My GPS is outputting the $GPGLL sentence once every 5 seconds.· I push the button to initiate the process: it waits to get/receive a "GLL,", then it starts a grab, then it goes to the printout and my LED comes on, I get the printout on the LCD, the LED goes out, and then it goes back to the top for another button push.
The characters that I get back are odd-ball.
Am I taxing the formatting ability of the BS2 at 4800?· Is my use of STR incorrect?· Any constructive criticism?
·
Here is my programme --
Post Edited By Moderator (Chris Savage (Parallax)) : 9/19/2005 12:02:22 AM GMT
$GPGLL,3330.6092,N,11200.6777,W,202110.595,A*27
All I want is the stuff in RED.·
I haven't tried it before, but I used STR to capture it all, using SKIPs, and more STRs.· At the end I read it out to a LCD.
I don't know if I'm writing the input with the STR right.· I have the feeling that I can't use it and then re-use it without the pointer being re-set, too.· The resulting output to the LCD basically repeats all three lines.··
My GPS is outputting the $GPGLL sentence once every 5 seconds.· I push the button to initiate the process: it waits to get/receive a "GLL,", then it starts a grab, then it goes to the printout and my LED comes on, I get the printout on the LCD, the LED goes out, and then it goes back to the top for another button push.
The characters that I get back are odd-ball.
Am I taxing the formatting ability of the BS2 at 4800?· Is my use of STR incorrect?· Any constructive criticism?
·
Here is my programme --
BtnWrk VAR Byte
CD VAR Byte (25)'co-ordinate data
Prelims:
DIRS = $0F 'MSB INs, LSB OUTs
OUTL = %10000000 'preset OUTs
INH = %00000000 'preset INs; button bit0,
Push:
BUTTON 8,1,255,20,BtnWrk,1,Rtrv
GOTO Push
Rtrv:
SERIN 9, 188,[noparse][[/noparse]WAIT("GLL,"),STR CD\7] 'ddmm.mm
SERIN 9, 188,[noparse][[/noparse]SKIP 3,STR CD\1] 'skip 3&4 decpl,comma; take N
SERIN 9, 188,[noparse][[/noparse]SKIP 1,STR CD\8] 'dddmm.mm
SERIN 9, 188,[noparse][[/noparse]SKIP 3,STR CD\1] 'skip 3&4 decpl,comma; takeW
SERIN 9, 188,[noparse][[/noparse]SKIP 1,STR CD\6] 'skip comma; take hhmmss
SERIN 9, 188,[noparse][[/noparse]SKIP 5,STR CD\1] 'skip time decpl, comma; a/v Status
Got1:
OUTL=%10000001 'LED=ON, gonna printout; serout bit HI for NO NUL
SEROUT 7, 188, [noparse][[/noparse]$0c] 'form feed
SEROUT 7, 188, [noparse][[/noparse]STR CD\8] 'ddmm.mmN
SEROUT 7, 188, [noparse][[/noparse]$0A,$0D] 'LF,CR
SEROUT 7, 188, [noparse][[/noparse]STR CD\9] 'dddmm.mmW
SEROUT 7, 188, [noparse][[/noparse]$0A,$0D] 'LF,CR
SEROUT 7, 188, [noparse][[/noparse]STR CD\7] 'hhmmssA
OUTL=%10000000 'LED=OFF, endof printout; serout bit HI for NO NUL
GOTO Push
Post Edited By Moderator (Chris Savage (Parallax)) : 9/19/2005 12:02:22 AM GMT

Comments
· ·SERIN GPS, Baud, [noparse][[/noparse]WAIT("GPGLL,"
···················· DEC latD, SKIP 1, DEC latM,
···················· DEC lonD, SKIP 1, DEC lonM, SKIP 1,
···················· DEC2 hrs, DEC2 mins, DEC2 secs,
···················· SKIP 5,·status]
If you do a bit of search you'll find I've posted a bunch of GPS related programs that you can work with.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
···
BtnWrk VAR Byte LA VAR Byte (7) NS VAR Byte (1) LO VAR Byte (8) EW VAR Byte (1) TM VAR Byte (6) AV VAR Byte (1) Prelims: DIRS = $0F 'MSB INs, LSB OUTs OUTL = %10000000 'preset OUTs INH = %00000000 'preset INs; button bit0, Push: BUTTON 8,1,255,20,BtnWrk,1,Rtrv GOTO Push Rtrv: SERIN 9,188,[noparse][[/noparse]WAIT("GLL,"),STR LA\7,SKIP 3,STR NS\1,SKIP 1,STR LO\8,SKIP 3,STR EW\1,SKIP 1,STR TM\6,SKIP 5,STR AV\1] 'ddmm.mm Got1: OUTL=%10000001 'LED=ON, gonna printout; serout bit HI for NO NUL SEROUT 7,188,[noparse][[/noparse]$0c] 'form feed SEROUT 7,188,[noparse][[/noparse]" GPS BY PJALLEN",$0A,$0D] SEROUT 7,188,[noparse][[/noparse]STR LA\7] 'ddmm.mm SEROUT 7,188,[noparse][[/noparse]$04] 'RC SEROUT 7,188,[noparse][[/noparse]STR NS\1] 'N SEROUT 7,188,[noparse][[/noparse]$0A,$0D] 'LF,CR SEROUT 7,188,[noparse][[/noparse]STR LO\8] 'dddmm.mm SEROUT 7,188,[noparse][[/noparse]$04] 'RC SEROUT 7,188,[noparse][[/noparse]STR EW\1] 'W SEROUT 7,188,[noparse][[/noparse]$0A,$0D] SEROUT 7,188,[noparse][[/noparse]"UTC ",STR TM\6] SEROUT 7,188,[noparse][[/noparse]$04,$04,$04]'RCx3 SEROUT 7,188,[noparse][[/noparse]STR AV\1] 'A OUTL=%10000000 'LED=OFF, endof printout; serout bit HI for NO NUL GOTO PushFirst, it hit me: I need to call the STRs by different names
By the way, I'm using a 4 x 20 LCD from a previous, unrelated, project.· It has an EIA-232 input.·
My BS2 is a "HomeWork Board" and I use a MAX232 driver between its I/O and the LCD and the GPS.
' {$STAMP BS2} ' {$PBASIC 2.0} ' {$PORT COM1} BtnWrk VAR Byte PA VAR Byte (2) PM VAR Byte (2) PD VAR Byte (3) NS VAR Byte (1) MA VAR Byte (3) MM VAR Byte (2) MD VAR Byte (3) EW VAR Byte (1) TM VAR Byte (6) AV VAR Byte (1) Prelims: DIRS = $0F 'MSB INs, LSB OUTs OUTL = %10000000 'preset OUTs INH = %00000000 PrepCUR: SEROUT 7,188,[noparse][[/noparse]$0c,$19,$00] 'form feed, blank cursor Rtrv: SERIN 9,188,[noparse][[/noparse]WAIT("GLL,"),STR PA\2,STR PM\2,SKIP 1,STR PD\3,SKIP 2,STR NS\1,SKIP 1,STR MA\3,STR MM\2,SKIP 1,STR MD\3,SKIP 2,STR EW\1,SKIP 1,STR TM\6,SKIP 5,STR AV\1] LCD: OUTL=%10000001 'LED=ON, gonna printout; serout bit HI for NO NUL SEROUT 7,188,[noparse][[/noparse]$02," * GPS BY PJALLEN *",$0A,$0D] SEROUT 7,188,[noparse][[/noparse]STR NS\1," ",STR PA\2,"deg ",STR PM\2,".",STR PD\3,"min"] SEROUT 7,188,[noparse][[/noparse]$0A,$0D] 'LF,CR SEROUT 7,188,[noparse][[/noparse]STR EW\1," ",STR MA\3,"deg ",STR MM\2,".",STR MD\3,"min"] SEROUT 7,188,[noparse][[/noparse]$0A,$0D] SEROUT 7,188,[noparse][[/noparse]"UTC ",STR TM\6] SEROUT 7,188,[noparse][[/noparse]" ",STR AV\1] OUTL=%10000000 'LED=OFF, endof printout; serout bit HI for NO NUL GOTO Rtrv