Shop OBEX P1 Docs P2 Docs Learn Events
Using an EM-408 GPS with a BS2 — Parallax Forums

Using an EM-408 GPS with a BS2

er56er56 Posts: 5
edited 2009-08-27 22:29 in BASIC Stamp
I am looking for some sample code to interface an em-408 (us sat) gps with my BS2.

Does anyone have experience using that particular gps module?

My goal is to develop a geo-cashing setup similar to the one presented in MAKE magazine but with the em-408, instead of the parallax gps module.
I have tinkered with the code from that particular project but have not been able to get reliable data from the gps.

Any advice on how to alter the code appropriately would be appreciated.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-08-07 21:07
    I'd see if the site where you bought the GPS has a forum or some software to run the thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • dev/nulldev/null Posts: 381
    edited 2009-08-07 22:11
    What do you mean by "not reliable"? Are you getting data at all? What baud rate? Which Stamp module? What does your SERIN look like? I know you attached the code, but if you explain you might get better answers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • er56er56 Posts: 5
    edited 2009-08-19 17:12
    Thanks for the replies.

    I went ahead and contacted Global Sat and, unfortunately, they are unwilling to help. I ordered the GPS from Spark Fun and I will go ahead and post over there as well and see if anyone can help. Their forum does not usually deal with Basic Stamps but I will give it a try anyway.

    As far as my platform is concerned, I am using a BS2, a 2x16, Backlit, Parrallax LCD.
    The baud for the LCD is: LcdBaud CON 84 (9600)
    The baud for the GPS, per Global Sat specs, is: GPSBaud CON 188 (4800)

    Regarding the data I am getting, this is an example of what I am getting on the LCD which is seemingly random:
    100 deg. 46" 79.1' N
    060 deg. 15' 79.1' E

    Here is the SEROUT/SERIN for the GPS "get latitude":
    ' get latitude from GPS
    SEROUT GPS_SIO, GPSBaud, [noparse][[/noparse]"!GPS", GetLat]
    SERIN GPS_SIO, GPSBaud, 3000, No_Response, [noparse][[/noparse]degrees, minutes, minutesD.HIGHBYTE, minutesD.LOWBYTE, dir]

    Here is the command to "display latitude":
    ' display latitude on LCD line 1
    SEROUT LCD_TX, LcdBaud, [noparse][[/noparse]LcdLine1, DEC3 degrees, DispCC0, " ", DEC2 minutes, MinSym, " "]
    SEROUT LCD_TX, LcdBaud, [noparse][[/noparse]DEC2 (temp / 10), ".", DEC1 (temp // 10), SecSym, " ", "N" + (dir * 5)]

    Even more confusing, the numbers continue to change every few seconds, line by line, sometimes a whole line changes simultaneously, sometimes just the individual deg., seconds, and hours.
    It may be that the GPS is not getting a satellite lock but from everything I have read about this unit it should not be having a lock problem. Just to be sure, I did move the GPS to different outdoor locations with no overhead obstructions.

    I am starting to suspect that my problem is related to the Parallax GPS "smart" mode that partially parses the GPS data. It may be that my GPS isn't able to send me accurate data because the command is truncated?

    Any other ideas for me? Hopefully I have given some more useful info this time around.

    Thanks Again.
  • FranklinFranklin Posts: 4,747
    edited 2009-08-20 22:34
    Try removing all the LCD code and using debug to display your raw data in a terminal to make sure it is the GPS that is the problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-08-20 23:45
    er56 said...

    Here is the SEROUT/SERIN for the GPS "get latitude":
    ' get latitude from GPS
    SEROUT GPS_SIO, GPSBaud, [noparse][[/noparse]"!GPS", GetLat]
    SERIN GPS_SIO, GPSBaud, 3000, No_Response, [noparse][[/noparse]degrees, minutes, minutesD.HIGHBYTE, minutesD.LOWBYTE, dir]

    (snip)

    I am starting to suspect that my problem is related to the Parallax GPS "smart" mode that partially parses the GPS data. It may be that my GPS isn't able to send me accurate data because the command is truncated?

    I may be wrong about this, but I suspect you're trying to use the "Smart Mode" commands with a GPS that does not have that mode. The code that you posted (and I quoted above) is directly from the Parallax GPS demo, right? That code assumes a "Smart Mode". I just looked through the datasheet for the EM-408, and while there are commands that can be sent to it (to warm start it, to adjust the baud rate, etc.), they don't seem to be much like the commands that the Parallax GPS uses in Smart Mode. Were you assuming that you could use the Parallax Smart Mode demo code with GPS modules in general? I'm fairly certain that you cannot.
    I think that instead what you will need to do is to just let the EM-408 transmit the NMEA strings (which it should do as soon as you power it up, though they won't be valid until you get a fix, of course), and you wait for a $GPGGA string, which you then parse to get the data you're after. I've done that with a BS2 and the Parallax GPS in normal (not "Smart") mode, and it works just fine, though you won't have enough variable space to take in all of the data (you just have to share variable space, using it now for Latitude and Longitude, then reuse it for time and date, and so on).
  • SRLMSRLM Posts: 5,045
    edited 2009-08-21 01:34
    You may want to take a look at the code posted http://forums.parallax.com/showthread.php?p=807139

    edit: I found this while browsing, and it might help point you in new directions: http://diydrones.com/forum/topics/705844:Topic:39728

    Post Edited (SRLM) : 8/21/2009 2:07:12 AM GMT
  • er56er56 Posts: 5
    edited 2009-08-26 01:30
    Thanks for all the input to date.

    I was able to get data from a debug code provided by the same source I started with.

    The data looks like this:

    131∞ 86' 38.6" ˝ (
  • SRLMSRLM Posts: 5,045
    edited 2009-08-26 02:44
    Did you hook your GPS up to pin 15 or change that part of the code? Try that, and see if you get an output. If you do and it's gibberish, then try playing around with the baud (4800, 9600 are possible with the BS2)
  • mechanomechano Posts: 8
    edited 2009-08-26 13:38
    can i know what is your problem with Parallax GPS module ?

    if you have any question about it i'm ready to help as much as i know

    i'm working on it since last year in both smart and raw modes and i got alot of experience on it

    regards
  • er56er56 Posts: 5
    edited 2009-08-26 19:16
    SRLM, I did hook up to pin 15 but I didn't fiddle with the baud rate. I will spend a little more time trying to make the code work.
    I wonder if working in the Mac terminal makes a difference or if that could be the reason I am not getting any info in my debug terminal. Even when I unplug the GPS I am not getting an error message, which is clearly in the subroutine. I will give it another shot.

    mechano, I am currently, without much luck, trying to set up a US Sat em-408 GPS. If I end up running the parallax GPS I will gladly pick your brain. Will let you know.

    Thanks, as always.
  • SRLMSRLM Posts: 5,045
    edited 2009-08-26 20:38
    Try putting this on a new line right after main:

    DEBUG "Hello World!", CR
    



    If you don't see that output, then you know that there is a problem with setup (your terminal, USB-to-serial, BOE, etc.), but not necessarily the GPS.

    Post Edited (SRLM) : 8/26/2009 8:49:28 PM GMT
  • er56er56 Posts: 5
    edited 2009-08-27 20:45
    That seemed to work fine, "hello world" came right up in the debug window. Thanks for that.

    Even so, If my GPS is not working, "no GPS" should come up in the debug window, right? From what you can see is the code ready to run? The author mentions something in the prefix about removing part of the code for simplicity.
  • SRLMSRLM Posts: 5,045
    edited 2009-08-27 22:29
    A couple of things, but this is the last that I've got. First, try taking out the "WAIT("-RMC,") part, and see if you get anything now (gibberish or not). Next, try changing the baud rate to the ones in the table for 4800 baud and 9600 baud. The table is in the Basic Stamp Syntax and Reference manual (index in the BS editor). Try all eight. I think your best be is "84", but don't discard anything. When you try the new baud rates, try instead something like this:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    rxdata VAR Byte
    rxpin PIN 15
    baud CON 84 'replace this as necessary
    
    main:
        SERIN rxpin, baud, [noparse][[/noparse]rxdata]
        DEBUG rxdata
        GOTO main
    



    That should echo any received character to the terminal.
Sign In or Register to comment.