Society of Robots - Robot Forum
Software => Software => Topic started by: Aberg098 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 (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:
#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.
-
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
-
Did you wait a few minutes after powering the GPS on? It needs time to acquire a signal
-
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:
//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.
-
The enable wire must be set high or low to actually enable the GPS, with it "floating" the GPS will default to be disabled
-
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?
-
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:
//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
-
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.
-
You could also use the Webbotlib Project Designer ( how to is here (http://www.youtube.com/watch?v=FPhMES0PFEw&feature=player_embedded#ws)) to setup all the GPS correctly in webbotlib.
-
I second madsci1016. Use PD (WebbotLib Project Designer) and it'll set up all your code properly.
-
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...
-
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.
-
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?
-
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.
-
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...
-
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!