Current implementation saves s->drift as an offset between current clock frequency and the remote clock frequency calculated on first two samples.
Locked state of the PI servo assumes the s->drift holds the history of clock frequency difference scaled by s->ki * weight. As a result the lock needs more time to stabilize when the frequency offset is very large (ex. set to extreme values with phc_ctl) or may totally prevent servo from correctly locking. This patch fixes the s->drift when entering the stable state to hold the scaled drift. Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net> --- pi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pi.c b/pi.c index 4a96a5b..bc38073 100644 --- a/pi.c +++ b/pi.c @@ -120,6 +120,7 @@ static double pi_sample(struct servo *servo, *state = SERVO_LOCKED; ppb = s->drift; + s->drift *= (s->ki * weight); s->count = 2; break; case 2: -- 2.30.2 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel