3D Robotics

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.)
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • How can i access the source code for GPS receiver . When i click on the code it is giving me access denied
  • Cool thanks!
    I'll roll back till it works lol
    Dont have $150 for a new gps, I have too many already ;)
  • 3D Robotics
    Max, I'm not sure what the problem is with that. It could be that we introduced a bug in the NMEA code, since none of use that anymore and haven't tested it for many versions (we also don't use the EM406 anymore, so that could have the same problem).

    I'll test both of them with the current code and see if I can replicate your error.
  • Hi,
    Im having problems with my 406 GPS (I think) - seems to test ok but ardu wont get a lock, so ive got a spare locosys sitting here I want to use.

    I followed the instructions in this thread, set the Loco to 5HZ, 38400 baud & changed the output stream to suit ardu- all good.
    Tested the gps via the serial port with MiniGPS / realterm. It lock onto sat's very reliably. 36seconds from cold start was the best - COOL!

    Yeah ok so I set the ardu code to NEMA and also my shield to the old red version but I cant seem to get ardu to get a solid blue light :(

    Is there something special I need to do as this thread is very old and I suspect things have changed, im using the 2.5.3 code.
    Thanks! :)
  • 3D Robotics
    @Norbert: Plastic should be fine. Just avoid metal and carbon fiber.
  • Does this unit need to "see" the sky in order to acquire a position? or can it be inside a plastic enclosure and still locate its position?
  • Is it possible to connect iPAQ GPS with ardupilot circuit or any type of GPS. Cuz I would like to use the ardupilot circuit for sailing boat application to control rudder i.e. to set the rudder in autopilot mode by using ardupilot.
    I notice the ardupilot can only function by using GPS module like EM406 or 5HZ type..Please advise me if the ardupilot is capable to control it by using other type of GPS i.e. not a programmable GPS but with display unit like iPAQ or Raymarine GPS's...All the best..
  • @Dr Mike Black

    I would love the link to the code...
    Thanks
  • @Mike: you're right, Ardu code has only implemented rates up to 38400 bauds, although the LS20031 is very well capable of 57600 (I tried it out). In my opinion, the code could be adapted fairly easily adding the necessary MTK string for 57600. But I didn't do it since I want to use it at 38400 in order to be compatible with my OSD.
  • Chris , they have prob changed versions thats all...

    If iyou need a copy, just shout....i will post a link to it.

    by the way, if you get 5hz, let me know, not had anything over 4hz.....either way, compared to the trusty old EM406.....its pretty cool

    regards,

    Doc
    http://it.by/
This reply was deleted.