# [time-nuts] Explanation of how a GPS RX generates time/freq precision?

Attila Kinali attila at kinali.ch
Mon Nov 23 09:02:12 EST 2015

```Moin moin,

On Sun, 22 Nov 2015 21:51:19 -0500
Mike Baker <mpb45 at clanbaker.org> wrote:

> My question is--  Can anyone on the Time-Nuts list point me
> to a source I can give them that will explain how the process
> works?  Seems to me that I have seen some papers describing
> the process but my search for this info has not turned up
> anything suitable that goes into some detail on this.
> Any feedback or suggestions on this is much appreciated!!

The questions are going into two directions.
One is determining the code phase of the GPS signal
to better than the sampling rate.
And the other one is measuring oscillator phase
and frequency differences.

For the first one I would recommend to have a look at the
book "Understanding GPS: Principles and Applications" by Kaplan et al.
It contains a very good explanation on how GPS works, with all the
pesky details. Another book worth having a look at is
"Fundamentals of Global Positioning System - A Software Approach",
by Tsui. The latter is more implementation oriented and gives example
code in Matlab.

To give you a intuitive understanding: The GPS code gives you
edges which you measure with your sampling clock. You know where
the "true" edges should be because you know what the code looks
like. Hence you can average over the position of the edges and
get the average. Hence you get a solution which is below the
granularity of your sampling clock. I have not done the calculations
how well this goes, but IIRC you get something of the order of 10ps
RMS error for consumer grade GPS chip.

The next step is measuring the phase offset of your local clock
relative to the GPS generated PPS. For simplicity, i just assume
that the PPS is already sawtooth corrected.
The simple way of doing this is using a counter that is clocked
by the processor. Unfortunately, as you noticed, that gives you
a resolution of at maximum the clock period of your counter
(disregarding metastability effects, again for clarity). But
you can do better if you don't just use a counter. There are
many time to digital converter (TDC) architectures that can
do better. The general idea is that you do not depend on a
counter clock, but make something that is "started" asynchronously
by the PPS and "stopped" by the clock of your local oscillator.
The review paper by Kalisz[1] gives a nice overview of most known

Usually, for time/phase difference mesurements, involving GPS,
the limit is given by GPS' uncertainty of several ns for
compensated/calibrated systems and several dozens of ns for
uncalibrated systems (due to delays in cables and electronics).

For frequency measurements, you can do better by measuring
over long intervals, and integrating/averaging. This works
under the assumption that the frequency measurement error
has zero mean, which is (almost) true for all frquency measuremnt
systems build upon phase measurement. With GPS you have to ensure
that GPS does not induce a frequency error and thus often integrate
over integer multiples of 24h (the "repetition" rate of the GPS
(due to delays in cables and electronics) falls out in your measurement
of frequency, as you take the difference of two events with the same
phase offset (under the assumption that the delays do not change).

I hope that clears the confusion

Attila Kinali

[1] "Review of methods for time interval measurements with
picosecond resolution", by Josef Kalisz, 2003
http://dx.doi.org/10.1088/0026-1394/41/1/004
http://ztc.wel.wat.edu.pl/met4_1_004.pdf

--
It is upon moral qualities that a society is ultimately founded. All
the prosperity and technological sophistication in the world is of no
use without that foundation.
-- Miss Matheson, The Diamond Age, Neil Stephenson
```