Shop OBEX P1 Docs P2 Docs Learn Events
GPS & Javelin — Parallax Forums

GPS & Javelin

Istha PowronIstha Powron Posts: 74
edited 2009-03-18 00:23 in General Discussion
Hi all you Javelin enthusiasts!

I am trying to communicate with the parallax GPS module.

I have had success communicating with it using the /raw stream, but am getting interesting results when I use SMART mode.

In STAMP one would send ("!GPS", $01) to the GPS receiver and expect a single byte answer.

In Javelin, I am sending;


GPS_tx_Uart.sendString("!GPS");
GPS_tx_Uart.sendByte(0x01);

CPU.delay (5000);

if(GPS_rx_Uart.byteAvailable())
{
valid = GPS_rx_Uart.receiveByte();
}

System.out.println(valid );

When this snippet loops, I get the following output;

1 33 71 80 83 1 33 71 80 83 1 33 71

when I should be expecting;

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Any ideas? Suggestions??

Istha

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
Adam Smith

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-13 08:19
    Here is a class I once wrote for the Parallax GPS.
    Sorry, no test program as I never had a GPS to test it.
    You are supposed to call a·method and then directly
    use the declared public variables (as read-only values)
    that will be set with results by the method.

    The class should be saved in folder ...\lib\stamp\peripheral\gps

    Could ypu post your raw mode code?
    My class only supports smartmode.

    regards peter



    Post Edited (Peter Verkaik) : 3/13/2009 8:30:15 AM GMT
  • Istha PowronIstha Powron Posts: 74
    edited 2009-03-15 22:07
    Peter,

    Thank's for the library.

    Here's the code that reads the RAW data. It works, but of course you ahve to do all the parsing to get to the numbers.

    Regards,

    Istha

    static void ReadGPSMessage()
    {
    c = 0xff;

    while (c != '\n')

    {


    if(GPS_rx_Uart.byteAvailable())
    {

    c = (char)GPS_rx_Uart.receiveByte();
    GPSBuffer.append(c);

    } //end if

    } // end while

    } // end bufferMessage

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
    Adam Smith
  • Istha PowronIstha Powron Posts: 74
    edited 2009-03-16 02:36
    Peter,

    Here is the "raw" output;

    $GPRMC,020247,A,2731.6377,S,15255.1461,E,000.0,354.0,160309,,,A*67
    $GPGGA,020248,2731.6291,S,15255.1458,E,1,03,06.6,00087.3,M,039.4,M,,*57
    $GPGSA,A,2,07,17,25,,,,,,,,,,06.7,06.6,00.9*0D
    $GPGSV,3,1,12,04,06,001,00,07,33,067,42,08,63,110,36,10,01,291,00*79
    $GPGSV,3,2,12,11,26,106,00,13,01,018,00,15,22,229,00,17,68,338,35*79
    $GPGSV,3,3,12,25,15,055,38,26,29,229,00,27,37,215,00,28,56,183,28*7A
    $GPRMC,020248,A,2731.6291,S,15255.1458,E,001.7,354.0,160309,,,A*6D
    $GPGGA,020249,2731.6290,S,15255.1459,E,1,03,06.6,00087.3,M,039.4,M,,27*75
    $GPRMC,020249,A,2731.6290,S,15255.1459,E,001.7,354.0,160309,,,A*6C
    $GPGGA,020250,2731.6290,S,15255.1460,E,1,03,06.6,00087.3,M,039.4,M,,*54
    $GPGSA,A,2,07,17,25,,,,,,,,,,06.7,06.6,01.0*05
    $GPGSV,3,1,12,04,06,001,00,07,33,067,42,08,63,110,35,10,01,291,00*7A
    $GPGSV,3,2,12,11,26,106,27,13,01,018,00,15,22,229,28,17,68,338,34*77
    $GPGSV,3,3,12,25,15,055,38,26,29,229,29,27,37,215,00,28,56,183,27*7E
    $GPRMC,020250,A,2731.6290,S,15255.1460,E,001.7,354.0,160309,,,A*6E
    $GPGGA,020251,2731.6290,S,15255.1461,E,1,03,06.6,00087.3,M,039.4,M,,*54

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
    Adam Smith
  • Istha PowronIstha Powron Posts: 74
    edited 2009-03-16 02:49
    Peter,

    I have tried you library and could not get it to work.

    I have even taken a section out of teh code and put it directly into my program.

    I have had a look at the code in your library.

    It's beautifully written as could be expected, however I have a concern with this section;

    " while (i<response) {
    buf[noparse][[/noparse]i++] = (char)rx.receiveByte();
    }"

    Given that the definition of .receiveByte() says;

    "Receives a byte from a receive Uart. This method will block until a byte is available.
    Returns:
    the next byte in the receive buffer."

    This suggests that if ther eis no data in the buffer the program will loop indefinitely and lock up.

    Is this the case?

    Istha

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
    Adam Smith
  • Istha PowronIstha Powron Posts: 74
    edited 2009-03-16 04:22
    Peter,

    I have tried to use your library, but am having greta difficulty getting it to link.

    I KNOW the code is in teh right library.

    Here is my code;

    import stamp.core.*;
    import stamp.peripheral.gps.GPS_Parallax;



    public class GPSLog_4
    {

    //GPS Variables

    final static int GPS_SERIAL_RX_PIN = CPU.pin1; // Transmit Pin

    static Uart GPS_Uart = new Uart( Uart.dirReceive, GPS_SERIAL_RX_PIN,
    Uart.dontInvert, Uart.speed4800,Uart.stop1 );

    static int Satellites;



    public static void main()
    {

    GPS_Parallax(GPS_Uart,0);

    System.out.println("Starting\n\r" );

    CPU.delay (20000); //Allow time for the system to settle


    while (true)
    {

    Satellites = getSats() ;

    System.out.println(Satellites );


    } //End while


    } // end main
    }

    When I compile, it throws errors on;

    GPS_Parallax(GPS_Uart,0); - The keyword new is expected........

    Satellites = getSats() ; - no method named getStats.....


    This would indicate it can't find teh library.

    I have tried;

    import stamp.peripheral.gps.*;

    and

    import stamp.peripheral.gps.GPS;


    Still can't find the library.

    Any advice?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
    Adam Smith
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-16 04:55
    You need to create an instance, hence·the error: keyword new expected.

    import stamp.core.*;
    import stamp.peripheral.gps.*;

    public class GPSLog_4
    {

    · //GPS Variables

    · final static int GPS_SERIAL_RX_PIN = CPU.pin1; // Transmit Pin

    · static Uart GPS_Uart = new Uart( Uart.dirReceive, GPS_SERIAL_RX_PIN, Uart.dontInvert,Uart.speed4800,Uart.stop1 );

    · static int Satellites;
    · static GPS_Parallax myGps = new GPS_Parallax(GPS_Uart,0);

    · public static void main()
    · {
    ··· System.out.println("Starting\n\r" );
    ··· CPU.delay (20000); //Allow time for the system to settle

    ··· while (true)
    ··· {
    ····· Satellites = myGps.getSats() ;
    ····· System.out.println(Satellites );
    ··· } //End while
    · } // end main
    }


    BTW, Thanks for the raw data.

    regards peter.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-16 05:00
    The loop

    " while (i<response) {
    buf[noparse][[/noparse]i++] = (char)rx.receiveByte();
    }"

    receives exactly as much bytes as the GPS will transmit
    depending on which command· was sent to the GPS.
    If the GPS operates correctly (eg, no malfunction)
    this loop will not block.

    regards peter
  • Istha PowronIstha Powron Posts: 74
    edited 2009-03-18 00:23
    Thank's again Peter,

    I have it working now (or should I say; you have it working!).

    I am suprised at the slow response with the "smart mode" calls. i.e., if you do this;

    myGps.getTime();
    Satellites = myGps.getSats();
    HRS = myGps.hours;
    MINS = myGps.minutes;
    SECS = myGps.seconds;

    it takes around 2 seconds for the GPS to send the data back.

    In Raw mode, you can get the stream, parse the data and convert the variables in about half a second.

    I would have thought that by putting a micro on the GPS, you would have been able to get the data out faster.

    Thank's anyway for your help. At least I have been able to test the 'smart" mode.

    regards,

    Istha

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    The robot is going to lose. Not by much. But when the final score is tallied, flesh and blood will beat the damn monster.
    Adam Smith
Sign In or Register to comment.