Don't use time_offset as a leaky bucket variable in hardpps(), this
resulted in vastly optimistic offset values reported to userland (typically a factor 40+ too small). Apart from that, the code had two sign-bugs. Apply the hardpps() phase with the right sign with a simply scaling by integration interval. (This may be too stiff at long integration intervals, see below). Allow pps_shiftmax to be reduced again. Before this, the phase lock in hardpps() were broken, but due to two bugs mostly cancelling out, it would end up basically working with a large stochastic component. Now it behaves as one would expect: smooth and quiet. It seems that pps_shiftmax above 7..9 somewhere makes the phaselock too weak to hold onto random walk phase errors from a HP-105 OCXO, which basically means that it is too weak for real-life use with such integration times. This is yet to be resolved. Submitted to: Prof. Dave "NTP" Mills. Tested by: Terje Mathisen <Terje.Mathisen@hda.hydro.com>
This commit is contained in:
parent
4712894e59
commit
19c5221906
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55219
@ -27,6 +27,8 @@
|
||||
* Only minor changes done to interface with the timecounters over in
|
||||
* sys/kern/kern_clock.c. Some of the comments below may be (even more)
|
||||
* confusing and/or plain wrong in that context.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "opt_ntp.h"
|
||||
@ -398,7 +400,7 @@ void
|
||||
ntp_update_second(struct timecounter *tcp)
|
||||
{
|
||||
u_int32_t *newsec;
|
||||
l_fp ftemp, time_adj; /* 32/64-bit temporaries */
|
||||
l_fp time_adj; /* 32/64-bit temporaries */
|
||||
|
||||
newsec = &tcp->tc_offset_sec;
|
||||
/*
|
||||
@ -477,18 +479,18 @@ ntp_update_second(struct timecounter *tcp)
|
||||
* value is in effect scaled by the clock frequency,
|
||||
* since the adjustment is added at each tick interrupt.
|
||||
*/
|
||||
ftemp = time_offset;
|
||||
time_adj = time_offset;
|
||||
#ifdef PPS_SYNC
|
||||
if (time_status & STA_PPSTIME && time_status &
|
||||
STA_PPSSIGNAL)
|
||||
L_RSHIFT(ftemp, PPS_FAVG);
|
||||
else
|
||||
L_RSHIFT(ftemp, SHIFT_PLL + time_constant);
|
||||
if (time_status & STA_PPSTIME && time_status & STA_PPSSIGNAL) {
|
||||
L_RSHIFT(time_adj, pps_shift);
|
||||
} else {
|
||||
L_RSHIFT(time_adj, SHIFT_PLL + time_constant);
|
||||
L_SUB(time_offset, time_adj);
|
||||
}
|
||||
#else
|
||||
L_RSHIFT(ftemp, SHIFT_PLL + time_constant);
|
||||
L_RSHIFT(time_adj, SHIFT_PLL + time_constant);
|
||||
L_SUB(time_offset, time_adj);
|
||||
#endif /* PPS_SYNC */
|
||||
time_adj = ftemp;
|
||||
L_SUB(time_offset, ftemp);
|
||||
L_ADD(time_adj, time_freq);
|
||||
tcp->tc_adjustment = time_adj;
|
||||
#ifdef PPS_SYNC
|
||||
@ -728,10 +730,7 @@ hardpps(tsp, nsec)
|
||||
time_status |= STA_PPSJITTER;
|
||||
pps_jitcnt++;
|
||||
} else if (time_status & STA_PPSTIME) {
|
||||
L_LINT(ftemp, v_nsec);
|
||||
L_SUB(ftemp, time_offset);
|
||||
L_RSHIFT(ftemp, pps_shift);
|
||||
L_SUB(time_offset, ftemp);
|
||||
L_LINT(time_offset, -v_nsec);
|
||||
}
|
||||
pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG;
|
||||
u_sec = pps_tf[0].tv_sec - pps_lastsec;
|
||||
@ -788,7 +787,11 @@ hardpps(tsp, nsec)
|
||||
} else {
|
||||
pps_intcnt++;
|
||||
}
|
||||
if (pps_intcnt >= 4) {
|
||||
if (pps_shift > pps_shiftmax) {
|
||||
/* If we lowered pps_shiftmax */
|
||||
pps_shift = pps_shiftmax;
|
||||
pps_intcnt = 0;
|
||||
} else if (pps_intcnt >= 4) {
|
||||
pps_intcnt = 4;
|
||||
if (pps_shift < pps_shiftmax) {
|
||||
pps_shift++;
|
||||
|
Loading…
Reference in New Issue
Block a user