br3ttb/Arduino-PID-Library — pull request #7 by bundgus (2013-02-22 04:08:46+00:00)
Title: Some adaptations for temperature control

Thanks for sharing your great PID library. It has been great motivation for my first Arduino project, for slow cooking temperature control.

I found that things worked pretty well out of the box, but I did make a few changes that helped for slow changing systems like electric smokers and rice cookers so I thought I would offer the changes back.

* The noise in temperature measurements seemed to create spikes in derivative feedback, so I modified the Kd calculation to use the average of the last 5 measurements.

* The response time and lag to heating input is very long for an electric smoker, up to 15 minutes. However, the integral gain needed to offset heat loss at temperature is needed. To overcome this issue I modified the ITerm calculation so it does not accumulate during the long initial heating period when Kp + ITerm is already at maximum.

* During normal operation the lid to a smoker or slow cooker may be opened to unload or check food. To avoid over-running the set temperature due to accumulator wind up, I added a method to completely clear the ITerm. In retrospect, this is probably mostly a duplication of the initialize function, that could be used through the setmode method.

Hopefully these are useful points for anyone using PID control for slow cycle time cooking.