From 22297229b7be6e2fd9d6496c887fff2bfc8ca032 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 7 Apr 2022 12:11:54 -0400 Subject: [PATCH] temperature_fan: Fix divide by zero error when pid_Ki is zero Signed-off-by: Kevin O'Connor --- klippy/extras/temperature_fan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/klippy/extras/temperature_fan.py b/klippy/extras/temperature_fan.py index 92dda7e0..aee94f28 100644 --- a/klippy/extras/temperature_fan.py +++ b/klippy/extras/temperature_fan.py @@ -147,7 +147,9 @@ class ControlPID: self.Ki = config.getfloat('pid_Ki') / PID_PARAM_BASE self.Kd = config.getfloat('pid_Kd') / PID_PARAM_BASE self.min_deriv_time = config.getfloat('pid_deriv_time', 2., above=0.) - self.temp_integ_max = self.temperature_fan.get_max_speed() / self.Ki + self.temp_integ_max = 0. + if self.Ki: + self.temp_integ_max = self.temperature_fan.get_max_speed() / self.Ki self.prev_temp = AMBIENT_TEMP self.prev_temp_time = 0. self.prev_temp_deriv = 0.