- Published: Sunday, 27 September 2009
- Written by Graham Mitchell
- Hits: 11800
The LS20031 GPS Module supports up to 32 Channels and outputs at 5Hz. That's some serious specs and a will serve the needs of almost any GPS application!
Also, the LS20031 GPS receiver includes an embedded antenna and GPS receiver circuits. It is a low-cost unit which outputs an astounding amount of position information 5 times a second. The receiver is based on the proven technology found in LOCOSYS 32 channel GPS SMD type receivers that use MediaTek chip solution.
The GPS smart antenna will track up to 32 satellites at a time while providing fast time-to-first-fix, one-second navigation update and low power consumption. It can provide you with superior sensitivity and performance even in urban canyon and dense foliage environments. The capabilities meet the sensitivity requirements of car navigation as a well as other location-based applications.
A long story short - its a great bit of kit for less than US$60 from most distributors. After building my development board and powering up the circuit, the LS20031 had picked up 5 satellites in less than 40 seconds - not bad given I was still in the house!!
Note: There are 5 bare pads you can solder to - the unit does not contain a connector. Here's what the device looks like in real life;
- MediaTek MT3318 solution
- 5Hz output
- 57600bps TTL serial interface
- 3.3V @ 41mA
- 32 Channel GPS
- Fast TTFF at low signal level
- Up to 5Hz update rate
- Capable of SBAS (WAAS, EGNOS, MSAS)
- Built-in micro battery to preserve system data for rapid satellite acquisition
- LED indicator for fix or no fix
Development and Prototyping
With one of these widgets in my possession, the first item on the agenda was to make a standalone development board. The module is so forgiving as it has 5 bare pads to solder the connections to - there are no other external components required. A side note though; the unit must operate at 3.3V, so use any PIC's with "LF" in their name. (for example, use 18LF2620, not 18F2620) as they can operate at lower voltages. The LD1117V33 (as shown below) is a 3.3V regulator.
The development board makes use of the PICKit 2 to both program and monitor the data. As there are different data transfer paths to consider (such as UART between PIC to GPS, PIC to PICKit2, PICKit2 to GPS), some DIP switches were used to allow control over the data paths. Here's a screenshot of the PCB layout (click on the layout to download the bottom copper layout to print and make your own);
Be sure that when wiring the LS20031 to the development board that Pin 1 of the LS20031 connects to Pin 1 on the dev board. Pinout of the LS20031;
Schematic (click to enlarge)
The PCB was designed with Proton Ares and developed via a light transfer technique. Download the PCB Layout , or click on the board layout above (note, the PCB layout links to a PDF file that you can print and use to develop your very own board). All of the components and associated values can be found between the above two images. You don't have to include the female port headers, I tend to incorporate them for interfacing with other dev boards.
The PCB board costs about $4 and the components are less than $10. It took me about 1 hour to produce the PCB and another 10 minutes to solder on the components. The result;
In the above image; the circuit is operating and the PK2 is busy receiving UART data from the PIC (which is receiving NMEA sentences from the GPS module). Note that you should carefully monitor the circuit after building - the last thing you want is a blown voltage regulator because of a missed short circuit due to poor soldering etc.
Also, the bottom copper side of the PCB has labelling for Vin and respective polarity. There is a diode in place to protect against reverse polarity. If all goes well, than the LED should light up with power applied (the 3 pin header switch) and the voltage regulator should only get warm (not HOT).
To program the PIC - simply connect the PICKit 2 to the top 6 pin header, and program as per normal. There is no need to remove power as In Circuit Programming (ICP) protection is in place. Just set your PK2 to run at target Vdd and off you go.
With the development board made, it was time to power up the circuit. As a fail safe, I removed the GPS module and ensured that the voltage regulator was functional before hand (3.3V), and also checked the current draw to ensure no short circuits on the tracks. With everything checking out, connecting the GPS module was simple enough as shown above.
The DIP switches allow data paths to be selected, and prevent short circuits between multiple TX outputs. Starting from the left on the board layout they are as follows;
- PIC TX - PK2 RX
- PIC RX - PK2 TX
- PK2 RX - GPS TX
- PK2 TX - GPS RX
- GPS TX - PIC RX
- GPS RX - PIC TX
Above, a cropped image of the board layout, color coded for reference.
So there's a few options heh, its really quite simple though. Given the first thing I want to do is inspect the raw data of the LS20031, I want direct coms from the GPS to the PICKit2. To do this, simply switch to "On" 3 and 4 of the above list.
* Note: To prevent short circuits between multiple TX outputs, always turn switches "Off" before making changes *
I was a little annoyed at this point! Long story short; the LS2003x GPS modules can be factory programmed to whatever baud and NMEA sentences the distributor desires, mine was configured to 57600 baud and 5 different NMEA sentences (a little bit of overkill, and does not leave much overhead for the PIC). This is quickly apparent when the PICKit2 is connected to the PK2-GPS connector and the UART Tool is showing gibberish at all speeds including 38400 (the PK2 max). Given the information was starting to look consistent at 38400 baud, it was a matter of a guess to assume that the GPS was configured to the next common increment (57600 baud).
Worry not, as the GPS module is programmable and customisable by end users as well. If your in the same boat, then use the following code on your PIC with DIP switches 5 & 6 on;
It's a standard across all GPS modules, NMEA. Wiki does a decent job at breaking it down, this article is more focused toward just using it. You may have noticed on the previous page that the GPS module had been configured to operate at 38400 baud and only to use GGA & RMC NMEA sentences. These sentences are just that, sentences. They are structured to comply with a standard protocol to ensure the fields within the sentences are always the same. Here's what the GGA and RMC sentences contain;
GGA - Global Positioning System Fixed Data
The following table contains the values for this example:
|Message ID||$GPGGA||GGA protocol header|
|N/S indicator||N||N=north or S=south|
|EIW Indicator||E||E=east or W=west|
|Position Fix Indicator||1|
|Satellites Used||8||Range 0 to 12|
|HDOP||1.1||Horizontal Dilution of Precision|
|Age of Diff. Corr.||second||Null fields when DGPS is not used|
|Diff. Ref. Station ID||0|
|CR + LF||End of message termination|
RMC - Recommended Minimum Specific GJ SS Data
Following table contains the values for this example:
|Message ID||$GPRMC||RMC protocol header|
|Status||A||A=data valid or V=data not valid|
|N/S Indicator||N||N=north or S=south|
|E/W Indicator||E||E=east or W=west|
|Speed over ground||2.69||knots||True|
|Course over ground||79.65||degrees|
|Variation sense||E=east or W=west (Not shown)|
|Mode||A||A=autonomous, D=DGPS, E=DR|
|CR + LF||End of message termination|
With the above information, a programmer can get ample positional information. Now to extract the fields so that we can use the values in a more meaningful way.
Download the Swordfish user library NMEA.bas here, and save it into your "Swordfish\UserLibrary" folder. The GPS module has already been configured previously to operate at 38400 baud, with RMC and GGA NMEA sentences at 5Hz. This means that 5 times a second, two sentences will be transmitted. The following program will capture and parse these NMEA sentences with a structured approach.
Sample programs make it easy to interpret the sequence to interface/use libraries. With the minor aspects aside, here's whats happening;
- "If NMEA.GetItem(NMEAItem) And NMEAItem.Valid Then" will return true if a valid NMEA sentence has been received in the buffer.
- If nothing has been received, then it will return false.
- If the checksum fails then it will return false.
- "NMEA.GetField(NMEAItem,0,Field)" will grab the first field from the sentence - Message ID.
- "If Field = "$GPRMC" Then" will ensure that only the RMC message is parsed.
- "NMEA.GetField(NMEAItem, 2, Field)" will put field #2 into the Field string (Status Field).
- Each relevant field is then parsed and returned to be displayed via UART.
Using the LS20031 GPS module was simply a breeze, not to mention it has good quality reception and reliable performance. I've had a few GPS modules move over my workbench, none worth writing about compared to this. Here are some screen shots of the PICKit 2 UART Tool screen and the development board in operation.
A screen shot of the PICKit 2 UART Tool receiving formatted information from GPS NMEA sentences;
And the development board in operation;