Mind the toves. They can be a bit slithy. Don't even get me started on the borogoves.

Saturday, March 22, 2008

Temperature problem solved ?

(This post refers to software from the Bare Bones Coffee Controller project by Tim Hirzel on the Arduino playground.)

So, I think I solved the problem with the temp sensing (see previous post). The thing that seems to have done it is to change the update interval to 2x per second from 5x:

#define PID_UPDATE_INTERVAL 500 // milliseconds

I re-read the PID without a PhD article, and it talks about sample rate. Since the boiler heater is a pretty slow-responding system, I figured I would try slowing down the rate that I grab a new temp for the PID process. I haven't changed how often the main loop checks the temp, so in effect, what I have done is increased the sample size that getFreshTemp() uses in averaging temps. But at this point, I don't really care, as long as it works. I'm also doing some extra smoothing with a simple algorithm I grabbed from the Arduino playground:

#define filterVal .2 //between 0 and 1 for smoothing function (small=more smooth)
float accum; //storage for smoothing function

float getFreshTemp() {
latestReading = (tcSum * multiplier / readCount) + 32.0;
accum = (latestReading * filterVal) + (accum * (1 - filterVal)); //smoothing function
latestReading = accum;
readCount = 0;
tcSum = 0.0;
return latestReading;

My performance is great now! The problem with the spikey temps was that they made the D factor essentially useless. Now, I've been able to tune the PID so that it stays within .5 deg +/-.

No comments: