Skip to content

Commit

Permalink
Add Zero temperature count, avoid heater verify failed before lost co…
Browse files Browse the repository at this point in the history
…mm with mcu.
  • Loading branch information
GuoGeTiertime committed Jul 16, 2024
1 parent 4b8884c commit 3d89884
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion klippy/extras/verify_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, config):
self.last_target = self.goal_temp = self.error = 0.
self.goal_systime = self.printer.get_reactor().NEVER
self.check_timer = None
self.zero_cnt = 0
def handle_connect(self):
if self.printer.get_start_args().get('debugoutput') is not None:
# Disable verify_heater if outputting to a debug file
Expand All @@ -46,6 +47,13 @@ def handle_shutdown(self):
reactor.update_timer(self.check_timer, reactor.NEVER)
def check_event(self, eventtime):
temp, target = self.heater.get_temp(eventtime)
if temp == 0.:
self.zero_cnt += 1
logging.error("Heater %s temperature is zero, cnt: %d @ %.3f" % (self.heater_name, self.zero_cnt, eventtime) )
if self.zero_cnt < 10: # ignore first 10 zero readings
temp = target
else:
self.zero_cnt = 0
if temp >= target - self.hysteresis or target <= 0.:
# Temperature near target - reset checks
if self.approaching_target and target:
Expand All @@ -68,7 +76,7 @@ def check_event(self, eventtime):
self.goal_systime = eventtime + self.check_gain_time
elif self.error >= self.max_error:
logging.info( "***** Error, heater %s over max_error, temp:%.2f, target: %.2f, error:%.2f, preverr:%.2f, max:%.2f, add tiertime 20231130.",
temp, target, self.error, prev_error, self.max_error)
self.heater_name, temp, target, self.error, prev_error, self.max_error)
# Failure due to inability to maintain target temperature
return self.heater_fault()
elif temp >= self.goal_temp:
Expand Down

0 comments on commit 3d89884

Please sign in to comment.