[time-nuts] PID Loop question as it relates to NTP

xaos xaos at darksmile.net
Thu Sep 15 21:48:20 UTC 2005


Hello Everyone,

I am in the midst of a design for a
new custom CPU board. I decided
to include NTP, in the board software,
for time keeping purposes.

The system is working rather well and
I am able to get millisecond time sync.
BTW this is as good as I'll get
on this hardware.

The background is this:

    I am using a PID Control loop to discipline
    the time and I am wondering if my algorithm
    is the correct one.

    This is what I do:

    Get NTP time every T seconds
    Calculate error
    Calculate correction
    Apply correction slowly.

        This means that if the correction is: C
        and if my smallest system clock increment is: I
        and if there are N clock increments until
        the next NTP get time.

        Then I apply a correction of: C/N for every I.

        In other words, the correction is smooth
        over the NTP sync interval (T).

    This method works quite well and the system
    reaches <100ms sync at almost (10T).

    It reaches <10ms at almost (20T)

And this is my question:

Should I be correcting the system this way
or should I be correcting all at once at the
time of NTP sync.

Should I expect a better convergence
if I use the all at once method?

Your thoughts on this are much
appreciated.

George Hrysanthopoulos, N2FGX





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