Tuning or Adjusting PID Values

Need help with equipment usage or want to share your latest discovery?
rdenotter

Postby rdenotter » Jul 16, 2018, 10:30 pm

Been lurking for some time, first post... I purchased a used Quickmill Vetrano 2B (about 5 years old) several months ago, and have been doing quite a bit of learning. (My previous machine for 10 years was a NS Mac V but that's a different story.) The Vetrano has been wonderful, once I learned the finer points of getting grind dialed in and tamps even.

One of the things that I wanted to understand better was the programming of the PID, and it took me some time to come up with descriptions of the various functions that actually started to make sense. There were a few posts here that helped, but nothing that I found that really explained what the three (P, I, and D) settings actually controlled or did. With a bit of help from some friends who work in the instrumentation and engineering worlds, and a bit of help from various helpful wiki entries and whatnot, I'd like to offer the following "layman's explanations" for others who may be asking the same questions I did.

The "P" is the proportional control. That setting determines how much electricity to apply to the boiler element, depending entirely on the difference between the actual temperature and the desired temperature. If the difference in temperature is large, a large proportion of the potential capacity of the boiler is called on. If the difference is small, a much smaller proportion of the potential capacity is used. Higher numbers in this value increase the proportion used based on the temperature differential. The unfortunate effect of higher numbers here are that you increase the potential of creating overshoot in the temperature. The unfortunate effect of lower numbers is that it may take longer to get to the desired temperature. (When the actual temperature is higher than the desired temperature, the proportional control simply leaves the element off. So, when the temperature has to climb, less and less heat is created as the temperature approaches the set point. When the temperature has to drop, no proportional control is possible--it just stays off until the set point is reached.)

The "I" is the integral control, which determines how much heat should be applied to the boiler element, depending entirely on how long it has been since the boiler has been at the desired temperature. The longer it's been since the control saw the set point, the more difference this value makes. This value gets calculated by adding up the difference between the current temperature and the desired temperature over time, and doing a mathematical calculation between that and the I-value. If you set too high a value here, the system will overreact to a pause in the temperature change. Too low a number means that the temperature has to be wrong for too long a time before this kicks in and fixes it. (Again, when the actual temperature is higher than the desired temperature, the integral control point simply leaves the element off.) What this control will do nicely, is overcome a proportional setting that is a bit too low--too low a P setting could mean that when the boiler temperature is too low, the proportional adjustment to temperature will never actually apply enough heat to get to the set point. A small I value will sense that the temperature has stopped climbing and nudge it the rest of the way there.

The "D" is the derivative control. That setting is helpful both when the boiler temperature is too low, and when it's too high. The D setting measures the rate of change in the boiler temperature and then applies a counter-balance to the P and I values. So, if the boiler is getting hot fast, and the proportion control isn't backing the electrical current off quite fast enough to prevent an overshoot, the D control will sense that some buffering of the electricity is needed to prevent dramatic overshoot of the temperature. Similarly, if the temperature is too high and falling fast, the D control will actual start cycling the heating element early to slow the fall of the temperature and prevent it from dropping too far.

In all three cases, think of the number you put into the control as an "importance" value, rather than trying to do the math (which is really complex). So, a higher number makes that value more important, and a lower value makes it less important. Just remember that all three values interact in a way that means that changing any one value actually has an effect on all three behaviors (except if you put in a zero.)

The steam boiler in my Vetrano runs with P=1.5, I=0, D=1.5 (factory setting, as far as I can tell.)
Using the above, that tells us that we want some control to slow the heat generated as we start to approach the set point, and some counter balance to ensure that we don't shoot too far over or under. We don't care much about maintaining a temperature if it's a degree or two off the set point (I=0). That makes sense, because we're after lots of steam, and if the temperature starts to drop, we want full power applied to keep the steam pressure up.

(Oddly), the water boiler in the Vetrano ships with similar values, suggesting P=1.5, I=.05, D=1.5.
That would suggest that the only change we make to the above, is to ensure that, if the temperature drops and the P value won't pull it back up quickly, (pulling a shot draws in cold water and keeps pulling in more cold water until the shot is over) we do want to be sure that we get a bit of recovery from the I control. Those values didn't make sense to me, and I wasn't happy with the temperature swings (9 degree F overshoot, 2-3 degree drop in a shot) that was giving me. (Which is what pushed me to do some research!). What I wanted was:
- less overshoot (the first shot was pulling at about 196, the next at about 201 and the rest at 204)
- less undershoot (here's the scenario: you pull a few shots for espressos and americanos, then somebody wants a latte. You steam milk, then pull a shot. That shot is maybe 3-4 minutes behind the previous one. that shot was pulling at 193 and went a bit sour. (Thankfully it was getting hidden with milk and a flavor syrup!)

Much experimentation later, I've ended up with the water boiler at P=1.4, I=.05, and D=20. This is giving me a far better "clamping" on the tendency of the 800 watt element to overheat a .75 litre boiler! I'm seeing temperatures stay well within two degrees F of overshoot, and one degree F of undershoot. Much better! (If your water boiler is bigger, you won't likely need as high a D value.)

The bottom line is, don't be afraid to experiment with these values. You're not going to break anything. If you haven't got the same machine I have, that's fine--the definitions and explanations above are still applicable.

Do yourself one favor: before changing anything, write down the values you started with--that way you can always get back to what you had before you started messing with the numbers! If you like what you had before better than what you have after you change, just put it back the way it was, and no harm done.

Also, from the reading I've done, there are machines that "auto-tune" or run in a "learning mode". I'm not sure that I'd be brave enough to tamper with those. Finally, the explanations above say nothing about how to get initial values into a new PID if yours ships with values that are dramatically different than mine. Again, however, the explanations of what the P, I, and D controllers do is consistent across the whole spectrum.

Hope this helps somebody!
★ Helpful