GPS DATA BS2 STAMP
cydelcamat
Posts: 53
hi guys! is there anyone who knows on how to get the data on gps? Im using basic stamp 2 and I always got an error saying that "Error: No response from GPS Receiver Module"
please see attachment.
please see attachment.
Comments
Which BS2 are you using, there are many flavors and require different programming for baud rates.
Sometime mixing up the transmit and receive lines would product the same problem
The above sample output does not help much. There's a standard format for GPS serial output (NMEA). Look on the GPS receiver for a part number/model number. If it's mounted on a printed circuit board or breakout board, is there a part number there?
The first two attachments are from Parallax's Nut and Volts column archive #83. The 3rd attachment is from Parallax's learn website KickStarter for their GPS receiver. The last attachment is an article on NMEA decoding using a Stamp. As mentioned earlier, it would be helpful to know what kind of GPS receiver you're using.
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Byte (6)
n4800 CON 188
n9600 CON 84
MAIN:
SERIN 0, n4800,[WAIT("RMC,"),STR time\6]
SEROUT 16, n9600,[time(0),time(1),";",time(2),time(3),";",time(4),time(5)]
DEBUG CR
GOTO MAIN
Similarly, if the hours goes over 23, you want to rollover to 0 hours. If you need the seconds, you can handle that the same way.
To display using SEROUT, prefix the variable with DEC2 and SEROUT will convert the number to 2 decimal digits.
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Byte (6)
moveto CON 2
n4800 CON 188
n9600 CON 84
MAIN:
SERIN 0, n4800,[WAIT("GGA,"),STR time\6]
DEBUG CR
time(2) = time(2) + 3
IF time(2) > 5 THEN
time(2) = time(2) - 6
time(1)= time(1) + 1
ENDIF
SEROUT 1, n4800, ["$GPGGA,",time(0),time(1), time(2),time(3),time(4),time(5)]
GOTO MAIN
This won't work because the digits in "time" are characters ("0", "1", ... , "9"). Try
IF time(2) > "5" THEN
What happens when the time starts off at "095000" and you add 30 minutes?
If the OP is using the code for the #28146 GPS we used to have (which it kind of looks like) and using a standard GPS that outputs NMEA strings, then this could also happen, because the code is expecting back formatted data and getting random characters from the NMEA strings and that is being printed.
And why I asked in Post #2 for the GPS unit he is using. OP has yet to reply.
That might narrow it down to the baud rate, but 4800 is kind of standard.
I've also confirmed by looking more closely at the screenshot...he is using the code for the Smart GPS (#28146) which won't work. This is evident by the Hardware/Firmware Version lines, which are queried from the module. This code isn't compatible with a standard GPS receiver.
In fact, as Mike already mentioned...your'e better off using a BS2p-series module to handle NMEA strings in the absence of #28146 (long since discontinued). The SPRAM alone makes those models invaluable for dealing with long strings since the BASIC Stamp Modules don't have enough variable RAM to handle that kind of data.
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Byte (6)
moveto CON 2
n4800 CON 188
n9600 CON 84
MAIN:
SERIN 0, n4800,[WAIT("RMC,"),STR time\6]
SEROUT 1, n4800, ["$GPGGA,",time(0),time(1), time(2),time(3),time(4),time(5)]
DEBUG CR
GOTO MAIN
I personally would have an easier time converting the date and time fields into numbers (hours, minutes, etc.) first the way I suggested earlier. I think you'd have an easier time testing against specific values and adjusting those values. You also might have an easier time using one of the BS2p Stamps or even a Propeller.
Ken Gracey
Thank you!