How to: Use PID for cooking

PID is a great and versatile control mechanism, but with limitations in cooking applications due to:

  1. Certain foods being sensitive to fluctuating temperatures, and
  2. Inconsistencies of control variable/heat output relationships in some heating methods.

Here are useful applications and adaptations to PID, should you need temperature control in your cooking project.

Where it’s limited—foods sensitive to fluctuations, e.g. PID for sous vide.

Prototype PID controller

Because I accumulates while getting to temperature, a plain PID will inherently require going over temperature to reach balance. This is disastrous if you’re cooking proteins sous vide. There are two things you can do to minimize this:

1. Set a temperature threshold for your process variable, under which you bypass your PID loop and max your control variable.

2. Set another temperature threshold for your process variable, over which you go through your PID loop, but zero your control variable.

This is essentially hybridizing a bang/bang control into your PID. #1 prevents I from accumulating until you reach the lower threshold, while #2 minimizes time in overshoot at the upper threshold.

This does require knowing a bit about your system to determine appropriate lower and upper thresholds. In the case of my sous vide build, I calculated the expected temperature change over time given the volume of water and the wattage of my heating element (an old rice cooker), and set the lower threshold 7°F under setpoint, with the upper threshold set at 0°F over setpoint.

Where it’s bad—foods sensitive to fluctuations, and an inconsistent control variable/output relationship, e.g. PID for a smoker/barbecue controller.

Prototype smoker controller

Managing a wood or charcoal fire with a plain PID is problematic on multiple fronts.

  1. When the fire is just starting, it requires a lot of air to output very little heat, and when the fire is going steady, it requires considerably less air to output a lot of heat—No one P coefficient can manage that.
  2. Overshooting the target temperature too much will catch additional fuel and require choking off air, which together can yield incomplete combustion and creosote on your food.
  3. At low-and-slow barbecue temperatures, fluctuations inherent in PID or an inability to hold precise temperature due to the above can throw off cook time by hours.
  4. Periodic disruptions of opening the lid or door.

What’s needed is to provide the exact amount of air to hold the setpoint, given the exact conditions of the fire at any given point. I mentioned that no one P coefficient can manage that, and the solution I came up with is to not rely on one fixed P, but rather, to constantly tune P. In conjunction with a very low I coefficient and a large enough D coefficient to damp sudden changes, I made a system that can hold +/- 1.5°F, torture tested with a fuel mix of charcoal, seasoned wood, green wood and pellets (picture above). Put simply:

1. If it is going to overshoot, dial down P and clear some of the accumulated I offset to avert overshoot.

2. If it’s under temperature and fluctuating, dial up P.

Where PID works fine—fixed control variable/output relationship, with food indifferent to fluctuations, e.g. PID for Raclette.

Prototype Raclette cheese melter

It’s not always so complicated. A scavenged electric heating element has a fixed control variable/output relationship, and Raclette is largely indifferent to temperature fluctuations, since melting cheese can be done at a wide range of temperatures.

If those two conditions are met, then it’s just a matter of picking good PID coefficients.