In this article, I'll show you one way to get the time and date from a GPS module, using a PICAXE 20m2.

Requirements

 

Introduction

There are over two dozen satellites for navigation in space. They are constantly providing time, dates, and location, which is all freely available to you as long as you have a GPS receiver. In this article, I'll make a clock that shows the time and date received from those satellites. I will not go into the workings of a satellite, but know that they're up there like nameless gods, sending information.

The clock I'll make will show the time and date on an LCD.

 

Hardware

The module I'll be using is the EM-411. It's a 6 pin module, where the 6th pin is used for pin header orientation.

The connections are GND, Vin, Tx, Rx, GND, and NC. In my clock, I'm not going to use the Rx pin. I'm not sending any commands to my GPS module. Tx is connected to the PICAXE 20m2 pin 4. That is C.6 and it is input only.

Here's the schematic diagram:

 

Parts list

This screenshot includes the EagleCAD devices, packages, and libraries.

 

Software

The software for this device is easily understood. However, I feel the need to explain a few things.

First the GPS-module is sending lots of information on the Tx pin. All this is received by the microcontroller. Using the command:

serin GPS_RX, T4800_8, ("$GPGGA"), @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptr

give us what we need.

To break this line down:

serin - This command is used to receive serial data into an input pin of the PICAXE 20m2.

GPS_RX - In the software this is the microcontrollers C.6/pin 4

T4800_8 - This is the baud mode. The T indicates that this is true output (idle high). The 8 tells us the microcontroller needs to run at 8MHz

("$GPGGA") - This is a qualifier, which means that it reads everything that comes after this, and place it in variables.

@bptrinc - This is a bit pointer variable that increases with one after a value is placed.

An explanation of bptr, bptrinc, @bptr and @bptrinc. Think of a set of drawers. Bptr hold the address of the drawer and @bptr hold the content of the drawer. @bptrinc use the content and goes to the next address.

This is what a $GPGGA sentence look like:

If you look closely at the example NMEA sentence, you'll see $GPGGA,161229.487...... The time is 16:12:29.487. So to get those numbers we need to fill 7 @bptrs with data. The first is the comma between the A (in $GPGGA) and 1629... We're using @bptrinc, because then it moves to the next address after the value is set.

One important note is that the bptr memory starts from address 53. The 52 addresses before this are all the b1, b2, b3, b4 and so on.

To get the date, I'm using the command:

serin GPS_RX, T4800_8, ("$GPRMC"),@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc,_
@bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptrinc, @bptr

The underscore at the end of the lines, indicates that the command continue on the next line.

This is what a GPRMC sentence look like:

If you count characters, starting from 53 you'll see that the first number in the date, "1" is character bptr address 104. That is why I need all the @bptrincs. We could get away with only this command, since it holds both time and date. Unfortunately, my GPS module sends this sentence each 4th second, so the seconds look like they are skipping and jumping ahead. The $GPGGA sentence is sent every second. That's why I'm using both.

 

Downloads

Here you'll find the EagleCAD library, the source code, and the GPS modules datasheet.

 

  EagleCAD Library     Source Code Sketch     GPS Module Datasheet  


Conclusion

This artice has shown you one way to use some satellite information. I made a clock, based upon the PICAXE 20m2 microcontroller, an LCD and a GPS module. Note that there are no error correction, so if the GPS module don't have a valid signal from the satellites, the display might show garbage.

 

Pictures and Video

 


Comments

0 Comments