[time-nuts] Re: GPSDO Control loop autotuning

Pluess, Tobias tpluess at ieee.org
Sat Apr 9 16:13:48 UTC 2022


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.
>




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