OBEX GPS NMEA Parser question
Dwayne Dibbley
Posts: 63
i am playing with Ryan David's GPS NMEA Parser from the OBEX.
I have my GPS connected to a quickstart board ( GPS coming in on P8 ) the default script just echo's the course to the terminal window. however this data does not seem correct see output from terminal:
any ideas as to why 842018869 is suppose to be my course?
is there an easyway to see if the NMEA data comming in is correct ie instead of echo'ing the course can i dump out the last NMEA string received?
sample from GPS plugged directly into terminal is as follows:
Thanks
I have my GPS connected to a quickstart board ( GPS coming in on P8 ) the default script just echo's the course to the terminal window. however this data does not seem correct see output from terminal:
84201886984201886984201886984201886984201886984201886984201886984201886984201886984201 8869842018869842018869842018869842018869842018869
any ideas as to why 842018869 is suppose to be my course?
is there an easyway to see if the NMEA data comming in is correct ie instead of echo'ing the course can i dump out the last NMEA string received?
sample from GPS plugged directly into terminal is as follows:
$GPGGA,184822.638,5023.3762,N,00354.4517,W,1,05,2.9,83.6,M,53.2,M,,0000*70 $GPRMC,184822.638,A,5023.3762,N,00354.4517,W,000.0,000.0,200711,,,A*70
Thanks
Comments
Does Ryan's parser output the data as a floating point number? That's my guess.
It would be helpful if you provided a link to the object.
Duane
heres the OBEX:
http://obex.parallax.com/objects/579/
Thanks
-Phil
from the spin code :
so I was hoping it would be a 0-360 bearing assuming that's what is meant by course?
Thanks
-Phil
Thanks
Jeff T.
Jeff that works fine, so i can confirm the GPS works and is outputting the correct data. So back to Ryan David's spin project as the bulk of the object is in ASM i haven't a clue how its parsing the data
the code " return @Course " in the GPSDriver, is that what is returning the data back to the main code? i have tride changing it to " return @Satellites " but i dont get anything
Thanks
so replaced the original code with this for the serial echo and now it generates 069.0 which look better
changing debug.dec to debug.tx ( is this just outputting plain text instead of a decimal number ? )
but still what does ((long[GPSBuff] >> 16) & %1111_1111) actually do with the GPSBuff? ( do i need the %1111_1111? )
Thanks again
Yes, you need the %1111_1111 if you do it that way, since the "&" is used to isolate individual characters. You could just as easily do it this way:
This is what I was alluding to above with my comment about "5002" vs. "2005" being 200.5 degrees. The characters are being stored by the parser in reverse byte order (big endian form) for some reason.
-Phil
%10101010_00110011_11101110_11101100
You intend to get that '00110011' to end up in the rightmost 8 bits.
Shifted 16 bits to the right two things happens:
1) The 16 bits to the left end up to the right,
2) and because the 'long' is a signed integer the leftmost 1 is sign-extended. So you get:
%11111111_11111111_10101010_00110011
(if that leftmost bit hadn't been 1 those bits to the left would all be 0, not 1).
Then you do '& %1111_1111' and end up with
%00000000_00000000_00000000_00110011
which is what you want.
-Tor
i am trying to loop while the gps noes not have a fix and flash a led with:
but i get unexpected end of line with repeat while ((long[GPSBuff+16] >> 16) & %1111_1111) = 0
thanks again
Incidentally, ((long[GPSBuff+16] >> 16) & %1111_1111) is equivalent to byte[GPSBuff+18]. Maybe it's easier to read.
-- http://www.parallaxsemiconductor.com/sites/default/files/appnotes/AN002-GPS-NMEA0183-v1.0_0.pdf
Thats awesome, and works a treat out of the box
regarding:
what is the best way to run as 10x? usually i would use:
Thanks alot
Glad you like it; I wrote that code.
When multiplying or dividing by numbers that are power of 2 I use shifts, otherwise, you've got use * or /
Note, though, that the usage above is approximate. If you want EXACTLY 10 iterations per second, use a synchronized loop
The caveat is that your loop code must consume less than your loop timing, otherwise you will miss the waitcnt target and be stuck until cnt rolls back to it.
Thanks
Thanks of to play some more.
How would I pull back the mm.ssss part for the gps ? i need to convert the NMEA formatted lat and long to decimal degrees hopefully like this dd + (mm.ssss/60) so i can calculate distances between positions.
Thanks
Note that there is also a public method called str2dec that returns the numeric value of n characters in a string.
For example....
Note that there are n_ methods to do the work above, but doing it as shown -- on a local buffer -- ensures that each field comes from the same instance of the GPS sentence.
One thing you might consider doing is adding a simple counter for each GPS string that is incremented every time a new string is moved from the GPS input to the object working buffers. By monitoring this counter one could easily tell if the system has received a new GPS sentence.
how does it trim the result to only two characters? ie 22 is returned from an original value of 3735 instead of 22.41 ?
Thanks
Perhaps you're unaware that the Propeller uses integer math, hence the 0.41 part gets truncated by the division by 10,000. Note, too, that the method comment explicitly states that it returns a decimal (perhaps I should change that to integer) value in the range of 0 to 59. You can do that calculation manually (as I showed you before) and divide by 100 instead of 10,000; this will return 2241 which is seconds expressed in 1/100ths units.
There are PASM and Spin Floating Point objects that may be helpful in your project. You can find them in ObEx.