Shop OBEX P1 Docs P2 Docs Learn Events
Parallax GPS NMEA String comparison code help for near-newbie — Parallax Forums

Parallax GPS NMEA String comparison code help for near-newbie

WBA ConsultingWBA Consulting Posts: 2,935
edited 2009-12-19 12:03 in Propeller 1
I am trying to create the Reverse Geo-Cache Project 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 (logs incorrectly formatted data, but works for analysis; see my post on that thread about the bug)
GPS to VGA Object
GPS Float Object

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
Special Olympics Polar Bear Plunge, Mar 20, 2010

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-13 08:13
    Something like this should work:

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


    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 12/13/2009 8:18:32 AM GMT
  • SRLMSRLM Posts: 5,045
    edited 2009-12-13 16:36
    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

    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 ConsultingWBA Consulting Posts: 2,935
    edited 2009-12-14 21:26
    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
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-14 21:41
    quit exits the repeat.

    -P.
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2009-12-19 09:45
    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
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-12-19 12:03
    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·
    My overstock is killing me.
    PM me for absolutly FREE 8-pin Mini Din connectors.
Sign In or Register to comment.