Using the 5Hz Locosys GPS with Arduino/ArduPilot

Sparkfun is now selling the excellent 5Hz Locosys (Mediatek chipset) GPS that Dean Goedde uses in ArduPilot. We're developing a daughterboard that will allow this 3.3v module to be a plug-and-play replacement for the 5v, 1Hz EM406 GPS that we're currently using for ArduPilot. In the meantime, if you want to start playing with a 5Hz GPS with Arduino here's some code and instructions to get you started.
The code is Jordi's new NMEA parser for the Locosys GPS. It's checksum verified, rocksolid, continuous, no delays, loop rate is about 32000hz. It uses pointers, so it's efficient.

You have to configure the Locosys for the first time you use it. It's very easy, you just need an FTDI cable. Be sure to connect the GPS to a 3.3 volt source. (We'll do this setup for you in the commercial version)


Instructions (please use the picture above as reference):

1-Run Realterminal and open the port @4800bps, you should see all the NMEA stuff, is not check the connections..
2-Now make sure you have checked the options marked with the green arrow... +CR +LF
3-Copy and paste this code: $PMTK251,38400*27 to the box indicated with the red arrow.
4-Then click the "Send ASCII" button indicated with the blue arrow..
5-Then the NMEA should disappear, and starting showing strange values. Go back to the "Port tab" (yellow arrow),
close the port, and choose the Baud "38400", and open the port again. You should the NMEA data again... =)
6- Then go back to the "Send" tab, and copy&paste this code: $PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28 then click Send, this should turn Off all sentences except GGA and RMC
7-Copy&paste now this code: $PMTK220,200*2C This should increase the updates to 5hz... (WOW!!!)..
8- Now you are able to connect the GPS module to Arduino, (only connect the RX pin to the TX of the GPS)
9-Then upload the code above, and open the port monitor, you should see Lat, Lon, Course, Speed, Altitude, Fix Position... like this:
46024504 8050998 312 0 519 1 (and yes you now know the exact position of my Swiss Chalet =P)...

If you want other setup codes for this GPS, you can find them in this datasheet.

Code explanation

If you'd like to understand the NMEA parser code a bit better, here are some of the library functions that it calls (all from the standard C++ library):

  • First of all pointers, which are very easy. They just give you the memory address where a variable is allocated in the ram: info
  • Then the strncmp(), better know as String Comparator. We use it to compare the header of the NMEA string "$GPGGA": info
  • Then strtl(), which means String to Long Variable. It converts a string number into a long variable: info
  • Then the strtok(). This is the string tokens, which looks for tokens in a string, for example commas ",", the ones used to separate values in the NMEA sentence: info
  • The atoi() will convert strings to integers: info
  • If you want to know all the available functions, see the library called "strings.h", "stdlib.h": info and info
(All these libraries are already installed in the Arduino IDE.)

Views: 41900

Tags: ardupilot

Comment by Spencer Riggs on December 14, 2008 at 9:31am
How did you connect the module to your computer to configure it? Also, does it store configuration in ROM or does it have a battery backup?

3D Robotics
Comment by Chris Anderson on December 14, 2008 at 10:45am
Solder on leads and plug them into a breadboard with a 3.3v power supply, then connect the FTDI cable to a strip of breakaway pins and the RX an TX pins to the matching FTDI pins.

Or just build our board.

As you can see from the product listing, it as a battery backup.
Comment by Spencer Riggs on December 14, 2008 at 12:56pm
Yes, I saw the battery backup, but I was a bit unclear on how it worked.

I think I am going to try to use Sparkfun's RS232 shifter, or breadboard it. RS232 would be a bit more convenient for me than FTDI, but I have enough budget to try both.

Thanks Chris!
Comment by Nathan on December 30, 2008 at 12:58pm
I know in theory this GPS unit is better than the EM-406 (according to the data sheet) but in practice how much better is it? I am working on a GPS project and the EM-406 does not seem to be good enough and I am basically wondering if getting this new one will drastically improve my accuracy. Also thank you for the article it is very useful.

3D Robotics
Comment by Chris Anderson on December 30, 2008 at 1:03pm
By "accuracy" what do you mean? Sat acquisition speed/number? Updating speed? Altitude resolution? Lat/lon resolution?
Comment by Nathan on December 30, 2008 at 1:26pm
Lat/Long resolution. I am making GPS navigation for an RC car and I want it to get very close to where I want it to be (one idea is running the bases on a baseball diamond). Also, if possible, a comparison between "true course" between the two because I will be using that to drive the car instead of a digital compass.

3D Robotics
Comment by Chris Anderson on December 30, 2008 at 1:32pm
I haven't compared them head-to-head, but the 5Hz updating would be a big advantage in determining true course.
Comment by Nathan on December 30, 2008 at 1:47pm
So in your opinion do you think this GPS unit will be worth the money and will provides at least some increased Lat/Long resolution to make a good enough difference? and thank you Chris for your timely responses

3D Robotics
Comment by Chris Anderson on December 30, 2008 at 2:00pm
I'm afraid I don't know whether it would offer increased lat/lon resolution. I was only referring to course (directional) data.
Comment by Ando Commando on January 8, 2009 at 4:25pm
GPS lat/long resolution is only accurate down to around 3 to 5 meters generally speaking. It is possible for the GPS system to be more accurate, using DGPS, WAAS or LAAS, but you still pretty much can't guarantee any type of resolution lower than the 3 - 5 meters. Any receiver that was produced within the last 5 or so years should be as accurate as you can get for right now.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Groups

  • IRIS

    IRIS

    254 members

  • X8

    X8

    207 members

Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Drone Delivery Challenge, is here

© 2014   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service