Electronics project notes/Some GPS notes
There are many more complete documents out there.
This is meant to get a hobbyist started.
Communication
GPS units tend to speak NMEA 0183.
They may additionally speak their own protocol, which you can often switch to via a NMEA-style but often brand-specific command.
NMEA
In the context of GPS, NMEA usually refers to to NMEA 0183, an ASCII-based, line-at-a-time protocol.
A single-talker, multiple-listener setup.
It has a basic per-line checksum to detect message corruption.
NMEA 0183 is technically a proprietary protocol that costs a few hundred dollars, but the basic information you'll need to start using it is fairly public information. There have been a number of revisions, including:
- NMEA 0183 v2.00
- NMEA 0183 v2.10
- NMEA 0183 v2.30
- NMEA 0183 v2.40
- NMEA 0183 v3.00
- NMEA 0183 v3.01
- NMEA 0183 v4.00
There is now a NMEA 2000 which is meant for similar purposes, but is fairly different in setup: a 250kbit/s shared bus (multiple-talker, multiple-listener) with a more compact protocol.
It seems to be used in boats and not much elsewhere. (verify)
Hardware
Typically uses a serial port at 4800bps (often 8bits, no parity, 1 stop bit).
All NMEA 0183 compliant equipment should support this, and probably default to this.
Newer versions of standards allow devices to use 38400bps, which seems mostly used for AIS, and (other) setups that may need to combine messages from multiple NMEA devices within somewhat more reasonable time.
It is recommended to make longer-distance wiring wiring conform to RS/EIA-422 (differential signalling) as this is less susceptible to noise than RS/EIA-232 (though RS232 is easier to connect to computer serial ports and perfectly fine for ~1m cables).
Sentence format
Example:
$GPGSV,3,1,11,15,67,284,14,26,66,130,12,28,50,066,,27,49,265,21*75
The parts:
- start with a $
- five characters:
- the first two of which identify the talker type - which includes
- their other three are the sentence type. For example, within the GP prefix there exist about two dozen sentence types, with most basics covered by a few
- a bunch of comma-separated fields
- the amount and meaning depends on sentence type (GSV is data about the satellites in view, some more notes below)
- later standard versions sometimes add fields to some sentences -- at the end
- is terminated by a * and a simple two-character checksum
- ...to be able to reject messages corrupted by noise
- the checksum value is a XOR of all the bytes between the $ and *, and this byte is shown as hex
Notes:
- Some devices may be/have more than one talker type, for example a GPS unit with a magnetic compass
- The unit chooses which sentence types to send (GGA, GSA, GSV, and RMC seem the most common). You may be able to configure a different set.
- Most GPS devices have some of their own sentence types in addition to the standard ones, apparently including
- GLL (apparently LORAN-style)
- VTG (apparently also LORAN)
- ZDA (SiRF-specific?(verify)).
- There is no imposed order, though any given unit may always use the same order.
- 4800 baud means ~480 characters per second, which means only a handful of sentences per second.
- This is fine for localization, but is something to keep in mind (and makes one wonder about all the redundancy between even the default sentences).
- some devices can speak much faster serial, but for backwards compatibility have to be switched to it.
- Messages often come in once-per-second bursts
- faster reporting exists, but isn't really necessary for most things
See also:
Example GPS sentences
The following are a few lines from a GPS unit that was just powered on (doesn't have a fix yet, before all fields are filled) in Delft, the Netherlands.
$GPRMC,150050.000,A,5200.5569,N,00421.9672,E,4.62,20.20,280411,,*39
$GPGGA,150051.000,5200.5581,N,00421.9679,E,1,00,50.0,-31.6,M,47.1,M,,0000*7A
$GPGSA,A,2,,,,,,,,,,,,,50.0,50.0,50.0*06
$GPRMC,150051.000,A,5200.5581,N,00421.9679,E,4.62,20.20,280411,,*35
$GPGGA,150052.000,,,,,0,00,50.0,,M,0.0,M,,0000*4E
$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
$GPRMC,150052.000,V,,,,,,,280411,,*22
$GPGGA,150053.000,,,,,0,00,50.0,,M,0.0,M,,0000*4F
$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
$GPRMC,150053.000,V,,,,,,,280411,,*23
$GPGGA,150054.000,5200.5465,N,00421.9579,E,1,03,6.5,-32.6,M,47.1,M,,0000*41
$GPGSA,A,2,15,26,27,,,,,,,,,,6.6,6.5,1.0*34
$GPRMC,150054.000,A,5200.5465,N,00421.9579,E,1.41,327.29,280411,,*01
$GPGGA,150055.000,5200.5363,N,00421.9525,E,1,03,6.5,-33.4,M,47.1,M,,0000*4B
$GPGSA,A,2,15,26,27,,,,,,,,,,6.6,6.5,1.0*34
$GPGSV,3,1,11,15,67,284,14,26,66,130,12,28,50,066,,27,49,265,21*75
$GPGSV,3,2,11,09,27,261,,18,23,312,,08,18,071,,17,14,118,17*73
$GPGSV,3,3,11,05,11,186,,22,01,333,,21,00,279,*4E
$GPRMC,150055.000,A,5200.5363,N,00421.9525,E,1.58,212.89,280411,,*0D
$GPGGA,150056.000,5200.5260,N,00421.9469,E,1,04,7.0,-28.9,M,47.1,M,,0000*47
Examples picked apart:
- (GP)GGA - "Fix information" [2] [3]
- All you need for the most basic location (and estimated precision)
- First example from above, $GPGGA,150051.000,5200.5581,N,00421.9679,E,1,00,50.0,-31.6,M,47.1,M,,0000*7A:
- 150051.000 - fix time in UTC (hhmmss, may or may not show fractional seconds (verify))
- 5200.5581 - latitude (ddmm.mmmm): 52° 0.5581 minutes
- N - ...north
- 00421.9679 - longitude (dddmm.mmmm): 4° 21.9679 minutes
- E - ...east
- 1 - fix type SPS (1=SPS, 2=DGPS, 3=PPS, 4=RTK, 5=Float RTK, 6=Estimated, 7=Manual, 8=Simulator)
- 00 - satellites in view (0..12)
- 50.0 - HDOP, approximating the accuracy of the fix (see DOP notes below). This is a very inaccurate fix (a later one in the example has a HDOP of 6.5, which is decent)
- -31.6 - altitude of antenna above mean sea level (negative means below)
- M - ...in meters
- 47.1 - difference between mean sea level and the WGS84 ellipsoid. (positive means msl above ellipsoid)
- M - ...in meters
- - age of DGPS data in seconds (time since last DGPS update), here empty as DGPS is not used
- 0000 - DGPS station ID. Can also be empty if not used.
- (GP)RMC - "Recommended Minimum (sentence C)" [4] [5]
- First example from above, $GPRMC,150050.000,A,5200.5569,N,00421.9672,E,4.62,20.20,280411,,*39
- 150050.000 - fix time
- A - active (could also be V for void, invalid) - you probably want to only use lines with A
- 5200.5569 - latitude: 52° 00.5569 minutes
- N - ...north
- 00421.9672 - longitude: 004° 21.9672 minutes
- E - ...east
- 4.62 - ground speed (in knots)
- 20.20 track angle (in degrees true)
- 280411 - Date; 28 April 2011 (2-digit year presumably good until 2080)
- - magnetic variation (amount)
- - E or W (verify)
- First example from above, $GPRMC,150050.000,A,5200.5569,N,00421.9672,E,4.62,20.20,280411,,*39
- (GP)GSA - mostly details precision [6] [7]
- DOP (Dilution Of Precision) information
- Example from above, $GPGSA,A,2,,,,,,,,,,,,,50.0,50.0,50.0*06
- A - 2D/3D mode selected Automatically (rather than Manually)
- 2 - 2D fix (would be 3 for 3D fix, 1 for no fix)
- - identifier of first satellite in view (in jargon, the PRN of first SV)
- - PRN of second satellite in view
- - PRN of third satellite in view
- - PRN of fourth satellite in view
- - PRN of fifth satellite in view
- - PRN of sixth satellite in view
- - PRN of seventh satellite in view
- - PRN of eighth satellite in view
- - PRN of ninth satellite in view
- - PRN of tenth satellite in view
- - PRN of eleventh satellite in view
- - PRN of twelfth satellite in view
- 50.0 - PDOP, Positional Dilution of Precision (DOP) - overall 3D accuracy
- 50.0 - HDOP, Horizontal DOP - that is, longitude and latitude
- 50.0 - VDOP, Vertical DOP - that is, height
- ...which is a boring example because this seems to be a preliminary report. The later figures in the example above (HDOP of 6.5) is a moderately good fix.
- (GP)GSV - "Detailed Satellites-in-View data" [8] [9]
- Details up to four satellites in a single message, so there you'll see a few of these in a row to detail all satellites in view. I've seen sentences where the last of these sentences has fewer fields, and examples where ther have 0,0,0,0 entries.
- Example from above, $GPGSV,3,1,11,15,67,284,14,26,66,130,12,28,50,066,,27,49,265,21*75
- 3 - amount of GSV messages this cycle (three)
- 1 - message number (out of the above number; this is one of three)
- 11 - number of satellites in view
- 15 - First detailed SV's PRN
- 67 - First detailed SV's elevation (in degrees)
- 284 - First detailed SV's azimuth (in degrees)
- 14 - First detailed SV's SNR
- 26 - Second detailed SV's PRN
- 66 - Second detailed SV's elevation (in degrees)
- 130 - Second detailed SV's azimuth (in degrees)
- 12 - Second detailed SV's SNR
- 28 - Third detailed SV's PRN
- 50 - Third detailed SV's elevation (in degrees)
- 066 - Third detailed SV's azimuth (in degrees)
- - Third detailed SV's SNR
- 27 - Fourth detailed SV's PRN
- 49 - Fourth detailed SV's elevation (in degrees)
- 265 - Fourth detailed SV's azimuth (in degrees)
- 21 - Third detailed SV's SNR
- (GP)GLL - lat, long and UTC time. Mostly redundant with GGA.
- (GP)VTG - heading (true and magnetic), ground speed (knots and km/h)
- (GP)ZDA - date and time. Specific to SiRF. Tells the time of the most recent 1PPS pulse.
Notes:
See also:
- http://www.gpsinformation.org/dale/nmea.htm
- http://aprs.gids.nl/nmea/
- http://en.wikipedia.org/wiki/NMEA_0183
On precision and DOP
DOP
DOP (Dilution of Precision) [10]
is an estimate of how accurate position determination - mostly determined by the given signals and our ability to do math to resolve them to a point.
DOP is a unitless figure of merit, yet still seems defined in a way where
- over 20 is bad
- 10-20 is poor
- 5-10 is moderate
- 2-5 is good
- 1-2 is very good
- 1 is ideal
- (the device in the examples above seems to report 50.0 for a bad-quality basic fix)
DOP can be split into:
- GDOP (Geometric DOP) is used both as a grouping term for the DOP variants, and as a single figure that summarizes PDOP and TDOP (verify)
- PDOP (Positional DOP) is 3D DOP, which could be separated into: (verify)
- HDOP (Horizontal DOP) - meaning that for longitude and latitude
- VDOP (Vertical DOP) - meaning that for altitude
- PDOP (Positional DOP) is 3D DOP, which could be separated into: (verify)
- TDOP (Time DOP)
In practice, you could say it refers to anything that reduces that accuracy.
In relatively ideal conditions, DOP has a roughly linear relation with accuracy in meters.
However, that's an assumption - in less than ideal conditions (reflections from buildings), there will be a difference between DOP and accuracy in meters that you cannot easily quantify.
On 2D/3D fixes
GPS units can start determining a fix using three satellites, but (approximately speaking)
but this is a 2D fix that has to assume an earth shape, specifically an altitude for this location to be fairly good.
Using the last altitude the receiver saw is better than nothing, but worse than a 3D fix.
With ≥4 satellites you can get a 3D fix, meaning you can determine the height.
Mathematically, more than four means the solution is over-determined.
But because all signals have unknown error, this gives diministing returns,
and will never be a point in space.
While receivers can choose to use more satellites's signals (there are usually a dozen in view) for a more accurate fix, the added precision is quickly diminishing returns, a lot of them don't use all of them in calculation because it won't help much.
(There are other, better ways of improve it, though various are external)
Things that augment basic GPS, like DGPS, AGPS, and WAAS, may also take a little time to kick in, depending on the hardware, setup, and situation.
See also:
Can you get more accurate? (Fix types, cleverness, external augmentation)
"Why does it sometimes show me in the wrong place?"
If you have an app that shows you where you went running, you'll notice it shows you off the road, and sometimes teleporting around a bit.
...probably because you're in a city. Reflected signals (because of buildings) make the solution make much less sense, which not only increases the DOP by a bunch of meters, but might also sometimes make the sort-of-average off by that much, which easily reports you on the next street over.
I have also seen it report a few points hundreds of meters away. I have no good answer why.
On startup time
For context:
- almanac data is orbit information
- considered usable for up to 180 days
- and apparently updated perhaps every six days(verify)
- it takes ~12.5 minutes for a complete almanac to receive.
- longer (possibly multiples) if obstructions means we miss some of that data
- we might get lucky enough to get started within maybe 2 minutes, if we happen to receive enough data for sattelites we are seeing(verify)
- ephemeris data
- (shorter-term corrections to the almanac)
- These corrections come from on-earth observations of the satellites, calculated, and sent to the satellites every so often to then send to us (verify)
From that:
Cold start
- if you haven't used the receiver for over half a year, you have no valid almanac or ephemeris data.
- also applies when you have moved a large distance since last power-on (or for other reasons that the predicted sattelistes are not overhead) (verify)
- starts from scratch, and the main wait is on the almanac
- Time To First Fix may be up to ~13min (almanac download time), but in practice may be anything between approximately 2 and 13 minutes(verify)
Warm start
- is used frequently enough, yet is not continuously on, then you probably always have valid almanac data, but probably start with outdated ephemeris data
- done when there is a valid almanac (we can predict and see satellites), you haven't moved much, and the time is known - but the ephemeris data is old
- Time To First Fix could be 20 in the best case, but if you need another pass, assume it may be 60 seconds.
Hot start
- valid almanac and recent ephemeris data for enough satellites
- typical if the powered continuously, or has been powered on for at least ~15 min in the last few hours
- Time To First Fix could be 10 or 20 seconds, perhaps down to 1 second if you get very lucky
Note also that A-GPS may further help hot starts happen, and can push it down from 10 seconds.
GPX (GPS Exchange Format)
See also:
- formats like KML
Glossary
Lower level:
- PPS
- when referring to a GPS module output pin (then a.k.a. 1PPS), this is a Pulse Per Second signal
- When not relating to a pin, it tends to mean Precise Positioning Service instead; see below.
- PRN - Effectively identifies a GPS satellite.
- More technically: The PRN identifies the pseudo-random number sequence that a specific satellite contains - that PRNG looks random but can be exactly reproduced)
- SV - "Satellite Vehicle". Seems to be used whenever people are too lazy to type 'satellite'
Startup, precision, and assistance terms
- TTFF: Time To First Fix.
- See #On_startup_time on what you can expect
- almanac - orbit information. Allows a GPS unit to predict what sattelites are overhead, shortening aquisition time.
- Takes ~15min to receive completely. There is usually enough useful information to go on within a few minutes(verify), but a full almanac helps faster startup for the next half year or so.
- ephemeris data - precise corrections to the almanac. Takes at least 30 seconds to retrieve this from the GPS signal, becomes outdated in a few hours.
AGPS
Assisted GPS (a.k.a. AGPS, A-GPS, aGPS) communicates ephemeris data via a communication network rather than from the satellites.
Consider that having ephemeris data is central to hot starts.
We need new data every few hours, but it takes half a minute listening to the satellites.
If you have a phone, though, when you are usually connected to the internet. Why not fetch ephemeris data (for your area) every now and then? It's probably charged as any network data, but it's a kilobyte per dozen-or-so satellites, so even if you're downloading for multiple constellatons (GPS, GLONASS, Galileo, etc.) it should be maybe 100KByte per day.
AGPS also predicts future ephemeris data ('extended ephemeris'), which you can see as better-than-not-doing-it
data that is good for days to maybe a week or two, assisting pretty-decent-accuracy hot-starts for longer
even when you have no network connectivity.
Fixes based on extended ephemeris data are a little less accurate, but is often on the order of magnitude of a meter or two of error per day of age (and note that it should soon be updated with live ephemeris data).
So the first goal of AGPS is TTFF, not accuracy,
but the extended ephemeris part gives you a mix of faster-and-still-pretty-good.
PPS and SPS
In the American GPS system (others may have different names(verify))
- PPS (Accuracy level): Precise Positioning Service - military
- ~10m horizontal accuracy (officially; practically often ~4m)
- compare with SPS and others
- SPS (Accuracy level): Standard Positioning Service - basic civilian GPS fix
- The level of accuracy is set by DoD policy, by introducing an error in the signal. Pre-2000, Selective Availability (SA) lowered SPS accuracy to on the order of ~100m, but in 2000 SA was effectively disabled, making it almost equivalent to PPS
Various augmentations
The ephemeris stuff is mostly about getting the satellite trajectories right. Which certainly helps overall accuracy, but is not the only problem.
Wild idea, what if we add some stations in very-well-defined spots (e.g. near major ports)
to calculate the difference between exactly where they know they are, and what GPS is telling them,
Or what if we start analysing satellite idiosyncracies, more precisely model atmospheric delays than classic GPS does?
Either way, anything that lets us conclude we see a structurally present offsets,
or lets us explain and reduce disagreement between satellite information,
can lead to better precision and accuracy.
Whether that correction was based on base stations, analysis of satellites or ionosphere or whatnot,
if we can send the data needed to correct send that to each other, using radio, internet, or satellite,
we then made GPS into something more accurate than GPS.
This can improve accuracy from a few meters to a meter, sometimes better.
The flavours vary in how they work, and how they communicate,
so there are at least a handful of essentially-incompatible flavours of this - though note that
a number of local ground-based variants were intentionally designed to be cross-compatible.
'DGPS' sometimes refers to this idea in general, but probably more often to some of the earlier implementations.
Classic DGPS is mostly developed for / used by marine navigation, coastguard, surveying, and such, and is transmitted on longwave radio, so correction has (decreasing) use up to a few hundred km (the US coast guard basically made it for their own use, back when SPS was still artificially crippled).
GNSS augmentation[11] - basically meaning "something DGPS-like".
Due to the differences, there are some terms indicating what they do and/or how they communicate.
Consider:
- The distinction between GBAS (where ground stations transmit the corrections) and SBAS (where satellites transmit corrections)
- Specific wider implementations: