From e815442617cf0e5674e9510a274277327ae675df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 21 Mar 2021 19:18:08 +0100 Subject: [PATCH] Pid Controller: Set integral term lower boundary to 0 --- stm-firmware/pid-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stm-firmware/pid-controller.c b/stm-firmware/pid-controller.c index 141771e..83e7f77 100644 --- a/stm-firmware/pid-controller.c +++ b/stm-firmware/pid-controller.c @@ -65,8 +65,8 @@ static void calculate_integral(struct pid_controller *pid, float deviation) /* Saturate integral term to specified maximum */ if (pid->integral > pid->integral_max) pid->integral = pid->integral_max; - else if (pid->integral < -pid->integral_max) - pid->integral = -pid->integral_max; + else if (pid->integral < 0.0f) + pid->integral = 0.0f; } float pid_sample(struct pid_controller *pid, float deviation)