diff --git a/kiln/PID.py b/kiln/PID.py index a4450fa..fac8f54 100644 --- a/kiln/PID.py +++ b/kiln/PID.py @@ -20,7 +20,7 @@ class PID(object): # """ - def __init__(self, P=2.0, I=0.0, D=1.0, Derivator=0, Integrator=0, Integrator_max=500, Integrator_min=-500): + def __init__(self, P=2.0, I=0.0, D=1.0, Derivator=0, Integrator=0, Integrator_max=2000, Integrator_min=-2000): self.Kp=P self.Ki=I diff --git a/kiln/breakout.py b/kiln/breakout.py index 292b0db..6dbfbef 100644 --- a/kiln/breakout.py +++ b/kiln/breakout.py @@ -35,7 +35,11 @@ class Breakout(object): def _set_cmd(self, cmd, value, fmt='f'): out = map(ord, struct.pack('<'+fmt, value)) - self.bus.write_i2c_block_data(self.addr, ord(cmd), out) + while True: + try: + return self.bus.write_i2c_block_data(self.addr, ord(cmd), out) + except IOError: + pass @property def motor(self): diff --git a/kiln/manager.py b/kiln/manager.py index 376f1d4..ef27e76 100644 --- a/kiln/manager.py +++ b/kiln/manager.py @@ -65,7 +65,10 @@ class Manager(threading.Thread): def notify(self, data): if self._send is not None: - self._send(data) + try: + self._send(data) + except: + pass else: logger.info("No notifier set, ignoring message: %s"%data) @@ -109,7 +112,7 @@ class Manager(threading.Thread): class Profile(threading.Thread): """Performs the PID loop required for feedback control""" def __init__(self, schedule, therm, regulator, interval=1, start_time=None, callback=None, - Kp=.025, Ki=.01, Kd=.001): + Kp=.03, Ki=.015, Kd=.001): super(Profile, self).__init__() self.daemon = True diff --git a/kiln/server.py b/kiln/server.py index 9efbd44..6ee6750 100644 --- a/kiln/server.py +++ b/kiln/server.py @@ -131,7 +131,7 @@ class WebApp(object): if __name__ == "__main__": try: import manager - kiln = manager.Manager(simulate=True) + kiln = manager.Manager(simulate=False) app = WebApp(kiln) kiln._send = app.send diff --git a/kiln/stepper.py b/kiln/stepper.py index ccc6d92..c22aae9 100644 --- a/kiln/stepper.py +++ b/kiln/stepper.py @@ -244,7 +244,7 @@ class Regulator(threading.Thread): pass class Breakout(object): - def __init__(self, addr, maxsteps=4500, minsteps=2100): + def __init__(self, addr, maxsteps=6500, minsteps=2300): import breakout self.device = breakout.Breakout(addr) self.min = minsteps @@ -255,15 +255,17 @@ class Breakout(object): self.off() atexit.register(exit) - def ignite(self, start=2500, delay=8): + def ignite(self, start=2500, delay=5): logger.info("Igniting system") + self.device.ignite = 127 + time.sleep(2) self.device.ignite = 255 time.sleep(delay) self.device.motor = start while self.device.motor != start: time.sleep(.1) self.device.motor = self.min - self.device.ignite = 127 + #self.device.ignite = 127 @property def output(self): diff --git a/kiln/thermo.py b/kiln/thermo.py index e70b6eb..87c1655 100644 --- a/kiln/thermo.py +++ b/kiln/thermo.py @@ -86,8 +86,8 @@ class Breakout(object): def get(self): time.sleep(.25) temp = self.device.temperature - self.last = time.time() - if not isnan(temp) and abs(temp - self.history[-1]) < 10: + if not isnan(temp) and len(self.history) < 1 or abs(temp - self.history[-1]) < 15 or (time.time() - self.last) > 5: + self.last = time.time() self.history.append(temp) return self.temperature