Skip to content

Commit

Permalink
Update oven.py
Browse files Browse the repository at this point in the history
Added proportional output funtionality by turning the oven (SSR) on for a portion of the time_step determined by the pid loop output. So, if time_step = 1, and the pid loop is calling for .3 heat, the SSR will be on for .3 seconds, and off for .7 seconds.  I did this by adding an additional sleep.  Previously, the SSR would be on whenever pid > 0.
  • Loading branch information
benkrasnow authored Jun 9, 2018
1 parent 0f598a2 commit 35eb7d3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def abort_run(self):
def run(self):
temperature_count = 0
last_temp = 0
pid = 0
while True:
self.door = self.get_door_state()

Expand Down Expand Up @@ -133,7 +134,7 @@ def run(self):
else:
temperature_count = 0

self.set_heat(pid > 0)
self.set_heat(pid)

#if self.profile.is_rising(self.runtime):
# self.set_cool(False)
Expand All @@ -152,17 +153,23 @@ def run(self):

#Capture the last temperature value
last_temp = self.temp_sensor.temperature

time.sleep(self.time_step)
if pid > 0:
time.sleep(self.time_step * (1 - pid))
else:
time.sleep(self.time_step)

def set_heat(self, value):
if value:
if value > 0:
self.heat = 1.0
if gpio_available:
if config.heater_invert:
GPIO.output(config.gpio_heat, GPIO.LOW)
time.sleep(self.time_step * value)
GPIO.output(config.gpio_heat, GPIO.HIGH)
else:
GPIO.output(config.gpio_heat, GPIO.HIGH)
time.sleep(self.time_step * value)
GPIO.output(config.gpio_heat, GPIO.LOW)
else:
self.heat = 0.0
if gpio_available:
Expand Down

0 comments on commit 35eb7d3

Please sign in to comment.