GPS Module Commands (Smart Mode)
OneCoolCat
Posts: 11
For some reason for which I can't figure out, the demo program written for the GPS module works and the brief code that I wrote to just·find altitude does not.
I'm just using the SEROUT, SERIN commands and the data I get back is not accurate.
What's the trick?
I'm just using the SEROUT, SERIN commands and the data I get back is not accurate.
What's the trick?
Comments
You should post your code to get better help.
How inaccurate are the data? GPS altitude is notoriously inaccurate.
SEROUT Sio, Baud, [noparse][[/noparse]"!GPS", GetAlt]
SERIN Sio, Baud, 3000, noResponse, [noparse][[/noparse]token.HIGHBYTE, token.LOWBYTE]
PAUSE 500
DEBUG token
I've verified that the 'token' variable is a WORD.
The altitude is way off.· I'm at about 125 m and it gives me about 3000 m.··And again,·if I run the demo·program downloaded from the web, the reading is accurate.
Thanks!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Duffer
·
Been there, done that.
Jim
It's definitely something quirky with my program or the Stamp BS2.· Get this, if I delete a PAUSE 500 line, the altitude and satellite numbers·become accurate!··Theoretically the line·should have nothing to do with this issue.
Any idea what's going on here?
Until Valid is 1 (true), the number of Sats and altitude are zero and garbage respectively.
GPS Startup - Valid = False
$GPGGA,000056,,N,,E,0,00,,,M,,M,,*6E<CR><LF>
$GPRMC,000056,V,,N,,E,,,010303,,,N*5A<CR><LF>
Sats fixed - Valid = True
$GPGGA,013620,4034.8983,N,07439.6939,W,1,04,04.0,00039.2,M,-034.0,M,,*71<CR><LF>
$GPRMC,013620,A,4034.8983,N,07439.6939,W,000.0,000.0,271109,,,A*6D<CR><LF>
The NMEA sentences above represent what the SX processor is parsing from the GPS module in Smart mode(the GSA and GSV sentences are ignored by Smart mode).
Notice that while Valid is false (second field in RMC sentence is "V"), the number of sats (7th field in GGA sentence) is "00" and the Altitude (the 9th field in GGA sentence) is null, The parser counts commas to locate a field and then reads a number of bytes of what it thinks is valid data. In the case of·Altitude, before a valid fix, the parser would read garbage (",M,,M" instead of "00039.2 in the "valid" GGA sentence).
Contrast that to the GGA and RMC sentences when Valid (second field in RMC = "A").
You could try something like:
This would continue to test for a valid signal at 2 second intervals until a valid signal was acquired (the red LED on the GPS is on solid when the GPS unit has a fix). Untill Valid is true, all data from the GPS is suspect. That's why the demo program·for Smart mode checks for Valid and if it's not, it outputs "?" to all the fields and tries again.
Duffer
Post Edited (Duffer) : 1/2/2010 3:22:28 AM GMT
Duffer