[time-nuts] Re: GPSDO Control loop autotuning

Markus Kleinhenz Markus.Kleinhenz at izt-labs.de
Mon Apr 11 06:51:35 UTC 2022


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://febo.com/pipermail/time-nuts_lists.febo.com/attachments/20220411/79098645/attachment.sig>


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