www.seattlecoffeegear.com: let us help you find the right gear

Coffee guy's oversimplified guide to setting your PID

Postby cannonfodder on Wed Jun 03, 2009 9:14 pm

In response to bluefaces question about Auberins PID settings for a Rancilio Silvia thought I would butcher up an attempt at explaining a PID.

Well if you really want to medium dive into PID's let me see if I can explain a few things whilst I puff on my cigar (Rocky Patel Sun Grown this evening). FYI, this is all book and none practical knowledge. I have not had need for a PID on any of my machine.

PID is an acronym for Proportional Integral Derivative. The fuzzy logic on the PID should make it as simple as set a temp and let it run. It will figure out what it needs to do. But you can override the P, I and D settings to performance tune your machine. The error is equal to the set point minus the measurement of the thermocouple.

The Proportional band is proportional to the error measurement (set temperature minus actual temperature) essentially your margin of error. The Integral portion controls the response time of the heater in response to the Proportional band. I am set at 205.6, my probe says the medium being monitored is 205.4. Ooops, that is out of my Proportional band range (error), I need heat. Or reversely, my temp setting is 205.6 and the medium being monitored is 205.9, oops, time to stop. Now I sit here while my temperature carries over another 1.0 degrees and then starts to fall. Ooops, now I am at 205.4 again, time to heat, over and over and over. Little more than a thermostat at this point.

Now the I comes in, Integral action. Basically a measurement of time. So now I can compensate for time error in the above loop. So now my little brain says Ok, you want me to run at 205.6, I am at 205.2. You want me to heat this stuff back to 205.6 but not go over (reverse the process for cooling). So I know that if I apply heat for 1 divided by I (lets say 0.6 seconds) I will heat the stuff to 205.5 but I know there will be carry over heat for another 0.5 seconds so I will turn off the heater even though I am under the error margin and the temperature will coast up to 205.7 and stop instead of running up to 206.9.

Now the Derivative jumps into the party. Basically doing the opposite of the above action. Ok, you told me to run at 205.6, I heat for 0.x seconds and turn off I know my temperature will stop at 205.5 and my end error will be 205.7. Now I sit here. Oops, I am back at 205.2, time to juice it up again. But I know that if I heat for 0.x seconds once I am beyond my margin of error I will get where I want to be. Hmm, but I know I am going to cool Z fast so instead of waiting until I get past my error setting I am going to kick in the juice to minimize the drop.

So P tells the brain I am beyond my error margin. I, tells the brain how long to apply juice before I need to turn off to keep a tighter band and D tells the brain how long to wait after before I give it more juice to keep the temperature from falling too much.

This is very simplified, the complicated stuff gives me a headache. Do a Google on PID loop tuning if you want the deep dive.
Dave Stephens
User avatar
cannonfodder
Team HB
 
Posts: 7724
Joined: May 23, 2005
Location: Downingtown PA

Postby HB on Thu Jun 04, 2009 1:07 am

cannonfodder wrote:This is very simplified, the complicated stuff gives me a headache. Do a Google on PID loop tuning if you want the deep dive.

Thanks for the quick explanation. To round out the above, a few references are linked from Good all round explanation of PID stuff.
Dan Kehn
User avatar
HB
 
Posts: 14244
Joined: Apr 29, 2005
Location: Cary, NC

Postby Ken Fox on Fri Jun 05, 2009 1:08 am

Some time ago I had a very long telephone conversation with Andy Schecter about tuning PIDs in espresso machines. As some here might know, Andy actually uses this technology in his work, and as a result is more familiar with how these controllers work than is your average espresso machine hacker.

At the time of the phone call, I was discussing with Andy the relative merits of further adjusting the PID settings that one would obtain from simply using the autotuning function of a PID, in this case, a Fuji PXR1.

Andy opined that I could waste a lot of time fiddling around with the parameters, but in the end he would be very surprised if it made any perceptible difference in temperature stability of the boiler in my espresso machine, at all, or if I'd be able to measure any improvement no matter what I did.

After doing extensive fiddling with the PIDs in both of my Cimbali Juniors, I have to agree with Andy; you can waste a lot of time modifying the results of an autotune, but it is very unlikely that whatever you do will have any real benefit over the simple autotune that you can get from most or all PID controllers. There are theoretical reasons for believing that you can improve the autotune values, but if your criteria for benefit is measurable improvement of temperature stability, either in boiler or in shot temperatures, you are very unlikely to see any improvement no matter what you do to the autotune values.

ken
What, me worry?

Alfred E. Neuman, 1955
Ken Fox
 
Posts: 2453
Joined: Oct 28, 2005
Location: Idaho

Postby JimG on Fri Jun 05, 2009 1:56 am

Ken Fox wrote:.... but it is very unlikely that whatever you do will have any real benefit over the simple autotune that you can get from most or all PID controllers....

Generally, I agree with this, particularly in the case of PID control of steam boilers on HX machines. The PID algorithm is pretty robust and converges well even if the parameters are not quite optimum.

But when considering a single boiler machine, especially one with a smallish boiler, then tuning for a fast recovery after a shot is also important. From among all P, I, and D combinations that give stable temps at idle, it's better to pick a set that also gets things back under control quickly after a shot.

In my experience, the parameters resulting from autotune do not always give acceptable performance in the latter situation.

Jim
JimG
 
Posts: 651
Joined: Jun 11, 2006
Location: Lexington, KY

Postby w7boxvaio on Fri Jun 05, 2009 9:51 am

If anyone is interested check out "Process Dynamics and Control" (Seborg, Edgar, Mellichamp) for a complete rundown on the theory and operation of PID controllers.
w7boxvaio
 
Posts: 1
Joined: May 28, 2009
Location: Houston

Postby another_jim on Fri Jun 05, 2009 10:46 am

Greg has tried retuning single and dual boiler PID controllers so that they do not stabilize, but rather hunt within the smallest possible range. His contention was that this kept the temperature in a narrower band if you make shots at fast, random intervals. His instruction, IIRC, was to set the proportional control to the lowest amplification (widest band) that caused cycling, leave the I at zero, and set the D out to half the cycle time. In essence, this is close to an on/off control, but with the P and D action set to minimize the dead band.

If you don't understand what I'm saying, don't try it.

I tried it on the Silvia's when I had them, and it did work, but looked extremely weird. If you do this, set the display to read the set point, not the actual.

Also, I tried one Auber controller, made for small espresso machines, which wasn't a PID algorithm at all, but was set up to hunt in this fashion instead.
User avatar
another_jim
Team HB
 
Posts: 8815
Joined: May 05, 2005
Location: Chicago

Postby AndyS on Sat Jun 06, 2009 9:26 am

JimG wrote:But when considering a single boiler machine, especially one with a smallish boiler, then tuning for a fast recovery after a shot is also important....In my experience, the parameters resulting from autotune do not always give acceptable performance in the latter situation.


Thanks for pointing that out. You're undoubtedly correct that some custom tunings can bring the boiler temp back near setpoint faster than typical autotune settings.

OTOH, how much of a difference do such tunings make to (1) delivered brew water temperature, and (2) shot quality?

In the case of (1), there is more to getting consistent brew water temperatures in a smallish single boiler machine than doing a good job controlling boiler temp. As I've droned on previously, even a machine like Silvia is really a heat-exchanger machine: ~225F boiler water is cooled by a ~175F group to produce ~200F brew water. If one pulls shots in rapid succession, the group temperature gets higher and the brew water temp increases even if a stable boiler temp is maintained.

Of course number (2), shot quality, is the only thing that really matters. It would be an interesting experiment to compare two series of shots prepared with a small single boiler machine using two different PID tunings. With a typical (moderately forgiving) blend, could tasters reliably distinguish which shots resulted from which PID tuning? I think Ken and I are pretty skeptical about this.
-AndyS
VST refractometer/filter basket beta tester, no financial interest in the company
User avatar
AndyS
 
Posts: 1059
Joined: May 05, 2005
Location: NY

Postby JimG on Sat Jun 06, 2009 12:52 pm

AndyS wrote:OTOH, how much of a difference do such such tunings make to (1) delivered brew water temperature, and (2) shot quality?

None. A faster recovery is a matter of user convenience and perceived quality.

AndyS wrote:In the case of (1), there is more to getting consistent brew water temperatures in a smallish single boiler machine than doing a good job controlling boiler temp. As I've droned on previously, even a machine like Silvia is really a heat-exchanger machine: ~225F boiler water is cooled by a ~175F group to produce ~200F brew water. If one pulls shots in rapid succession, the group temperature gets higher and the brew water temp increases even if a stable boiler temp is maintained.

Right again. As this graph shows, the boiler temp recovers to a reasonably stable state within 2 minutes of the end of the shot.

Image

But after 4 minutes, the group temp is still 3.5F above its pre-shot stable temp of 197.7F. Ideally, you'd like to have both the boiler and the group fully back to normal within 2 minutes. But getting one of them right is better than none.

AndyS wrote:Of course number (2), shot quality, is the only thing that really matters. It would be an interesting experiment to compare two series of shots prepared with a small single boiler machine using two different PID tunings. With a typical (moderately forgiving) blend, could tasters reliably distinguish which shots resulted from which PID tuning? I think Ken and I are pretty skeptical about this.

Probably well-founded skepticism. But the best chance of higher shot quality, even if its a small chance, is going to come from a well-tuned PID that brings the PV back in line as quickly as possible.

Even though I don't take issue with any of the points you've made, I can't think of any good reason why you would not want to give your machine the best chance possible to avoid problems associated with overshoot and long recovery times. It may not be efficient for one individual to spend hours optimizing the tuning on their PID. But if the time spent in this effort is spread across hundreds of units, and if better tuning can, at worst, improve the machine performance, then I'd argue it's worth doing.

Jim
JimG
 
Posts: 651
Joined: Jun 11, 2006
Location: Lexington, KY

Postby AndyS on Sat Jun 06, 2009 1:15 pm

JimG wrote:Probably well-founded skepticism. But the best chance of higher shot quality, even if its a small chance, is going to come from a well-tuned PID that brings the PV back in line as quickly as possible....I can't think of any good reason why you would not want to give your machine the best chance possible to avoid problems associated with overshoot and long recovery times.


Agree 100%.
-AndyS
VST refractometer/filter basket beta tester, no financial interest in the company
User avatar
AndyS
 
Posts: 1059
Joined: May 05, 2005
Location: NY

Postby cannonfodder on Sat Jun 06, 2009 11:28 pm

IMHO, the problem with an E61 group and a PID is that as mentioned above, pulling shots in rapid succession will heat that big hunk of brass up. Even if your boiler temps are pancake flat, the group is still overheated and your shots start to cook. If you want to get real picky, the ambient temperature would need monitored as well. So you would need a PID with three channels, one for the boiler, another channel to monitor the ambient temperature and the third to monitor the grouphead. That way it could tune down the boiler temp as the group temp increases and compensate for cool/warm days. Or you could just wait 3 minutes between shots.

I don't see any real benefit to putting a PID on a heat exchanger machine or a machine with an E61 group. To get the full benefit, you need a saturated grouphead. A good pressurestat, thermosiphon flow restrictor and a little patience is all I have had need for at home. My very limited PID playing has met with no real improvement; in fact I think I made things worse when I tried to out think the tuneing.
Dave Stephens
User avatar
cannonfodder
Team HB
 
Posts: 7724
Joined: May 23, 2005
Location: Downingtown PA