PDA

View Full Version : Parallax GPS NMEA String comparison code help for near-newbie



WBA Consulting
12-13-2009, 02:50 PM
I am trying to create the Reverse Geo-Cache Project (http://forums.parallax.com/showthread.php?p=851955) that I posted in the sandbox a while back for my wife's birthday (12/21). In my searching for objects in the OBEX, it seems that parsing the NMEA string data from the GPS in RAW mode is done by typical manipulation of variables (longs, bytes, and arrays). Unfortunately, I am still learning how to do this type of thing in SPIN and it's a bit of a struggle. I am looking at the following to help with this project:

Google Earth SD Card Logger thread (http://forums.parallax.com/showthread.php?p=729953) (logs incorrectly formatted data, but works for analysis; see my post on that thread about the bug)
GPS to VGA Object (http://obex.parallax.com/objects/225/)
GPS Float Object (http://obex.parallax.com/objects/405/)

It appears that the data from the NMEA string is being stored in an array (buffer) and pointers are created for the different pieces of data so that they can be called individually. This makes sense to me. Here's my dilemma:

What commands should I be looking at so that I can compare a Latitude string with a stored value to give me a result that tells me that I am within X distance from the stored value? My thoughts are that if I am looking for Latitude "38.795150" then I would just make sure the Latitude string begins with "38.7951" (IE: 38.795100-199) and I know I am within 18 feet of my target. That would work for my project.

How do I translate "does lat-string begin with 38.7951" into SPIN?

thanks!!!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
WBA-TH1M Sensirion SHT11 Module (http://www.aestheticacoustics.com/sht11_01.htm)
Special Olympics Polar Bear Plunge, Mar 20, 2010 (http://www.kintera.org/faf/donorReg/donorPledge.asp?ievent=322002&lis=1&kntae322002=BDAEE98623FB443591C072E356710D6B&supId=265642883)

Phil Pilgrim (PhiPi)
12-13-2009, 03:13 PM
Something like this should work:




match := true
repeat i from 0 to 6
if (lat_string[*i] <> byte[string("38.7951")][*i])
match := false
quit




-Phil

Post Edited (Phil Pilgrim (PhiPi)) : 12/13/2009 8:18:32 AM GMT

SRLM
12-13-2009, 11:36 PM
I wrote some assembly code that will automatically receive and parse the GPS strings (RMC and GGA if I recall) then put that data in the hub for the other cogs to get at.

www.srlmproductions.com/projects-home/propeller-objects-1/GPSAssembly.zip?attredirects=0&d=1 (http://www.srlmproductions.com/projects-home/propeller-objects-1/GPSAssembly.zip?attredirects=0&d=1)

It's designed for a 5Hz (?) GPS so you might have to change the buad. I don't have the time to look at it this morning, but let me know and I can see what needs to be changed for you tonight.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm

WBA Consulting
12-15-2009, 04:26 AM
Thanks for the responses, I will try more out tonight.

Phil, Does the quit stop the IF routine or the REPEAT routine? (I need to read up more on IF usage in SPIN)

SRLM, I really like your Bacchus clock on your site!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
WBA-TH1M Sensirion SHT11 Module (http://www.aestheticacoustics.com/sht11_01.htm)
Special Olympics Polar Bear Plunge, Mar 20, 2010 (http://www.kintera.org/faf/donorReg/donorPledge.asp?ievent=322002&lis=1&kntae322002=BDAEE98623FB443591C072E356710D6B&supId=265642883)

Phil Pilgrim (PhiPi)
12-15-2009, 04:41 AM
quit exits the repeat.

-P.

WBA Consulting
12-19-2009, 04:45 PM
Thanks for all the help. After struggling with things for a while, I realized that the code was converting numbers to strings, so I just used the numbers with math to compare the locations. Updates will be on the Reverse Geo-Cache thread in the sandbox. http://forums.parallax.com/showthread.php?p=851955

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
WBA-TH1M Sensirion SHT11 Module (http://www.aestheticacoustics.com/sht11_01.htm)
Special Olympics Polar Bear Plunge, Mar 20, 2010 (http://www.kintera.org/faf/donorReg/donorPledge.asp?ievent=322002&lis=1&kntae322002=BDAEE98623FB443591C072E356710D6B&supId=265642883)

Microcontrolled
12-19-2009, 07:03 PM
To exit from an IF loop after reading something that checks out on your IF then you can make it a IF...ELSEIF loop and that will skip the rest of the checking after one of your IFs are positive. If you just put down IFs then even if it is positive the program will still search for the next IF. This can be useful at times too.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.

Robots are microcontrolled.
I am microcontrolled.

But you·can·call me micro.

Want to·experiment with the SX or just put together a cool project?
SX Spinning light display· (http://www.gadgetgangster.com/find-a-project/56?projectnum=200)
My overstock is killing me.
PM me for absolutly FREE 8-pin Mini Din connectors.