arduino-tech

How the Program Works

The GPS data logger program code is very simple. Here is a basic explanation of how the program works. There are actually two versions of the program. Version 1 (called the Debug version) is a simplified version of the program that displays debug information to the serial console. Due to the memory size limitations of the Uno it isn't possible to output to the display and do the distance calculations in the production version.

Version 2 or the production version (the one that I use to capture the data later shown on a Google map) has all the functionality of the Debug version but doesn't output any data to the serial console. That's OK because you wouldn't normally have the PC connected while driving around with the logger. The only difference is that the production version has the distance calculation part of the code. This function is called everytime we capture the GPS position and it determines if the GPS has moved more that 3/4 of a mile from the last reported position. If so, another report is made. This helps capture position information when on a long, straight roads such as a highway or interstate.

All of this data is captured to a CSV file called GPS.LOG on the SD card. View an example of the CSV data file here.

Which one should I use?

If you are interested in learning about how the program works then I would use version 1 - The Debug version. If you want something to take on the road with you and make as smooth as a map as possible, I'd recommend version 2.

Flowchart

The flowchart below shows the basic program flow. This applies to both versions as they are virtually identical. Obviously, version 1 does not have the check for distance calculation but everything else is the same.

LEDs

Something else that I found useful is attaching two additional LEDs to the data logger. One of them is connected directly to the Adafruit GPS and the other is connected to pin 9 on the Uno. The following excerpt from Adafruit's documentation explains the purpose of the FIX LED connection.

Adafruit GPS - Connection to external LED FIX is an output pin - it is the same pin as the one that drives the red LED. When there is no fix, the FIX pin is going to pulse up and down once every second. When there is a fix, the pin is low (0V) for most of the time, once every 15 seconds it will pulse high for 200 milliseconds.

Pin 9 on the Uno is used by the program to let the user know that data is being written to the SD card. For example, when the GPS.LOG file is being created the LED will flash 3 times. When a report is being written the LED will flash only once. This helps the user verify that the logger is functioning properly and writing data to the log file.