time  

The Next Level

Maximum Accuracy

The techniques described can be used to create a very accurate time server. You might think that you could achieve microsecond accuracy easily this way. Unfortunately, this is not true.

What a GPS clock will give you is a stream of accurate second boundaries. However, a time server must know what time it is at any instant. In order to do this, you attempt to synchronize a higher frequency clock to the second boundaries coming from the GPS clock.

Typically, you use a Pentium's instruction counter. One nice feature of the Intel Pentium processor is that it can count instruction cycles, and you can read this counter at any time. If you have a Pentium 100, this gives you easy access to a clock that has well under microsecond resolution.

The best that you can do is to measure how many clock cycles there are between PPS inputs. That then tells you your current frequency to high accuracy. For a Pentium 100, it will usually be between 98Mhz and 102Mhz (my Pentium 200 runs at between 199.07 and 199.43 Mhz). You can then use this frequency measurement to interpolate the time at any time you need.

The problem is that this time source is not stable. It is generally produced indirectly by a quartz crystal oscillator that is not designed to be highly accurate. As a result, fractional degree temperature changes in the crystal from second to second cause its frequency to drift.

As a result, the stability you can achieve with just software is limited. In fact, without doing something to solve this problem, accuracy often falls to as low as ten microseconds. Since our PPS input has microsecond accuracy, we should be able to do better than this.

Fortunately, there is a fairly cheap and simple solution to this problem. Instead of using the processor's instruction counter, use a far more accurate counter. At the same time, you can add hardware to latch the counter's value at PPS inputs.

Highly stable oscillators are inexpensive. A 10Mhz oscillator with an accuracy of well under 1 ppm can be had for less than $30. The Toyocom TCO-627B is excellent for this purpose.

The idea is to run a 32-bit counter off this oscillator. When the PPS signal is received, you latch the counter's value. You also give the host computer the ability to latch the counter's value at any time.

Now, in software, you check the PPS counter latch a few times a second and store the readings each time they change. By subtracting consecutive readings, you can determine the oscillator's current frequency. Since the oscillator is highly stable, you can rely on the frequency reading not changing significantly over a period of a few seconds.

Then, when you need to determine the time, you follow a simple procedure. First, you latch the current counter value. Then you look up the counter value at the last PPS pulse and compute the difference. If you divide this difference, which is the number of counter pulses since the last second, by the current frequency, you can determine with high accuracy how much time has passed since the last PPS signal.

All that's left to do is to add this time offset to the time of the last PPS signal. At that point, you know the time to an accuracy of about 5 us. This procedure can be performed at any time. So you have a stable time source with which to make a stable time server.


Newsflash: It should be possible to replace the time base in your motherboard with a more stable one. Many Pentium motherboards use a 14.31818Mhz crystal to produce the timebase that goes to a PLL. Simply replacing this crystal with a TCXO or OCXO should make a big accuracy difference. More

Back

Copyright © 1999, 2001, 2002 GPSClock.com
Contact Us