[time-nuts] Re: GPSDO Control loop autotuning

Pluess, Tobias tpluess at ieee.org
Mon Apr 11 11:33:19 UTC 2022


Hi Markus,

Thanks for your hints. That's actually what I meant. One could use the
Kalman filter to "improve" the noise of the 1PPS signal being measured, and
then use the observed output from the Kalman filter as input to a
controller, which still might be a PI controller. Right?

Also thanks for your valuable links, I will look through these.
When I look at examples of Kalman filters, they often deal with position
and velocity control and the state variables are often the position, speed
and sometimes even acceleration.
In the case of a GPSDO, what should the states be?
I was thinking a lot about this topic, and I believe there are several
possibilities.

For instance, one could use only the phase as state. In that case, the
Kalman filter would be 1D and this would be the simplest case.
On the other hand, we could also have the phase and the frequency as
states, because the frequency is the derivative of the phase, and this
would be analogous to the position-velocity example. I am not sure which
one of these models shall be used, is there a "right" one and a "wrong"
one, i.e. with the wrong one it won't work at all?

I believe, but am not 100% sure, the state space model with just one state
would work, with the phase being used as the only state.

phi[k] = phi[k-1] + K_VCO * u

where u is the control input. Further, the Kalman filter needs to know the
process noise and measurement noise. I would guess that the process noise
in our case is very small, as the OCXO is very stable. On the other hand,
the measurement noise is large, because the 1PPS coming from the GPS module
has some jitter which affects the measurement. However, and this is
probably an interesting idea, the GPS module outputs an estimate of the
timing accuracy, so couldn't we use this information to estimate our
measurement noise? the timing accuracy squared would directly yield the
measurement variance. And the above state equation could be used for the
Kalman filter, together with the estimated timing accuracy information
which we get from the GPS module.

But I am unsure whether this will work, at first it almost sounds too
simple :-)

Then, once per second, the Kalman equations are calculated and the Kalman
filter yields an estimate of the phase error that is (hopefully!) smoother
than the 1PPS from GPS, and this signal would then be used as input to the
PI controller. We would still need the PI controller, but we could add the
Kalman filter as sort of prefilter that removes some of the jitter.

best
Tobias
HB9FSX



On Mon, Apr 11, 2022 at 9:19 AM Markus Kleinhenz via time-nuts <
time-nuts at lists.febo.com> wrote:

> Hi Tobias,
>
> I was looking into Kalman filters as well, albeit some time ago. But I
> think i got some pointers that can put
> you on your path.
>
> 1. The Kalman filter is an estimator not a controller. It gives you an
> estimate of your current system state but no controll law.
>
> 2. Time and the Kalman Filter by Lorenzo Galleani et al
> <https://ieeexplore.ieee.org/document/5438294> is a great article on the
> topic.
>
> 3. There are control schemes which are designed for the state space like
> Linear–quadratic–Gaussian control
> <
> https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic%E2%80%93Gaussian_control
> >
>
> 4. Comparison between Simulation and Hardware,Realization for Different
> Clock Steering Techniques
> <https://elib.dlr.de/127013/1/LQR_PP_Metrologia_paper_revised.pdf>  is
> another paper on the topic
>
> 5. A Practical Approach to Optimal Control Problem for Atomic Clocks
> <https://ieeexplore.ieee.org/document/8922770> claims to use a Kalman
> filter and LQG control to achieve better ADEV than the used WPN reference.
>
> I hope these are helpful.
> Unfortunately i haven't had the time to implement these myself.
>
> Regards
> Markus
>
> Am 09.04.2022 um 18:13 schrieb Pluess, Tobias via time-nuts:
> > Hi all,
> >
> > My reply to this topic is a bit late because I have been busy with other
> > topics in the meantime.
> >
> > To Erik Kaashoek,
> > You mentioned my prefilter. You are absolutely right, I looked again at
> my
> > prefilter code and decided it was garbage. I have removed the prefilter.
> > Thanks to your hint I also found another mistake in my PI controller
> code,
> > which led to wrong integration times being used. I corrected that and the
> > controller is now even more stable. I made some tests and the DAC output
> > changes less than before, so I guess the stability is even better!
> >
> > To all others.
> > I discussed the topic of improving my GPSDO control loop with a colleague
> > off-list and he pointed out that, on this list, there was a while ago a
> > post about Kalman filters.
> > I totally forgot about this, I have looked at them at university a couple
> > years ago, but never used it and therefore forgot most of it. But I think
> > it would be interesting to try to implement the Kalman filter and compare
> > its performance with the PI controller I currently have.
> >
> > I guess the first step before thinking about any Kalman filters is to
> find
> > the state space model of the system. I am familiar with the state space,
> > but one topic I was always a bit struggling with is the question which
> > variables I should take into account for my state. In the case of the
> > GPSDO, all I can observe is the phase difference between the locally
> > generated 1PPS and the 1PPS that comes from the GPS module. On the other
> > hand, I am not only interested in the phase, but also in the frequency,
> or,
> > probably, in the frequency error, so I think my state vector needs to use
> > the phase difference (in seconds) and the frequency error (?). So my
> > attempt for a GPSDO state space model is:
> >
> > phi[k+1] = phi[k] - T * Delta_f[k]
> > Delta_f[k+1] = Delta_f[k] + K_VCO * u
> >
> > y[k] = phi[k]
> >
> > u is the control voltage that is applied to the VCO, Delta_f is the VCO
> > frequency error and T is the sampling period, which is 1 second in this
> > case because the control loop is executed once per second, triggered by
> the
> > 1PPS pulse from GPS. Note that with "VCO" I actually mean the combination
> > of the OCXO plus the clock divider that produces the 1PPS signal, which
> we
> > want to control in both aspects, phase and frequency. So this VCO outputs
> > just 1 Hz signals, plus or minus some deviation that depends on the
> control
> > voltage of the OCXO.
> >
> > Assume for a moment the GPS module has no jitter and outputs a perfect
> 1PPS
> > pulse. Also assume the whole thing is nicely locked and the VCO has no
> > frequency and phase error. In this case, the model yields the right
> > behaviour, that is, the phase (actually the time interval) between the
> two
> > 1PPS signals is always 0. Also, Delta_f stays 0. (The linear VCO model
> > assumes the VCO is at nominal frequency for zero voltage).
> > Now if we assume we apply a VCO voltage u that sets the VCO high by 0.1
> Hz.
> > At the beginning, the 1PPS pulses are perfectly aligned, but one second
> > later, the VCO is around 100ms too early and therefore the phase is now
> > -100 ms and so on. It is not 100% correct because a 0.1 Hz frequency
> > increase gives a 909 ms period and therefore the phase should be actually
> > -91 ms, but it's sort of close. Since we are dealing with small frequency
> > errors only, the approximation is probably good enough?
> > Is that a useful state space model, would it make sense to try to proceed
> > with this? or is this complete garbage and I am thinking too far.
> > Or would it make sense to use the Kalman filter with only one state
> > variable, which is the phase? In that case the calculations would
> probably
> > be simpler.
> >
> > Thanks for any hints,
> > best
> > Tobias
> > HB9FSX
> >
> >
> >
> >
> > On Mon, Mar 21, 2022 at 9:08 AM Erik Kaashoek <erik at kaashoek.com> wrote:
> >
> >> Hi Tobias,
> >>
> >> I'm very new to all this GPSDO stuff and going through similar learning
> >> but maybe I have some remarks/questions that could be relevant for you.
> >> - Developing control algorithms is an extremely long process unless done
> >> on a simulator. Tom Van Baak has an excellent simulator and several
> >> realistic data sets for testing.
> >> http://www.leapsecond.com/pages/gpsdo-sim/
> >> - Use Timelab to look at the ADEV, the frequency error and the phase
> >> error to evaluate the performance.
> >> - Why do you prefilter? In my experience this only adds a time delay in
> >> the input data for the loop and makes it harder to do a good job. Test
> >> if the prefilter works by taking one of the GPS data sets from Tom and
> >> run it through the prefilter and test using the simulator if the results
> >> improve.
> >> - In my GPSDO temperature changes and supply voltage variations where
> >> the largest source of variations. You can simulate this with the
> >> simulator by creating LO data sets with artificial changes in frequency.
> >> Add a drift and test if the loop can keep up, add a jump and see how
> >> fast it recovers
> >> Erik, PD0EK
> >>
> >> On 20-3-2022 21:46, Pluess, Tobias via time-nuts wrote:
> >>> Hi Bob,
> >>>
> >>> I see your point on quickly moving the OCXO. However of course this is
> >> NOT
> >>> what I do. To be precise, my GPSDO does this exactly once after
> powerup,
> >> to
> >>> quickly align the PPS. After that, the control loop takes over and
> steers
> >>> the OCXO according to the error signal.
> >>> I also have already implemented the algorithm that switches the control
> >>> parameter sets: just after powerup, a "quick" set is used, that quickly
> >>> brings the OCXO to the right frequency but also lets the DAC work quite
> >>> hard. If the time error stays below 100 ns for a couple minutes, an
> >>> "intermediate" control set is used with longer loop time constants. If
> >> the
> >>> time error stays below 100 ns for a couple minutes, the "slow" control
> >> set
> >>> is used which, currently, has a loop time constant of one hour. The DAC
> >>> ouput changes very rarely, about one count up or down every couple
> >> minutes.
> >>> What I wanted to achieve with this autotuning is to find out whether 1
> >> hour
> >>> is a good time constant. Should it be longer? shorter? what would be
> the
> >>> best value?
> >>>
> >>> Since the GPSDO already has a TIC built in, that measures the time
> >> interval
> >>> between the two PPS, I thought it must be, somehow, possible to assess
> >> the
> >>> current performance of the GPSDO. Lets say by estimating the ADEV.
> Based
> >> on
> >>> that value, it should then be possible to adapt the loop time constant,
> >>> until some sort of optimum is found. No?
> >>>
> >>> Best
> >>> Tobias
> >>> HB9FSX
> >>>
> >> _______________________________________________
> >> time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe
> send
> >> an email to time-nuts-leave at lists.febo.com
> >> To unsubscribe, go to and follow the instructions there.
> >>
> > _______________________________________________
> > time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe
> send an email to time-nuts-leave at lists.febo.com
> > To unsubscribe, go to and follow the instructions there.
> >
> --
> Innovationszentrum für Telekommunikationstechnik GmbH IZT
> Kleinhenz Markus
> Fon: +49-9131-9162-546
> Fax: +49-9131-9162-190
> Markus.Kleinhenz at izt-labs.de
>
> Am Weichselgarten 5
> D-91058 Erlangen
> http://www.izt-labs.de
> Rechtsform und Sitz: GmbH, D-Erlangen
> Registergericht: AG Fürth, HRB 6716
> Geschäftsführung: Rainer Perthold
>
> Wie Sie wissen, können über das Internet versandte E-Mails leicht unter
> fremden Namen erstellt oder manipuliert werden. Aus diesem Grund bitten
> wir um Verständnis dafür, dass wir zu Ihrem und unserem Schutz die
> rechtliche Verbindlichkeit der vorstehenden Erklärung ausschließen,
> soweit wir mit Ihnen keine andere Vereinbarung getroffen haben.
>
> Diese E-Mail kann vertrauliche Informationen enthalten. Wenn Sie nicht
> der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
> informieren Sie bitte sofort den Absender und vernichten Sie diese
> E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser
> E-Mail oder von Teilen dieser E-Mail ist nicht gestattet.
>
> The information contained in this message and any attachments is
> intended only for the use of the individual or entity to which it is
> addressed and may contain information that is privileged, confidential
> and exempt from disclosure under applicable law. If you have received
> this message in error, you are prohibited from copying, distributing,
> or using the information. Please contact the sender immediately by
> return e-mail and delete the original message.
>
> _______________________________________________
> time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe send
> an email to time-nuts-leave at lists.febo.com
> To unsubscribe, go to and follow the instructions there.




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