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

  • Hi Mayur. I had the issue about defaults setting in one time, yesterday evening. and its the first time since I have it and play with it for many months! In fact, it seems to me that I may have resetted ArduPilot (through the shield reset cable, before all setup message send by ArduPilot ver. 2.2.3 were received by the GPS. It the only explanation I can think of right now. In fact, I don't like the GPS being reprogrammed every time ArduPilot is powered since the setting stay in the GPS memory which has battery backup power. I think I will most likely disable the Locosys programming sentences written by ArduPilot. In any case, I can re-enable them if reprogramming the GPS is necessary one day. But as I said, in many months I had no other issues.
  • Hi all,
    I've only just got this module and wired it up. My module's LED seems to stay 'ON' all the time. However, just by touching the unit or with a light/gentle tap, the module LED goes off and shortly after that it will capture. All seems to be well until power off, when once again, the LED will just stay on and I'd have to touch/tap the GPS module. I've double triple checked my soldering of wires etc. I'm not new to soldering.
    Also, randomly, my settings seem to go back to default, ie, the GPS module defaults back to 5hz 57600 with all messages on.
    Anyone else have this issue?

    Looking forward to any feedback

    Thanks
  • Answering my own question...

    I emailed the manufacturer and got back from them...

    "This is Eric Chin from LOCOSYS Technology Inc.

    Thank you very much for this email and using our product.

    All commercial GPS module has altitude limitation, 60000 feet. If the module over the altitude specification, it will not get position immediately. "
  • Anyone know if this GPS module has the 60k feet altitude lockout?

    Thanks!
  • Hi all,

    Just an addition to what is being said here - We finally got the GPS coordinates from the LS 20031 after setting the baud rate as 57600 in Jordi's code as well as in the serial monitor window.

    We directly connected the GPS module to arduino without configuring it using the FTDI cable. After playing around for a while, we found that the default baud rate of the module to be 57600bps, instead of the 9600 specified in the datasheet. Though we are not sure, the default update frequency seemed to be around 5Hz instead of the 1Hz specified in the datasheet.

    We are also attaching a pic here of the GPS-Arduino connections. Hope people find this useful.


    - aravind, yogesh
  • In the C code it notes that the RMC head contains the following: UTC, UTC status ,Lat, N/S indicator, LON, Lon, E/W indicator, speed, course, date, mode, checksum>>> But in the datasheet for the 5Hz Locosys (Mediatek chipset) GPS it is actually:$GPRMC,UTC Time,Status,Latitude,N/S Indicator,Longitude,E/W Indicator,SpeedOverGround,CourseOverGround,Date,MagneticVariation,VariationSense,Mode,Checksum

    the code is missing magnetic variation and variation sense.... Is there a reason for this or am I reading it incorrectly?

    Geovanie
  • does anyone know if a Parallax propellor plug is basically the same as a FTDI cable? If yes, how would I hook up my Locosys LS20033 to this cable?
    The pin config for this GPS is:
    pin1 - pwr (3.3V)
    pin2 - gnd
    pin3 - tx
    pin4 - rx

    propeller plug:
    vss
    res
    tx
    rx.

    I am a little confused of what VSS and RES mean. The prop plug should be able to work with 5v and 3.3v. Do I still need to power my gps from an external source?

    I appreciate your suggestions!
  • Anybody has experience with using and/or interfacing the 14 Channel 10Hz GPS Receiver - Venus634FLPx (at Sparkfun) with this or any other project? Is the difficulty of interfacing compare with the LS20031? Thanks for any input.
  • @Dan: yes if it has an uart, but you need to check the voltages also as LS20031 etc are 3.3V.
    It will output the position in standard gps sentences over the serial out so you can make/use a parser for this like done in the ArduPilot project.
    For more info I'd suggest looking at the mainpage of the ArduPilot which is a uC controlling an airplane based on GPS data. You can get there by clicking on ArduPilot in the top bar of the site.
  • hi..I'm new in this. Can I connect 5Hz Locosys GPS to a microcontroller? I'm trying to detect the position of my small airplane and tell it where to go from the position received by the GPS. Like program it in a microcontroller. I hope this is not confusing.
This reply was deleted.