Remove unnecessary states in PI servo.
Step the clock as soon as the second sample is collected. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
af2a4f47fb
commit
d8cb9be46a
14
pi.c
14
pi.c
|
@ -72,25 +72,19 @@ static double pi_sample(struct servo *servo,
|
|||
case 1:
|
||||
s->offset[1] = offset;
|
||||
s->local[1] = local_ts;
|
||||
*state = SERVO_UNLOCKED;
|
||||
s->count = 2;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
s->drift += (s->offset[1] - s->offset[0]) * 1e9 /
|
||||
(s->local[1] - s->local[0]);
|
||||
if (s->drift < -s->maxppb)
|
||||
s->drift = -s->maxppb;
|
||||
else if (s->drift > s->maxppb)
|
||||
s->drift = s->maxppb;
|
||||
*state = SERVO_UNLOCKED;
|
||||
s->count = 3;
|
||||
break;
|
||||
case 3:
|
||||
|
||||
*state = SERVO_JUMP;
|
||||
ppb = s->drift;
|
||||
s->count = 4;
|
||||
s->count = 2;
|
||||
break;
|
||||
case 4:
|
||||
case 2:
|
||||
/*
|
||||
* reset the clock servo when offset is greater than the max
|
||||
* offset value. Note that the clock jump will be performed in
|
||||
|
|
Loading…
Reference in New Issue