Shop OBEX P1 Docs P2 Docs Learn Events
Pulling NMEA strings off of the parallax GPS Module — Parallax Forums

Pulling NMEA strings off of the parallax GPS Module

cwolffcwolff Posts: 24
edited 2007-12-29 06:06 in BASIC Stamp
Hello,

I recently purchased a Parallax GPS module and wrote a simple program to pull raw strings off of the unit. But my output looks screwy, can anyone advise how to make nice clean nmea strings come out? Thank you.

' {$STAMP BS2p}
' {$PBASIC 2.5}

'
[noparse][[/noparse] I/O Definitions ]

Sio PIN 10 ' connects to GPS Module SIO pin
Raw CON 7

'
[noparse][[/noparse] Constants ]

T4800 CON 500
Baud CON T4800

i VAR Byte
serdata VAR Byte

Initialize:
LOW Raw

Start:
SERIN Sio,500,[noparse][[/noparse]SPSTR 82 ]

FOR i = 0 TO 81
GET i,serdata
DEBUG serdata
NEXT
DEBUG CR
GOTO start:


$GPGGA,051107,3213.8873,N,11058.1625,W,0,00,,00687.1,M,-027.2,M,,*65

$GPGSA,A,1,,
NI

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-29 05:55
    It takes quite a long time to display the 82 character input stream with the DEBUG loop and the BS2p stops listening to the input stream while it's doing other things. When it goes back to Start, it takes a while to synchronize with the incoming serial stream and that's where the garbage comes from. About the only way you could make this work would be to use an external serial buffer chip like this one www.protean-logic.com/tickit/rsb509B_HTML_Cutsheet.htm or to switch to using a processor like the Propeller that can do buffered serial I/O by itself.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-29 05:55
    It's no coincidence that your output craps out after 82 characters. This is because the GPS keeps sending data while your program is doing the DEBUG output. When your program starts reading data again, synchronization to the incoming serial stream has been lost and takes awhile to reestablish itself. That's why you see garbage characters. You might try inserting a WAIT("$GP"), as follows:

    SERIN Sio, 500, [noparse][[/noparse]WAIT("$GP"), SPSTR 82 ]
    
    
    


    You will miss entire sentences while synchronization is reestablished, but at least what you read should be intact. If you're only interested in, say, $GPGGA, you could use WAIT("GGA") instead. That way you will be more likely to intercept the stuff you're interested in.

    Note: There's a chance that the BS2p won't be able to keep up at 4800 baud using WAIT. You'll just have to experiment with it to see.

    -Phil
  • cwolffcwolff Posts: 24
    edited 2007-12-29 06:06
    Ok guys, thanks for the quick response... I made the following change and the output is much better, plus I now have plenty of RAM to include my sensirion code! yaaaay!

    $GPGSV,3,2,12,1
    RMC,060733,A,3213.8585,N,11058.1665,W,000.5,266.2,291207,,,A*63

    $GPGGA,060734,321
    GSV,3,1,12,01,51,030,34,05,05,041,00,11,34,271,38,14,26,058,32*79

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    '
    [noparse][[/noparse] I/O Definitions ]

    Sio PIN 10 ' connects to GPS Module SIO pin
    Raw CON 7

    '
    [noparse][[/noparse] Constants ]

    T4800 CON 500
    Baud CON T4800

    i VAR Byte
    serdata VAR Byte

    Initialize:
    LOW Raw

    Start:
    SERIN Sio,500,[noparse][[/noparse]WAIT("$GP"),SPSTR 82 ]

    FOR i = 0 TO 81
    GET i,serdata
    DEBUG serdata
    NEXT
    DEBUG CR
    PAUSE 2000
    GOTO start:
Sign In or Register to comment.