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)