Pid Controller: Set integral term lower boundary to 0

This commit is contained in:
Mario Hüttel 2021-03-21 19:18:08 +01:00
parent 60104df30e
commit e815442617

View File

@ -65,8 +65,8 @@ static void calculate_integral(struct pid_controller *pid, float deviation)
/* Saturate integral term to specified maximum */ /* Saturate integral term to specified maximum */
if (pid->integral > pid->integral_max) if (pid->integral > pid->integral_max)
pid->integral = pid->integral_max; pid->integral = pid->integral_max;
else if (pid->integral < -pid->integral_max) else if (pid->integral < 0.0f)
pid->integral = -pid->integral_max; pid->integral = 0.0f;
} }
float pid_sample(struct pid_controller *pid, float deviation) float pid_sample(struct pid_controller *pid, float deviation)