On Thu, 25 Dec 2008, cdb wrote: > I have been asked to alter one of my temperature controller projects > to work as an egg incubator. I need to implement a better heater > control mechanism. > > I have decided not to use a PID algorithm as I have no way of knowing > the placement of sensors, heater or even size of enclosure, so I > decided to use a rate of change self calibration method, I have found > some example code for an oven, which is a commercial product and > should work. I understand what the code is trying to do, I just don't > understand where the constants they've used have come from. The code > note just states //25 * 4 = 100 deg C. Which as you will see doesn't > appear correct. The code: > > deltaT = ((3 x deltaT) + ((read_temp() - tmp) x 25))/4 > > Ok tmp contains the previous temperature measurement. The divide by 4 > is due to the original circuit using a Maxim thermocouple IC so a > reading of 400 = 100 deg C - this will be superfluous as I'm not using > a thermocouple. > > I cannot work out what the x25 is for or where they get the 3 x I'm > assuming this is a form of digital filtering and scaling, I also think > this code would surely fail if the readings were ever zero. All > variables are signed ints. > > The above code is called at a constant time beat so the rate of change > time component is taken care of. > > Or perhaps is there another method I should think of? > > Thanks > > Colin The x25 looks like it's just scaling the measurement. look at it like this: new_temp = read_temp() new_deltaT = (new_temp - old_temp) * scale deltaT = (deltaT * 0.75) + (new_deltaT * 0.25) old_temp = new_temp NOTE: that 0.75 + 0.25 == 1.0, as you increase 0.75 towards 1.0 and decrease the 0.25 towards 0 the new_deltaT is having a smaller effect on the calculation of deltaT, so yes deltaT is being filtered Regards Sergio Masci -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist