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
Miroslav Lichvar 2013-01-14 17:09:11 +01:00 committed by Richard Cochran
parent af2a4f47fb
commit d8cb9be46a
1 changed files with 4 additions and 10 deletions

14
pi.c
View File

@ -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