Skip to content

Commit

Permalink
Update from actual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgao committed Oct 18, 2014
1 parent 8dd9752 commit 3cb20a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 4 additions & 1 deletion kiln/bisque_firing_06.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import manager
import thermo
import sys
import time

if __name__ == "__main__":
start_time = None
Expand All @@ -9,6 +10,8 @@
schedule = [[2*60*60, 176], [4*60*60, 620], [6*60*60, 1013], [6*60*60+20*60, 1013]]
mon = thermo.Monitor()
mon.start()
time.sleep(1)
#schedule = [[20, 176], [40, 620], [60, 1013]]
kiln = manager.KilnController(schedule, mon, start_time=start_time, simulate=False)
kiln.run()
kiln.run()
mon.stop()
7 changes: 3 additions & 4 deletions kiln/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, schedule, monitor, interval=5, start_time=None, Kp=.01, Ki=.0
if simulate:
self.schedule.insert(0, [0, 15])
else:
self.schedule.insert(0, [0, self.monitor.temperature])
self.schedule.insert(0, [0, 15])

@property
def elapsed(self):
Expand All @@ -34,13 +34,12 @@ def run(self):
#find epoch
for i in range(len(self.schedule)-1):
if self.schedule[i][0] < ts < self.schedule[i+1][0]:
print "In epoch %d"%i
time0, temp0 = self.schedule[i]
time1, temp1 = self.schedule[i+1]
frac = (ts - time0) / (time1 - time0)
setpoint = frac * (temp1 - temp0) + temp0
self.pid.setPoint(setpoint)

print "In epoch %d, elapsed time %f, temperature %f"%(i, ts, setpoint)
if self.simulate:
temp = setpoint + random.gauss(-20, 15)
else:
Expand All @@ -49,7 +48,7 @@ def run(self):
pid_out = self.pid.update(temp)
if pid_out < 0: pid_out = 0
if pid_out > 1: pid_out = 1
self.regulator.set(pid_out)
self.regulator.set(pid_out, block=True)

time.sleep(self.interval - (time.time()-now))
except:
Expand Down
6 changes: 3 additions & 3 deletions kiln/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Stepper(threading.Thread):
[0,0,1,1],
[1,0,0,1]]

def __init__(self, pin1=5, pin2=6, pin3=13, pin4=19, timeout=5):
def __init__(self, pin1=5, pin2=6, pin3=13, pin4=19, timeout=1):
self.queue = Queue.Queue()
self.finished = threading.Event()

Expand Down Expand Up @@ -137,7 +137,7 @@ def stop(self):


class Regulator(object):
def __init__(self, maxsteps=4500, minsteps=2400, speed=150, ignite_pin=None, simulate=False):
def __init__(self, maxsteps=4500, minsteps=2480, speed=150, ignite_pin=None, simulate=False):
"""Set up a stepper-controlled regulator. Implement some safety measures
to make sure everything gets shut off at the end
Expand Down Expand Up @@ -180,7 +180,7 @@ def ignite(self, start=2800, delay=1):
time.sleep(delay)
if self.ignite_pin is not None:
GPIO.output(self.ignite_pin, False)
self.stepper.step(self.min - start, self.speed)
self.stepper.step(self.min - start, self.speed, block=True)
self.current = self.min
print "Done!"

Expand Down

0 comments on commit 3cb20a0

Please sign in to comment.