PID algorithm for heater control

Related to the development libraries, released by Curt Binder
Post Reply
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

PID algorithm for heater control

Post by AlanM »

As far as I know every controller out there just switches heaters on and off. On if the temp is below the low set point, off if it's above.

Would anyone be interested in a function for Reef Angel that would use a PID type algorithm to try to keep the temp fixed at a set value instead of working in a sawtooth type pattern where it ramps up, then drops, then ramps up, etc.

It would probably be along the lines of this one: http://playground.arduino.cc/Code/PIDLibrary

I'd also maybe add some sampling and averaging in there for the measured temperature to make it less noisy too.

One consequence would be that it would cycle the heater on and off much more often, adding small amounts of heat to keep it riding around a fixed temp. Would that damage the relays? I think the heaters would be fine with it. In fact it would be better on them if they didn't run full-out for long periods of time.

What do folks think?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: PID algorithm for heater control

Post by lnevo »

I have a .5 degree hysteresis and yes I get a sawtooth pattern, but I think based on what i read on the link that it would always be the case and that other "unpredictable" variables like outside temperature, evaporation rates, etc would make prediction tricky. It would be cool, I'm interested in seeing if there's a real benefit and would use it for sure if that were the case. The only thing is that my heater beeps when it turns on, so if it beeps too much, I'd have to change back...
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: PID algorithm for heater control

Post by AlanM »

haha. Beep beep beep beep beep beep beep.

I modified my espresso maker for PID control rather than the snap-action button thermostat it was using previously and the PID I used, a Fuji PXR3, had a cycle time of 1 second, so it would cycle the heat on and off each second. Probably not really what you want.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PID algorithm for heater control

Post by rimai »

PID is a method to control a variable output and not a relay.
Although you can fake it to use a relay, it would nothing more improved than using a really small hysteresis IMO.
Roberto.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: PID algorithm for heater control

Post by AlanM »

Right. We used it with the espresso machine on a solid state relay and cycled it on and off. They had a version which did variable output, but we didn't use that one.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: PID algorithm for heater control

Post by lnevo »

How about a variable output controlled heater? Can we do something with PWM or I2C and make a more efficiently controlled heating element?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PID algorithm for heater control

Post by rimai »

The idea of the "fake" PID that I mentioned above is some sort of PWM variation.
You basically put the heater on a PWM signal, but at a very slow frequency. PWM we use is around 500Hz, which means one pulse every 2ms. If you increase this 2ms to let's say 5s, you would get 0.2Hz PWM signal.
So, the heater would be controlled by a PWM signal at a very slow frequency and thus you can make it so it looks like a variable output.
Roberto.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: PID algorithm for heater control

Post by AlanM »

rimai wrote:The idea of the "fake" PID that I mentioned above is some sort of PWM variation.
You basically put the heater on a PWM signal, but at a very slow frequency. PWM we use is around 500Hz, which means one pulse every 2ms. If you increase this 2ms to let's say 5s, you would get 0.2Hz PWM signal.
So, the heater would be controlled by a PWM signal at a very slow frequency and thus you can make it so it looks like a variable output.
Yep, that's what my espresso machine did. Longer "pulses" when it called for more of a delta. Actually, PID was good for holding a steady temp, but it really shined when you want to do a delta in temp, like from coffee brewing temp to milk steaming temp, without vastly overshooting the temp you were looking for. It would begin shutting off the heater ahead of reaching the set point so that you would converge on the right temperature quickly.
Post Reply