go_away

Author Topic: Axon2 and GPS, questions  (Read 1899 times)

0 Members and 1 Guest are viewing this topic.

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Axon2 and GPS, questions
« on: July 26, 2010, 01:49:32 PM »
Hello all,

My goal is to get my Axon2 to read data from my EM-408 GPS http://www.sparkfun.com/commerce/product_info.php?products_id=8234) then to have it spit out the position, velocity, heading and time information back to my computer via USB.

First thing, although this is the software forum, I should explain, I have the GPS wired to UART0, with Tx going to Rx, and Rx going to Tx. The power and ground wires go to a separate power module which gives me the required 3.3V. There is another wire labelled Enable/Disable...

I am trying to figure things out using Webbotlib, and have come up with the following:

Code: [Select]
#include "sys/Axon.h"
#include "rprintf.h"
#include "uart.h"
#include "Sensors/GPS/NMEA/gpsNMEA.h" //GPS library

GPS_NMEA myGPS = MAKE_GPS_NMEA(UART0,4800); //Declares the GPS as a device, Set UART port and baud rate

void appInitHardware(void){
   
   //setup UART
   uartInit(UART1, 9600); 
   rprintfInit(&uart1SendByte);

}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){

return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){

//GPS section
if(gpsNMEAprocess(&myGPS) ){
    // We have received something
    if(myGPS.info.valid){
        // And we have a satellite fix
        if(myGPS.info.changes.values.longitude && myGPS.info.changes.values.latitude && myGPS.info.changes.values.speed && myGPS.info.changes.values.track){
            // Longitude and latitude have been received - so fetch the values
                            double longitude = myGPS.info.longitude;
                            double latitude = myGPS.info.latitude;
double speed = myGPS.info.speed;
double track = myGPS.info.track;
rprintf("Longitude = %d\n",myGPS.info.longitude);
rprintf("Latitude = %d\n",myGPS.info.latitude);
rprintf("Speed = %d\n",myGPS.info.speed); //In Knots
rprintf("Track = %d\n",myGPS.info.track);
        }
    }
else rprintf ("Fail to acquire signal");
}
else rprintf ("Fail to receive something");
return 0;
}

Right now, I plug things together, and get the "fail to receive something" message repeatedly.

Offline teoxan

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
Re: Axon2 and GPS, questions
« Reply #1 on: July 29, 2010, 06:18:56 AM »

First of all, you have to be outside your room for your GPS to get a valid signal. Or close to an open Window.

You have the GPS in UART0, but you have not intialize it.
Also, change the baud rate of the Axon, it works in 115200.

Do all this and see if you get a signal.

Theo

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: Axon2 and GPS, questions
« Reply #2 on: July 29, 2010, 07:15:49 AM »
Did you wait a few minutes after powering the GPS on? It needs time to acquire a signal

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #3 on: July 29, 2010, 09:34:29 AM »
For the signal, I was outside and had the GPS powered for 45 minutes, just to be sure.

I have added an Initialise for UART 0 in this form:
   
Code: [Select]
//setup UART communication protocol
   uartInit(UART1, 9600);  //set the Baud rate for communication at UART 1 (USB)
   rprintfInit(&uart1SendByte);
   uartInit(UART0, 4800);//set the Baud rate for communication at UART 0 (GPS)
   

I am assuming I've done the initialise properly.

Still nothing  :(

I don't currently have any way to connect the GPS directly to my PC for testing. I am also concerned about the Enable/Disable wire, I am assuming the GPS is enabled by default...

I am trying to eliminate possibilities here, so is there anything silly I'm missing in my code? I know the GPS works at 4800 baud, and I have the Axon 2 at 9600 so it doesn't spit out miles and miles of readings too fast to read on screen.

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: Axon2 and GPS, questions
« Reply #4 on: July 29, 2010, 09:45:44 AM »
The enable wire must be set high or low to actually enable the GPS, with it "floating" the GPS will default to be disabled

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #5 on: July 29, 2010, 09:49:58 AM »
Hmmmm,

I guess I'll have to do some more reading to figure out how to have it set "high or low"... This means I need to power it somehow?

Offline teoxan

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
Re: Axon2 and GPS, questions
« Reply #6 on: July 29, 2010, 09:52:51 AM »
For the signal, I was outside and had the GPS powered for 45 minutes, just to be sure.

I have added an Initialise for UART 0 in this form:
   
Code: [Select]
//setup UART communication protocol
   uartInit(UART1, 9600);  //set the Baud rate for communication at UART 1 (USB)
   rprintfInit(&uart1SendByte);
   uartInit(UART0, 4800);//set the Baud rate for communication at UART 0 (GPS)
   

I am assuming I've done the initialise properly.

Still nothing  :(

I don't currently have any way to connect the GPS directly to my PC for testing. I am also concerned about the Enable/Disable wire, I am assuming the GPS is enabled by default...

I am trying to eliminate possibilities here, so is there anything silly I'm missing in my code? I know the GPS works at 4800 baud, and I have the Axon 2 at 9600 so it doesn't spit out miles and miles of readings too fast to read on screen.




Just a silly question, but, do you have an antenna on it?
Don't worry about the Enable/Disable pin, just don't use it.

You can check if the GPS is working by deleting the "if" statement in your code.
GPS receivers do "spit out" data even if they don't get a signal, you just get zeros. But you can try it to see if it actually works.


Also, how exactly do you have physically connected it with the Axon?

Let us know and we'll see what else to do.

Theo

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #7 on: July 29, 2010, 10:14:45 AM »
I don't have an external antenna on it right now. I'm also glad to hear I don't need to use the enable/disable...

I know this isn't the proper forum for hardware questions, but since it's relevant:
GPS Tx goes to UART0 Rx
GPS Rx goes to UART0 Tx

Since I needed 3.3V supply, I was recommended to build a regulated voltage supply circuit using a linear voltage regulator and 2 capacitors. It takes a 5V input from the Axon 2 and gives me 3.3V. This is apparently in case I fry something, it will be an external regulator, not anything on my pricey Axon. The VCC and GND from the GPS go to that circuit.

I have removed the if structure for testing, and do get a nice bunch of zeroes for all the variables. I will let the setup sit outside for a bit longer to make sure.

Edited to add: I get the zeroes regardless of whether or not the GPS is actually plugged into the Axon 2... This means that zeroes are by default.
« Last Edit: July 29, 2010, 10:27:51 AM by Aberg098 »

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: Axon2 and GPS, questions
« Reply #8 on: July 29, 2010, 10:15:12 AM »
You could also use the Webbotlib Project Designer (
how to is here
) to setup all the GPS correctly in webbotlib.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: Axon2 and GPS, questions
« Reply #9 on: July 29, 2010, 01:01:02 PM »
I second madsci1016. Use PD (WebbotLib Project Designer) and it'll set up all your code properly.

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #10 on: July 29, 2010, 03:47:55 PM »
Alright, so I've re done everything using project designer. Still get a nice bunch of zeroes on hyperterminal. I'm now reasonably sure that my problem is hardware related...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: Axon2 and GPS, questions
« Reply #11 on: July 29, 2010, 03:56:22 PM »
zeros mean its not getting data . . . check everything with a multimeter, and make sure your baud rates are right.

The datasheet doesn't specify the default baud, but my money is on 4800. Try several baud rates and see what happens.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 109
Re: Axon2 and GPS, questions
« Reply #12 on: July 29, 2010, 07:28:15 PM »
Couple of points in your original code (although you may now have changed some of this).
1. You haven't created a receive buffer on the Axon as recommended in the WebbotLib manual - so you may be loosing characters. Does the decimal point of the LED flash out an error msg? Now you're using Project Designer then you can specify the size of the input buffer for the uart.
2. You are trying to use '%d' to print out a floating point value - which wont work. See the manual for rprintfFloat
3. Your 'if' statement is testing for too many flags that have changed ie longitude, latitude, speed and track. This will only succeed if a single message contains all 4 of those values.  I suggest you remove the 'if' statement until you've got stuff going.

Incidentally - the 'MAKE_GPS' specifies the baud rate you want to use and the lib automatically initialises the UART to that baud rate the first time the 'process' function is called - so you don't need to explicitly init the uart yourself.

The 'fall back' is to write a small prog that reads data from UART0 and then writes it out on UART1 (ie you are using the Axon as a TTL to USB shifter). Then run Hyperterminal, or similar, and you will see the raw output coming out of the GPS. Do you see anything?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #13 on: August 03, 2010, 09:31:54 AM »
I've been doing some hardware checks, to make sure that everything is okay on that end. It's not, I need to make a circuit to keep the Rx pin "HIGH". Will post back later once that is done.


Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Axon2 and GPS, questions
« Reply #14 on: August 03, 2010, 09:53:53 AM »
Saw this on the Sparkfun comments:
"Some things not in the data sheet--tie both enable and RX to 3.3 V and the output is defaulted to 4800 baud 8,n,1. "
3.3V power levels...
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Aberg098Topic starter

  • Full Member
  • ***
  • Posts: 66
  • Helpful? 0
Re: Axon2 and GPS, questions
« Reply #15 on: August 03, 2010, 11:18:17 AM »
Saw this on the Sparkfun comments:
"Some things not in the data sheet--tie both enable and RX to 3.3 V and the output is defaulted to 4800 baud 8,n,1. "
3.3V power levels...

Well that's interesting!

 


Get Your Ad Here