Added non responsive sensor emergency stop

Added an 'emergency stop' feature to stop a run if the temperature
sensor is no longer providing data.  If the temperature sensor values
are remaining stable and exactly the same for 20 time cycles
consecutively while the heat is on, the run is reset to prevent damage
to the part or the oven.
pull/1/head
sbman 2015-07-02 10:47:34 -07:00
rodzic 19d65914ef
commit 00ed33b002
1 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -86,6 +86,8 @@ class Oven (threading.Thread):
self.reset()
def run(self):
temperature_count = 0
last_temp = 0
while True:
self.door = self.get_door_state()
@ -102,8 +104,24 @@ class Oven (threading.Thread):
log.info("pid: %.3f" % pid)
self.set_cool(pid <= -1)
if(pid > 0):
# The temp should be changing with the heat on
# Count the number of time_steps encountered with no change and the heat on
if last_temp == self.temp_sensor.temperature:
temperature_count += 1
else:
temperature_count = 0
# If the heat is on and nothing is changing, reset
# The direction or amount of change does not matter
# This prevents runaway in the event of a sensor read failure
if temperature_count > 20:
log.info("Error reading sensor, oven temp not responding to heat.")
self.reset()
else:
temperature_count = 0
self.set_heat(pid > 0)
#if self.profile.is_rising(self.runtime):
# self.set_cool(False)
# self.set_heat(self.temp_sensor.temperature < self.target)
@ -119,6 +137,9 @@ class Oven (threading.Thread):
if self.runtime >= self.totaltime:
self.reset()
#Capture the last temperature value
last_temp = self.temp_sensor.temperature
time.sleep(self.time_step)
def set_heat(self, value):