aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/heater.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-13 13:13:31 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-16 12:49:15 -0400
commite60779bfe117abdf861f65012d3fdf037b81b46c (patch)
tree09c672cd6d21d6a5e7687a7964a8f08ebb245690 /klippy/heater.py
parentf66b1ac450d3a33cea66e2f1ea6f81befe0c0e39 (diff)
downloadkutter-e60779bfe117abdf861f65012d3fdf037b81b46c.tar.gz
kutter-e60779bfe117abdf861f65012d3fdf037b81b46c.tar.xz
kutter-e60779bfe117abdf861f65012d3fdf037b81b46c.zip
heater: Force set_pwm of zero when target_temp is zero
Fix a corner case where a residual in the PID could cause a non-zero pwm request even when the target_temp is zero. (Which could lead to a firmware "Missed scheduling of next pwm event" shutdown.) Simplify the logic for suppressing duplicate pwm updates and make sure a zero target_temp always results in a zero pwm update on the following set_pwm calculation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/heater.py')
-rw-r--r--klippy/heater.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/klippy/heater.py b/klippy/heater.py
index 84249a9d..8de546b5 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -72,14 +72,11 @@ class PrinterHeater:
self.next_pwm_time = 0.
self.last_pwm_value = 0
def set_pwm(self, read_time, value):
- if value:
- if self.target_temp <= 0.:
- return
- if (read_time < self.next_pwm_time
- and abs(value - self.last_pwm_value) < 0.05):
- return
- elif not self.last_pwm_value and (
- self.target_temp <= 0. or read_time < self.next_pwm_time):
+ if self.target_temp <= 0.:
+ value = 0.
+ if ((read_time < self.next_pwm_time or not self.last_pwm_value)
+ and abs(value - self.last_pwm_value) < 0.05):
+ # No significant change in value - can suppress update
return
pwm_time = read_time + REPORT_TIME + SAMPLE_TIME*SAMPLE_COUNT
self.next_pwm_time = pwm_time + 0.75 * MAX_HEAT_TIME