Doubling Down on PIDs
/By Michael Teahan
Controlling temperature is critical to consistent results, and we have gotten pretty obsessed with just how precise we want to be. For decades, machines were controlled by steam pressure, the link between temperature and pressure fluctuations was extremely tight but the latency of the pressure switch made for deviations of multiple degrees. The mechanical design of the machines sought to minimize some of that impact, but drilling down on the impact of grind, pressure, flow, and temperature on coffee required more precision on all counts.
Even multi-boiler machines with mechanical temperature switches had latency issues. They were either all on or all off, operating between two narrow set points. Proportional Integral Derivative (PID) controllers attempt to control temperature without the narrow setpoint band. A properly-tuned PID controller uses math and memory to regulate temperature to within tenths of a degree.
What a PID Actually Does
To understand how PID controllers work, we have to address some of the problems they try to fix. Heating elements are different sizes, have different surface areas, and heat at different rates. This effects how quickly they respond to power and increase the hysteresis of the setpoints. Hot elements can overshoot while low powered elements are slower to recover. What begins as a two-degree dead band gets worse because of the latency.
The first bit of magic a PID controller does is essentially convert a fixed power heating element to a variable one. By pulsing the power through a solid-state relay, the element is able to provide full heating capacity for heat and recovery while throttling it back as it approaches its target to reduce overshoot. This is the Proportional (P) aspect of the controller.
The controller samples the actual temperature of the sensor and compares it to the target. The difference is the “error” it is trying to mitigate. How aggressively it seeks to correct that error is where the programming comes in. If it's too aggressive, it can overshoot in much the same way as a standard mechanical controller. If too timid, it won’t recover temperature quickly enough.
Because the Proportional program applies power as a percentage of the error between the sample and the target, it never really gets rid of the error. For the Proportional programming of the controller to work, there has to be a difference between the target and the sample (sensor temperature). While effective at approaching the target, proportional control isn’t designed to hit it.
This is where the Integral (I) part of PID controllers come into play. The controller actually looks back at how the Proportional program has reached its target and how it responds to the error. It uses this data to calculate the power required to more precisely hit its temperature target, driving the controller to essentially ignore the error and drive it to the set-point. When the controller sees an error, it uses the Proportional program to recover and once it approaches the target the Integral program takes over to increase accuracy and drive the error to zero.
Even with all of this math, there are issues. Because the Integral program isn’t trying to eliminate the error so much as pushing past the Proportional programming to actually hit it, the Integral programs have a tendency to overshoot the target.
The last part of the PID controller is the Derivative (D) function, which slows the corrective action of the Integral program to reduce this overshoot. When properly setup, the PID controller will accurately hit its set point and pulse the element to maintain its temperature.
Most controllers are able to program these settings on their own during a learning phase, but you can override the parameters like duration and timing of the pulses to tweak the results.
Caveats
PID controllers have solved everything and now temperatures are stable, so what can go wrong?
Espresso machines are complex pieces of equipment with lots of mass, surface area, heat inhibiting, and conductive materials and water, which kind of sucks at transferring heat. You can measure the temperature at a dozen different locations in a machine and get different results at each one. PID controllers are designed to control the temperature of the sensor, not at the group, portafilter, boiler, or element. Placement of the sensor is tricky because the closer you are to the outlet, the further you are from the source of heat. By the time the sensor sees the chilling effect of cold water entering the circuit might be too late to respond.
This is where the illusion of temperature precision comes in. This is the offset. Because the controller is measuring the temperature at the sensor and not the outlet, the offset is a calculation of the difference between what the sensor is reading and what the outlet temperature should be based upon the physical design of the machine. This physical design of the machine is the same used by traditional old school machines to smooth out temperature fluctuations with precise controls.
Because the sensor temperature may not be indicative of outlet temperature, the program is tweaked to fool you into thinking that the temperature displayed is what you are actually delivering. A little smoke and mirrors. Set up properly, it’s damn close and still ridiculously stable, but it isn’t what you think it is.
The second issue with PID controllers is that while they are in some respects proactive at maintaining temperature, they are not designed to react to abnormal fluctuations. If you never pulled a shot, PID’s would be perfect. As loads on the machines fluctuate between continuous use and extended periods of rest, the PID controller uses the same program. It doesn’t have an ability to react to unanticipated loads and all the math it uses to control one scenario is useless for another.
The third thing PID controllers can’t do is temperature profile. They are really good at maintaining a target, but if brewing a perfect shot of espresso means starting the extraction at one temperature and reducing it during the pour, PIDs are confused. Even if you program a little latency into the system by programming or design, the profile is dependent upon flow. Single shots (God forbid anyone pours a single), doubles and longer pours have different rates for profiling, and PID’s can’t handle it.
And if you flush between shots (which is sometimes advised against), the controller has no idea what you are doing.
Really controlling temperature requires that the machine and the temperature controller work together to proactively anticipate temperature demands and use multiple profiles to ensure accuracy. It's conceivable you could even profile shots to a degree by integrating them into the controller.