This article is publishing with the help of my friend Mick Gulovsen who edited it and helped me translating it from it’s original Bulgarian-English to Queen’s English🙂
Global Positioning System (GPS) is a satellite based global navigation system that provides location and time information in all weather, anywhere on (or near) Earth, where there is an unobstructed line of sight to four or more GPS satellites.
You can read more about how GPS was created and how it works in Wikipedia.
Also some theory is available in this web site: http://lea.hamradio.si/~s53mv/navsats/theory.html.
It’s very easy to use GPS with DuinoMite using Olimex’s UEXT GPS module ‘MOD-GPS’ which interfaces using DuinoMite’s UEXT connector.
MOD-GPS is based on the SiRF StarIII chipset which provides high precision, low power and high sensitivity, so MOD-GPS is even able to lock onto satellites inside buildings.
MOD-GPS output is via serial 19200 bps 8bits,1 stop bit, No Parity.
It is easy to access MOD-GPS data with DuinoMite using MMBasic, for example, you can view MODGPS output using this small program:
10 OPEN “COM3:19200” AS #5
20 PRINT INPUT$(1,#5);
30 GOTO 20
Running this code will generate something like this:
This will continue forever, each message starts with $Gpxxx then some data separated with “,” and ends with *xx which is the checksum in Hex.
Some messages contain several ,,, i.e. empty parameters.
When the GPS receiver is started for the very first time or after it was moved any distance without being powered the GPS receiver will have lost connection to some satellites, it takes time to lock onto them again (called `cold start time’ and is usually about 1 minute).
If you are inside a building or the signal is weak due to other obstacles the GPS receiver may not lock to some satellites at all, MOD-GPS can lock onto 12 satellites, but even 4 are enough to calculate it’s correct location.
There are 4 types of messages which MOD-GPS sends:
These messages are in NMEA0183 format and the prefix $GP means that the message is ordinated from the GPS receiver.
http://www.gpsinformation.org/dale/nmea.htm has an explanation of the different NMEA messages.
RMC – Recommended Minimum Essential GPS Data.
let’s decode our message:
$GPRMC – message ID
192840.000 – 19:28:40 UTC time stamp
A – Status A=active or V=Void
4208.3343,N – Plovdiv Latitude 42 deg 08.3343′ N
02445.0342,E – Longitude 24 deg 45.0342′ E
0.00 – Speed over the ground in knots
37.14 – Track angle in degrees True
211111 – Date – 11th of November 2011
(empty field) – Magnetic Variation
(empty field) – Magnetic Variation direction
*51 – The checksum data, always begins with *
With this message we get information about time, date, our location and our speed, the speed is calculated very precisely and you can even calibrate your car or motorcycle speedometer with the value read by the GPS, as the car’s mechanical speedometers usually have about +-5% error.
This immediately leads me to an interesting project: Car performance logger. Having the change of speed of your car and the time, you can calculate the acceleration, and if you know the weight of your car you can also calculate the moment power as P=A*m i.e. you can monitor and log exactly how much horsepower or kw are used when your car accelerates.
GGA – Essential 3D Location Fix Data.
Let’s decode our message:
$GPGGA – Global Positioning System Fix Data
192839.000 – Fix taken at 19:28:39 UTC
4208.3343,N – Latitude 42 deg 08.3343′ N
02445.0342,E – Longitude 24 deg 45.0342′ E
1 – Fix quality: 0 = invalid
1 = GPS fix (SPS)
2 = DGPS fix
3 = PPS fix
4 = Real Time Kinematic
5 = Float RTK
6 = estimated (dead reckoning) (2.3 feature)
7 = Manual input mode
8 = Simulation mode
07 – Number of satellites being tracked
1.5 – Horizontal dilution of position
171.8,M – Altitude, Meters, above mean sea level
37.1,M -Height of geoid (mean sea level) above WGS84 ellipsoid
(empty field) – time in seconds since last DGPS update
(empty field) – DGPS station ID number
*56 – the checksum data, always begins with *
GSA – GPS DOP and active satellites.
This sentence provides details on the nature of the fix. It includes the number of the satellites being used in the current fix and the DOP.
DOP (dilution of precision) is an indication of the effect of satellite geometry on the accuracy of the fix.
It is a unit-less number where smaller is better. For 3D fixes using 4 satellites a 1.0 would be considered to be a perfect number, however for multi-satellite fixes it is possible to see numbers below 1.0. There are differences in the way the PRN’s (Pseudorandom Noise) are presented which can affect the ability of some programs to display this data. For example, in the example shown below there are 5 satellites in the solution and the null fields are scattered indicating that the almanac would show satellites in the null positions that are not being used as part of this solution. Other receivers might output all of the satellites used at the beginning of the sentence with the null fields stacked up at the end.
This difference accounts for some satellite display programs sometimes, not being able to display the satellites being tracked. Some units may show all satellites that have ephemeris data without regard to their use as part of the solution but this is non-standard.
let’s decode our message :
$GPGSA – Satellite status message
A – Auto selection of 2D or 3D fix (M = manual)
3 – 3D fix – values include: 1 = no fix
2 = 2D fix
3 = 3D fix
07,23,20,10,13,08,04 – PRNs of satellites used for fix (space for 12)
3.1 – PDOP (dilution of precision)
1.5 – Horizontal dilution of precision (HDOP)
2.7 – Vertical dilution of precision (VDOP)
*3A – the checksum data, always begins with *
GSV – Satellites in View
Shows data about the satellites that the unit might be able to find based on its viewing mask and almanac data. It also shows current ability to track this data. Note that one GSV sentence only can provide data for up to 4 satellites and thus there may need to be 3 sentences for the full information.
It is reasonable for the GSV sentence to contain more satellites than GGA might indicate since GSV may include satellites that are not used as part of the solution. It is not a requirement that the GSV sentences appear in sequence.
To avoid overloading the data bandwidth some receivers may place the various sentences in different samples since each sentence identifies which one it is.
The field called SNR (Signal to Noise Ratio) in the NMEA standard is often referred to as signal strength. SNR is an indirect but more useful value than raw signal strength.
It can range from 0 to 99 and has units of dB according to the NMEA standard, but the various manufacturers send different ranges of numbers with different starting numbers so the values themselves cannot necessarily be used to evaluate different units.
The range of working values in a given GPS will usually show a difference of about 25 to 35 between the lowest and highest values, however 0 is a special case and may be shown on satellites that are in view but not being tracked.
$GPGSV – Satellites in view
3 – Number of sentences for full data
1 – sentence 1 of 3
11 – Number of satellites in view
13 – Satellite PRN number
72 – Elevation, degrees
323 – Azimuth, degrees
37 – SNR – higher is better
(for up to 4 satellites per sentence)
*78 – the checksum data, always begins with *
The three messages contain the info for all 12 satellites.
The following code reads RMC message and extract the time, date, latitude, longitude
20 PRINT “GPS DEMO CODE”
30 OPEN “COM3:19200” AS #5 ‘open UEXT UART at COM3
40 IF NOT EOF(#5) THEN 60 ‘if something is received
50 GOTO 40
60 C$=INPUT$(1,#5) ‘get character
70 IF C$ = CHR$(10) THEN 100 ‘until LF is received
80 MSG$=MSG$+C$ ‘store in MSG$
90 GOTO 40
100 ‘LOCATE 0,100: ? MSG$ ‘used for debug
110 IF LEFT$(MSG$,6) = “$GPRMC” THEN 140 ‘wait for RMC message
130 GOTO 40
140 LOCATE 0,100: PRINT MSG$ ‘RMC message received
150 LOCATE 0,20: PRINT “UTC TIME: “;
160 A$ = MID$(MSG$,INSTR(MSG$,”,”)+1)
170 PRINT MID$(A$,1,2);”:”;MID$(A$,3,2);”.”;MID$(A$,5,2)
180 GOSUB 500
190 GOSUB 500
200 LATITUDE$ = LEFT$(A$,INSTR(A$,”,”)-1)
210 LOCATE 0,50: PRINT “LATITUDE :”;LATITUDE$;” “;
220 GOSUB 500
230 NS$ = LEFT$(A$,1)
240 PRINT NS$
250 GOSUB 500
260 LONGITUDE$ = LEFT$(A$,INSTR(A$,”,”)-1)
270 LOCATE 0,60: PRINT “LONGITUDE :”;LONGITUDE$;” “;
280 GOSUB 500
290 EW$ = LEFT$(A$,1)
300 PRINT EW$
310 GOSUB 500
320 SP$ = LEFT$(A$,INSTR(A$,”,”)-1)
330 LOCATE 0,70: PRINT “SPEED KNTS:”;VAL(SP$)
340 GOSUB 500
330 GOSUB 500
340 LOCATE 0,30: PRINT “UTC DATE: “;
350 PRINT MID$(A$,1,2);”-“;MID$(A$,3,2);”-20″;MID$(A$,5,2)
360 GOTO 120
500 A$ = MID$(A$,INSTR(A$,”,”)+1) ‘skip to next ‘,’