GPS Clocks for Computer Time Synchronization
Using GPS Clocks for Computer Clock Synchronization
Almost all GPS receiver modules provide a serial output of some kind. The
protocol supported by most GPS receivers is called NMEA-0183. This is a
standard for communication between marine devices developed by the National
Marine Electronics Association.
The NMEA standard calls for 4800 baud and recommends an electrical
connection similar to RS-422, but most non-marine implementations use
RS-232.
Unfortunately, none of the standard NMEA-0183 messages contains a precise
time code. The best you can do without using any proprietary extensions is
to configure your receiver to send an 'RMC' message every second. An 'RMC'
includes the date and time down to the second.
If the message was transmitted on a second boundary, we can use the
time we received the last character of the message, less the time it took to
receive the message, to compute an 'offset' between a computer's clock and
the correct time. This offset can then be used to steer the computer's clock
to GPS time.
NTPD supports this without any difficulty with its NMEA reference clock
driver. You generally cannot get millisecond-level accuracy this way. If you
are satisfied with an accuracy of about 10 milliseconds, this is all you
need.
Problems occur primarily because serial ports were not designed to
preserve time accuracy. Also, serial port drivers will generally try to
clump characters together, waiting before handing them to the application
that requests them.
Some operating systems have features to reduce this problem, such as
Linux's 'low_latency' option. It may also help to shut off the serial port's
FIFO.
But you really want a GPS clock with an accurate PPS (pulse per second)
signal, like ours has. You can wire it to your
serial port to generate an interrupt when the pulse occurs, at the precise
second boundary. If the routine that services this interrupt saves a copy of
the system's internal clock (with microsecond accuracy), you can then use
this saved timestamp to adjust the system's clock.
FreeBSD supports a PPS input directly. Linux does too, but requires
patches for maximum accuracy.
[ Prev ]
[ Up ]
[ Next ]
Sources
We offer the GPSClock 200, a GPS receiver that is designed for time
reference use from the ground up. It weighs about .8 pound and has threads
on it to allow it be easily mounted to a PVC pole.
Here are more details.
Further Reading
The Next Level
The Capture Effect
|