Shop OBEX P1 Docs P2 Docs Learn Events
Problem reading GPS data — Parallax Forums

Problem reading GPS data

ArchiverArchiver Posts: 46,084
edited 2000-03-13 18:44 in General Discussion
Group,

I've connected my Stamp 2 to a GPS unit. I'm trying parse out the time field. These are the first 6 digits that follow "GPRMC". I have the program waiting for the string "GPRMC" and that seems to work just fine. Then I save the next 6 digits as a string in memory. That also appears to work as advertised. When I try to read the 6 digits from memory however, I get odd characters. I know I've captured the correct 6 digits because I have them·"debug" to the terminal program once per second. Just like you'd expect, the·rightmost ones "digit" changes each second, going through 10 changes before the tens "digit" changes to the next odd character. I can watch it count off the seconds in these odd characters. The program itself seems to run fine.

Example: I was trying to read the time at·during the 1900 hour (UTC). The first (leftmost) character which should have been "1" was returning as the ")". During the 2000 hour, which should have been the number "2", I was getting the letter "I" as the leftmost character.

I'm either not saving the right format (hex, bin, dec) or I'm not reading it back out correctly. I'm relatively sure its some type of conversion I'm not doing right.

Help!

Robert Swain
robert@etpsolutions.com

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-03-13 16:56
    Robert,

    There's a BOB-II/BS2/GPS application example at our web site that should be
    helpful... The link is near the bottom of the BOB-II description page.

    At 09:36 AM 3/13/00 -0500, you wrote:
    >
    > I've connected my Stamp 2 to a GPS unit. I'm trying parse out the time
    field.
    > These are the first 6 digits that follow "GPRMC". I have the program waiting
    > for the string "GPRMC" and that seems to work just fine. Then I save the
    next
    > 6 digits as a string in memory. That also appears to work as advertised.
    When
    > I try to read the 6 digits from memory however, I get odd characters. I know
    > I've captured the correct 6 digits because I have them·"debug" to the
    > terminal program once per second. Just like you'd expect, the·rightmost ones
    > "digit" changes each second, going through 10 changes before the tens
    "digit"
    > changes to the next odd character. I can watch it count off the seconds in
    > these odd characters. The program itself seems to run fine.
    >
    > Example: I was trying to read the time at·during the 1900 hour (UTC). The
    > first (leftmost) character which should have been "1" was returning as the
    > ")". During the 2000 hour, which should have been the number "2", I was
    > getting the letter "I" as the leftmost character.


    Mike Hardwick, for Decade Engineering -- <http://www.decadenet.com>
    Manufacturer of the famous BOB-II Serial Video Text Display Module!
  • ArchiverArchiver Posts: 46,084
    edited 2000-03-13 18:44
    On 13 Mar 00 at 9:36, Robert, ETP Solutions wrote:

    > I've connected my Stamp 2 to a GPS unit. I'm trying parse out the
    > time field. These are the first 6 digits that follow "GPRMC". I have
    > the program waiting for the string "GPRMC" and that seems to work
    > just fine. Then I save the next 6 digits as a string in memory. That
    > also appears to work as advertised. When I try to read the 6 digits
    > from memory however, I get odd characters...

    Robert-

    My guess is your Stamp is getting out of sync with the bit stream.
    There are a couple of real easy ways for this to happen:

    - Hit your Stamp with a too-fast serial stream. By the time the
    Stamp realizes it's seen the WAIT objective and reacts accordingly,
    it's behind schedule looking at what comes next. Set your GPS and
    program to work at 2400 baud or even slower and see if that helps.
    If so, try at 4800, etc. to find what speed you can handle.

    - Put too many instructions in the SERIN part of your program. If
    you do much of anything between the WAIT part of SERIN and the data
    capture, you're almost guaranteed to lose data. The following worked
    for me:

    baudmode CON 10000/48 - 20 + $4000 ' 4800 baud inverted
    gpspin CON 7
    utc VAR BYTE(6)

    again:
    SERIN gpspin,baudmode,[noparse][[/noparse]WAIT("GPRMC,"),STR utc\6]
    DEBUG STR utc\6,CR
    GOTO again


    The following would definitely not work because of the time between
    the two SERIN actions:

    again:
    SERIN gpspin,baudmode,[noparse][[/noparse]WAIT("GPRMC,")]
    DEBUG "Got GPRMC",CR
    SERIN gpspin,baudmode,[noparse][[/noparse]STR utc\6]
    DEBUG STR utc\6,CR
    GOTO again

    If you get stuck post your code and maybe somebody will see a fix.

    Steve
Sign In or Register to comment.