[ntp:questions] NTP phase lock loop inputs and outputs?

skillzero at gmail.com skillzero at gmail.com
Mon May 19 04:10:28 UTC 2008


I'm doing NTP exchanges to determine my clock offset. I use this to
adjust my clock frequency, but there's a lot of lag so I overshoot by
too much and it oscillates around the reference frequency. This is an
audio clock so I have to do my own NTP stuff. I think I want to use a
phase lock loop as described in the NTP literature, but I'm confused
by the terminology (and possibly the math) so I'm not sure what the
inputs or outputs should be.

If my reference clock is running at ~44100 Hz and through my NTP
exchanges, I get an instantaneous offset of -20 Hz, I want to adjust
my clock to 44080 Hz, but no more than 5 Hz/sec (so it's not audible)
and that instantaneous offset will likely change as it narrows in on
the true frequency. The formula I've seen for NTP's PLL is:

	y = (Vs*u) / (64Tc)^2

I do NTP packet exchanges every 2 seconds so I think that resolves to:

	y = (2*Vs) / 16384

Is Vs the actual reference frequency estimate (44080 Hz in this case)?
I'm not sure how I use the result of the equation to adjust the clock.

I guess my question is that if I think my frequency is 44100 Hz and
via an NTP exchange, I calculate I'm off by -20 Hz, how should I
calculate what I should set my frequency to, to slowly sync to the
reference frequency (no more than 5 Hz/sec) while also factoring in
the previous clock offset estimate?

The current scheme I'm using to simply set my clock to 44100-5 Hz
(capping the -20 Hz offset to 5) every 2 seconds doesn't work very
well because it's too slow to realize that the direction of the offset
has changed because the absolute clock offset is still negative (e.g.
went from -20 to -5, but it's still negative so it thinks it still
needs to reduce the clock frequency when it should probably increase
it or leave it the same).




More information about the questions mailing list