Shop OBEX P1 Docs P2 Docs Learn Events
Can someone help me with the GPS reciever module source code/ program interpred — Parallax Forums

Can someone help me with the GPS reciever module source code/ program interpred

XanderXander Posts: 23
edited 2009-02-08 22:45 in BASIC Stamp
Hello,

I need to know how location information are obtained from GPS receiver module & process into output to 4x20 serial LCD ? Which books or document should I reference to understand them ?

For example :

Get_Lat:
SEROUT Sio, Baud, [noparse][[/noparse]"!GPS", GetLat]
SERIN Sio, Baud, 1000, No_Response, [noparse][[/noparse]degrees, minutes, minutesD.HIGHBYTE, minutesD.LOWBYTE, dir]

' convert decimal minutes to tenths of seconds
workVal = minutesD ** $0F5C ' minutesD * 0.06

DEBUG MoveTo, FieldLen, 12, DEC3 degrees, DegSym, " ", DEC2 minutes, MinSym, " "
DEBUG DEC2 (workVal / 10), ".", DEC1 (workVal // 10), SecSym, " "
DEBUG "N" + (dir * 5)

' convert to decimal format, too
workVal = (minutes * 1000 / 6) + (minutesD / 60)
DEBUG " (", " " + (dir * 13), DEC degrees, ".", DEC4 workVal, " ) "

Why it is work this way ? Thank you.

Warm regards.

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2009-02-08 16:01
    I don't know how the Parallax GPS module works internally, but the GPS device outputs information in the form of NMEA sentences.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • XanderXander Posts: 23
    edited 2009-02-08 16:21
    Hello,

    Yes I know something about NMEA sentences. For my project, I will follow the GPGGA of NMEA sentences.

    However, I wanted to know what the meaning of the code in the GOSUB section of the GPS module. Which document should I read to understand them better so I would write a report. Thank you.

    Thanks Rick.

    Warm regards.
  • FranklinFranklin Posts: 4,747
    edited 2009-02-08 18:04
    The code in your post sends a serial request for the latatude and then stores the response in several variables then displays the converted data. If you have a more specific question please ask it and include the entire code you are asking about. What happens when you run the code you have now?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-08 19:09
    The code you're quoting here uses the Parallax GPS' "smart mode". In that mode, it does NOT transmit NMEA strings, but instead sends out just the data being asked for by the SEROUT command. When you send the GetLat command you get back the 5 bytes that you have in the SERIN command that follows.

    The code that you're talking about is for converting decimal minutes and seconds to degrees/minutes/seconds, I believe. For example, if you had 43.5000 degrees north, that is the same as 43 degrees, 30 minutes, 00 seconds north (since exactly 30 minutes is .5 degrees).

    Now, what you get from the GPS module is the actual number of degrees, and the actual number of whole minutes, but then a number (actually, two bytes that you read into the HIGH and LOW bytes of a Word variable so they can be used together) representing the decimal fractions of minutes, and that needs to be converted to DDMMSS format (well, you could use it as is, but that's not the normal format that we use).

    Notice the first piece of conversion code, reading

    workVal = minutesD ** $0F5C ' minutesD * 0.06

    As the comment indicates, it multiplies the number of fractional minutes by .06. If you look in the Stamp manual or the Stamp help file for information on operators, you'll see an explanation of how the ** operator can be used to do this kind of multiplication by a fraction. As I'm sure you're aware, you can't simply have

    workVal = minutesD * .06

    since .06 does not exist in the Stamp's integer mathematics.

    Post Edited (sylvie369) : 2/8/2009 7:15:03 PM GMT
  • XanderXander Posts: 23
    edited 2009-02-08 22:45
    Hello,

    My program is about the same as the GPS module sample code. However, I did not include the altitude because there is a problem. I display the GPS information on my Parallax 4x20 serial LCD by using Serout command.

    Thank you·sylvie369 and Franklin. I understand the code better now.

    Warm regards.
Sign In or Register to comment.