[time-nuts] General discussion of PID algorithms applied to GPSDO control loops

André Balsa andrebalsa at gmail.com
Thu Apr 14 14:12:10 UTC 2022


Hello fellow time-nuts,

I am afraid this post will only re-hash various concepts with which most of
you are much more familiar with than I am, but please bear with me and
share your thoughts for my education.

Since I am going to be working on the hybrid FLL/PLL control loop algorithm
for the STM32 GPSDO, I would like to discuss a few aspects of GPSDO control
loops and PID algorithms as applicable.

So first the PID reference is the Wikipedia article:
https://en.wikipedia.org/wiki/PID_controller

And a few preliminary considerations:

1. There are two main types of GPSDO control loops: FLL and PLL.

2. In FLL loops, the "process variable" PV is the frequency of the OCXO in
Hz, measured by a counter with the gate time controlled by the PPS from the
GPS receiver. No PPS, no frequency measurement.

3.  In PLL loops, the "process variable" PV is the phase difference (in ns)
between the rising edge of the (e.g.) 10MHz from the OCXO, and again the
rising edge of the PPS from the GPS receiver, measured by a "time interval
counter" TIC circuit which can be digital or analog. And similarly, no PPS
means no phase difference measurement.

4. In both cases, the presence of a PPS from the GPS receiver is essential.
Not only that, but the "precision" of the PPS from the GPS receiver
determines the precision of our measurements of the PV variables frequency
or phase difference. This is in fact what GPSDOs are all about: we use the
PPS from the GPS receiver as a "proxy" for the atomic clocks onboard the
satellites, to measure our local oscillator frequency or phase, and
"discipline" it.

5. Just a note about digital/analog measurement circuits: the STM32 GPSDO
FLL uses a 100% digital frequency measurement circuit, Lars' DIY GPSDO uses
an analog TIC that generates a voltage that is then converted to a digital
value using an ADC.

6. Getting back to our PPS from the GPS receiver, how "accurate" is it ?
The accuracy of a clock is not a single number, it is actually best
described ("characterized") by a chart, the famous ADEV/MDEV charts, which
essentially plot the statistical variance of the frequency of our clock
over a period of time (tau). I refer you to the seminal paper by Dr. Allan
himself: https://tf.nist.gov/general/pdf/2082.pdf So we know that the ideal
frequency of the PPS from the GPS receiver is exactly 1Hz, and we can
measure (using an even better clock) the minute variations in time between
two consecutive rising edges of our PPS signal, and then if we collect
enough measurements over e.g. a day or two, we can plot an ADEV/MDEV chart
for our PPS receiver. This has been done over and over again by extremely
knowledgeable people using very expensive equipment for a number of GPS
receivers, and - surprise, surprise - they have found that the ADEV/MDEV
curves for the PPS from different GPS receivers are actually quite similar.
I'll come back to that later. But for the moment, we can assume that the
"precision" of the PPS signal from a < $10 u-blox NEO M8N is better than
100ns over 1 second (10E-7) and improves by an order or magnitude per
decade iow it is approximately 10E-8 for tau = 10s, 10E-9 for tau = 100s,
etc. up to 10E-11 for tau=10k seconds.

7. I refer to this excellent analysis of various GPS receivers:
https://hamsci.org/sites/default/files/publications/2020_TAPR_DCC/N8UR_GPS_Evaluation_August2020.pdf
by John Ackermann N8UR

8. Note that in the STM32 GPSDO firmware we use a little trick to further
improve the accuracy of the PPS from the u-blox NEO-M8N GPS receiver. Check
the function ubxconfig() and you'll find this comment:

  // send UBX commands to set optimal configuration for GPSDO use
  // we are going to change a single parameter from default by
  // setting the navigation mode to "stationary"

9. Getting back to the Wikipedia article on PID control loops, we have now
defined our two process variables PVs frequency and phase difference, we
have just seen how to measure them, and we have a rough idea of
the precision of our measurements. What is the setpoint SP or target value
for these PVs ? For the frequency, it is the nominal frequency of our OCXO
or 10MHz in our case, and for the phase difference it is exactly 0. In the
STM32 GPSDO we already measure the error term e(t) every second for both
PVs: for the frequency, this is the "offset" which is now stored in a
20,000s unified ring buffer, and for the phase difference this is the
reading from the TIC, which we average over the last 10 seconds using the
moving average library (this simple filter can and will be improved).

10. (to be continued)




More information about the Time-nuts_lists.febo.com mailing list