Shop OBEX P1 Docs P2 Docs Learn Events
Help: PMB-648 SiRF GPS Module — Parallax Forums

Help: PMB-648 SiRF GPS Module

BStephenBStephen Posts: 5
edited 2014-05-15 19:43 in Accessories
Hi friends,

I have been scouring the internet for quite a few hours now (~10 hours to be exact) looking for a direction to coding the PMB-648 GPS module using SimpleIDE with the Parallax propeller board. I can't seem to figure out the direction I am supposed to take to use the GPS.

We are making a robot for the RoboMagellan competition utilizing the parallax propeller microcontroller, HC-SR04 Ultrasonic sensors and the PMB-648 SiRF GPS for the robot. We also decided to code the entire project in C, as we are all quite adept to using C, and have no time to learn another language (we have 6 other courses to take care of).

Can someone point me to the right direction or even post a demo code in C for the GPS?

Much thanks,
Stephen

Comments

  • PublisonPublison Posts: 12,366
    edited 2014-04-08 12:26
    BStephen wrote: »
    Hi friends,

    I have been scouring the internet for quite a few hours now (~10 hours to be exact) looking for a direction to coding the PMB-648 GPS module using SimpleIDE with the Parallax propeller board. I can't seem to figure out the direction I am supposed to take to use the GPS.

    We are making a robot for the RoboMagellan competition utilizing the parallax propeller microcontroller, HC-SR04 Ultrasonic sensors and the PMB-648 SiRF GPS for the robot. We also decided to code the entire project in C, as we are all quite adept to using C, and have no time to learn another language (we have 6 other courses to take care of).

    Can someone point me to the right direction or even post a demo code in C for the GPS?

    Maybe someone from the forums or Parallax has some C code.?


    Much thanks,
    Stephen

    Welcome to the forums!

    There are a couple of demos the show BasicStamp and Arduino C code:

    http://learn.parallax.com/KickStart/28500

    I'll see if I can dig up more in the mean time. Others may chime in with some more C stuff.

    Maybe someone from the forums or Parallax has some C code.?

    Jim
  • BStephenBStephen Posts: 5
    edited 2014-04-08 13:41
    Hi Jim,

    Thanks!

    I have actually taken a look at the Spin, Stamp and Arduino C code for the GPS. The Spin and Stamp code are completely unknown to me, in fact, I only heard about these languages when I picked up the propeller which was a couple months ago. The Arduino C code from what I gathered uses softwareserial.h and tinygps.h, which, from research, are Arduino specific. I have tried looking for TinyGPS alternatives for the propeller to no luck.

    I am still hoping to have a breakthrough... If I ever find out, I'll post it here. Until, then still "googling".

    Cheers,
    Stephen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-09 15:33
    The C language on the Propeller chip is still relatively new. You could write your own GPS object. The GPS sends the data out (usually at 4800 bps) every second serially. So right off the bat you need a serial port driver which there is. Once you have the data it is just a matter of parsing the respective fields into variables. If the serial driver waits for the $GPRMC string and just dumps that into the array then getting the fields should be pretty straightforward. You need only read the comma-delimited fields one at a time and the fields are in a fixed order and number, you just need to count commas.
  • BStephenBStephen Posts: 5
    edited 2014-04-10 15:58
    Hey Chris,

    Thanks for the input!
    The way we have the robot set up, we can't use the serial port. This is because we have a netbook that takes input from a camera, to visual basic and over to the propeller.

    I have question though, is it possible to have to different languages running on the propeller? If we could run both C and Spin, I think we might be able to get the GPS working. In the meantime, we resorted to using an Arduino for the GPS to figure what to do with the data. Ultimately, we want to use the propeller as the only microcontroller though.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-11 08:48
    So does the Propeller or the Netbook need the GPS data? It is possible with minimal hardware to connect the GPS directly to the Netbook via USB interface. It seems strange to not be able to solve the issue on the Propeller with an additional serial port interface but you can with an Arduino?
  • BStephenBStephen Posts: 5
    edited 2014-04-11 11:49
    With the implementation of Arduino, what we had meant to do was that it would send the GPS data over to Visual Studios on the netbook. In addition to that, we have a USB camera connected to the netbook that also sends data to Visual Studios on the netbook. Both pieces of data (GPS and Camera) are then sent to the propeller via USB. We made this our fallback plan if all doesn't go well with programming the propeller.

    Sorry if I have cause some confusion, I misunderstood what you were talking about with the serial port. Somehow when you said said serial port driver, I had thought of the port that the USB connection is made.

    So, we did as you said, and it was a bit of a challenge, but here's a code that one of the group member was able to write out to get the data. However, there's a couple things, 1) most of the time, the string is able to grab the $GPGGA line, which we want, but sometimes it is grabbing other data and 2) when my group member used readStr() command, he was getting garbage and had to resort readChar() instead and store it into a char array to create a string.

    Here's the code he came up with:
    #include "simpletools.h"
    #include "simpletext.h"
    #include "string.h"
    #include "serial.h"
    #include <propeller.h>
    #include <stdarg.h>


    serial *gps, *pc;


    int main()
    {
    int number, i;
    char location[256];
    i=-1;
    gps = serial_open(15, 14, 0, 4800);
    pc = serial_open(31,30,0,115200);
    while(1)
    {
    if(readChar(gps)=='$')
    {


    do
    {
    i++;
    location = readChar(gps);
    } while(location!='\n');




    location=0;
    dprint(pc,"%s",location);
    }
    pause(500);
    }
    }
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-11 15:53
    What I meant was, you could connect the GPS directly to the Netbook via a USB adapter such as the Prop Plug or USB2SER. These are not RS-232 adapters. But a COM Port is assigned to them by the PC. The PC can then read/parse the GPS data and send it to the Propeller chip.
  • BStephenBStephen Posts: 5
    edited 2014-04-15 18:13
    Sorry for the inactivity, been studying for finals.

    We had not known that was actually quite possible... That is quite helpful. However, with time constraints, we cannot go down the path as I can't seem to find it locally, and thus have to buy it on-line. The code posted above, more or less works and we have no idea why. It's the only lead we have with it and we are still messing with the code, so I'll update when I can.

    Anyway, suffice to say, thank you for the help so far. I will continue to update this thread on our progress, and ask more questions as they come.
  • mnastasimnastasi Posts: 9
    edited 2014-05-15 19:43
    okay. i got some progress. try this:
    //
    /**
    * This is the main serial_inout program file.
    */
    #include "simpletools.h"
    #include "fdserial.h"


    #define NONE 0
    #define DEC 1
    #define HEX 2
    #define BIN 3
    #define CHR 4


    void serout(text_t *ser, int delay, char* string, int type, int val, int end);
    void serin(text_t *ser, int wait, void (*function)(), int type, void* value);


    void printnewline() {
    print("\n");
    }


    int main(void)
    {
    int inpin = 3;
    int outpin= 2;
    int baud =9600;
    int value = 0x55;


    text_t *ser = fdserial_open(inpin, outpin, 0, baud);


    int number, i;
    char location[256];
    i=-1;


    pause(500);
    print("SEROUT/SERIN DEMO\n");


    while(1)
    {
    //serout(ser, 100, "HELLO", 0, value, CR);
    //serout(ser, 1, "DEC VAL ", DEC, value, CR);
    //serout(ser, 1, "HEX VAL ", HEX, value, CR);
    //serout(ser, 1, "BIN VAL ", BIN, value, CR);
    //serout(ser, 1, "CHR VAL ", CHR, value, CR);


    //print("Enter DEC: ");
    // serin(ser, 5000, printnewline, DEC, &value);
    //print("Got DEC %d\n", value);


    //print("Enter HEX: ");
    //serin(ser, 5000, printnewline, HEX, &value);
    //print("Got HEX %x\n", value);


    //print("Enter BIN: ");
    //serin(ser, 5000, printnewline, BIN, &value);
    //print("Got BIN %b\n", value);


    //print("Enter CHR: ");
    serin(ser, 1, printnewline, CHR, &value);
    //print("Got Char %c\n", value);
    if(value=='$')
    {

    print("Got GPS \n");
    do
    {
    i++;
    location = readChar(ser);
    } while(location!='\n');


    location=0;
    print("location %s",location);
    }
    }
    return 0;
    }


    // i did not use this serout
    void serout(text_t *ser, int delay, char* string, int type, int val, int end)
    {
    int n = 0;
    int len = strlen(string);


    for(n = 0; n < len; n++) {
    writeChar(ser, string[n]);
    pause(delay);
    }


    if(DEC == type) {
    writeDec(ser, val);
    pause(delay);
    writeChar(ser, end);
    }
    else if(HEX == type) {
    writeHex(ser, val);
    pause(delay);
    writeChar(ser, end);
    }
    else if(BIN == type) {
    writeBin(ser, val);
    pause(delay);
    writeChar(ser, end);
    }
    else if(CHR == type) {
    writeChar(ser, val);
    pause(delay);
    writeChar(ser, end);
    }
    else {
    writeChar(ser, end);
    }
    }




    void serin(text_t *ser, int wait, void (*function)(), int type, void* value)
    {
    char buf[33]; // big enough for hex, dec, bin, or char


    while(--wait > -1) {
    if(fdserial_rxReady(ser))
    break;
    pause(1);
    }
    if(wait < 0) {
    writeLine(ser, "No input");
    function();
    return;
    }


    readStr(ser, buf, 33);


    if(DEC == type) {
    sscan(buf, "%d", value);
    }
    else if(HEX == type) {
    sscan(buf, "%x", value);
    }
    else if(BIN == type) {
    sscan(buf, "%b", value);
    }
    else if(CHR == type) {
    sscan(buf, "%c", value);
    }
    }
Sign In or Register to comment.