Bug fixes from last firing

master
James Gao 2014-12-17 06:34:47 +00:00
rodzic 7d8d5aa445
commit c1208f0e60
6 zmienionych plików z 19 dodań i 10 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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):

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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):

Wyświetl plik

@ -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