From fb5f9034eab3ba32f8408b2f4b1a7a5a40ecf644 Mon Sep 17 00:00:00 2001 From: Eric Price Date: Thu, 9 Mar 2017 18:48:36 +0100 Subject: [PATCH] LP-289 prevent initialization with non-zero pid->I accumulator (dangerous if kI is low) --- flight/libraries/math/pid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flight/libraries/math/pid.c b/flight/libraries/math/pid.c index 4fba36984..8f4babcb8 100644 --- a/flight/libraries/math/pid.c +++ b/flight/libraries/math/pid.c @@ -221,7 +221,10 @@ float pid2_apply( pid->D = 0.0f; // t=0, u=u0, y=y0, v=u - pid->I = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y); + // pid->I = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y); + // this is dangerous, if pid->I starts nonzero with very low or zero kI, then + // it will never settle! + pid->I = 0.0f; } // compute proportional part