# HG changeset patch # User darius # Date 1191032604 0 # Node ID 860936fab75f943b4d01448604d798e719d3408b # Parent a51f78d44552a0f2f41c10a0c332ac788f319c3e Support overshooting on heating/cooling. diff -r a51f78d44552 -r 860936fab75f beermon.py --- a/beermon.py Fri Sep 28 13:05:11 2007 +0000 +++ b/beermon.py Sat Sep 29 02:23:24 2007 +0000 @@ -4,7 +4,7 @@ # Monitor & control fermenter temperature # v1.0 # -# $Id: beermon.py,v 1.5 2007/09/28 13:05:11 darius Exp $ +# $Id: beermon.py,v 1.6 2007/09/29 02:23:24 darius Exp $ # # Depends on: Python 2.3 (I think) # @@ -83,6 +83,7 @@ # Work out what state we should go into nextState = "-" + # Temperature diff, -ve => too cold, +ve => too warm diff = self.m.temps[self.m.fermenterId] - self.targetTemp if (self.m.currState == 'idle'): # If we're idle then only heat or cool if the temperate difference is out of the @@ -93,12 +94,12 @@ elif (diff > 0 and self.m.minHeatOffTime + self.m.lastHeatOff < time.time()): nextState = 'cool' elif (self.m.currState == 'cool'): - # Go idle as soon as we can, there will be overshoot anyway - if (diff < 0 and self.m.minCoolOnTime + self.m.lastCoolOn < time.time()): + # Work out if we should go idle (based on min on time & overshoot) + if (diff + self.m.minCoolOvershoot < 0 and self.m.minCoolOnTime + self.m.lastCoolOn < time.time()): nextState = 'idle' elif (self.m.currState == 'heat'): # Ditto - if (diff > 0 and self.m.minHeatOnTime + self.m.lastHeatOn < time.time()): + if (diff - self.m.minHeatOvershoot > 0 and self.m.minHeatOnTime + self.m.lastHeatOn < time.time()): nextState = 'idle' else: # Not possible.. @@ -136,6 +137,10 @@ minHeatOnTime = 60 minHeatOffTime = 60 + # minimum to overshoot on heating/cooling + minHeatOvershoot = 1 + minCoolOvershoot = 0 + # Dictionary of sensor IDs & temperatures temps = {} # Dictionary of sensor IDs & epoch times @@ -330,7 +335,7 @@ log = initLog() log.debug("=== Initing ===") - log.debug("$Id: beermon.py,v 1.5 2007/09/28 13:05:11 darius Exp $") + log.debug("$Id: beermon.py,v 1.6 2007/09/29 02:23:24 darius Exp $") m = None exitCode = 0