changed to work with simulation for easier maintenance
This commit is contained in:
parent
f608a7199b
commit
62efd5cde5
@ -6,7 +6,6 @@ import csv
|
|||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def recordprofile(csvfile, targettemp):
|
def recordprofile(csvfile, targettemp):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -32,6 +31,7 @@ def recordprofile(csvfile, targettemp):
|
|||||||
# construct the oven
|
# construct the oven
|
||||||
if config.simulate:
|
if config.simulate:
|
||||||
oven = SimulatedOven()
|
oven = SimulatedOven()
|
||||||
|
oven.target = targettemp * 2 # insures max heating for simulation
|
||||||
else:
|
else:
|
||||||
oven = RealOven()
|
oven = RealOven()
|
||||||
|
|
||||||
@ -42,35 +42,43 @@ def recordprofile(csvfile, targettemp):
|
|||||||
# * wait for it to decay back to the target again.
|
# * wait for it to decay back to the target again.
|
||||||
# * quit
|
# * quit
|
||||||
#
|
#
|
||||||
# We record the temperature every second
|
# We record the temperature every config.sensor_time_wait
|
||||||
try:
|
try:
|
||||||
stage = 'heating'
|
|
||||||
if not config.simulate:
|
|
||||||
oven.output.heat(0)
|
|
||||||
|
|
||||||
while True:
|
# heating to target of 400F
|
||||||
temp = oven.board.temp_sensor.temperature + \
|
temp = 0
|
||||||
|
sleepfor = config.sensor_time_wait
|
||||||
|
stage = "heating"
|
||||||
|
while(temp <= targettemp):
|
||||||
|
if config.simulate:
|
||||||
|
oven.heat_then_cool()
|
||||||
|
else:
|
||||||
|
oven.output.heat(sleepfor)
|
||||||
|
temp = oven.board.temp_sensor.temperature() + \
|
||||||
config.thermocouple_offset
|
config.thermocouple_offset
|
||||||
|
|
||||||
|
print("stage = %s, actual = %.2f, target = %.2f" % (stage,temp,targettemp))
|
||||||
csvout.writerow([time.time(), temp])
|
csvout.writerow([time.time(), temp])
|
||||||
f.flush()
|
f.flush()
|
||||||
|
|
||||||
if stage == 'heating':
|
# overshoot past target of 400F and then cooling down to 400F
|
||||||
if temp >= targettemp:
|
stage = "cooling"
|
||||||
if not config.simulate:
|
if config.simulate:
|
||||||
oven.output.cool(0)
|
oven.target = 0
|
||||||
stage = 'cooling'
|
while(temp >= targettemp):
|
||||||
|
if config.simulate:
|
||||||
elif stage == 'cooling':
|
oven.heat_then_cool()
|
||||||
if temp < targettemp:
|
else:
|
||||||
break
|
oven.output.cool(sleepfor)
|
||||||
|
temp = oven.board.temp_sensor.temperature() + \
|
||||||
print("stage = %s, actual = %s, target = %s" % (stage,temp,targettemp))
|
config.thermocouple_offset
|
||||||
time.sleep(1)
|
|
||||||
|
print("stage = %s, actual = %.2f, target = %.2f" % (stage,temp,targettemp))
|
||||||
f.close()
|
csvout.writerow([time.time(), temp])
|
||||||
|
f.flush()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
f.close()
|
||||||
# ensure we always shut the oven down!
|
# ensure we always shut the oven down!
|
||||||
if not config.simulate:
|
if not config.simulate:
|
||||||
oven.output.cool(0)
|
oven.output.cool(0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user