www.ptscoffee.com: without the love, it's just coffee

Coffee guy's oversimplified guide to setting your PID

Beginner or pro barista, all are invited to share.

Link to "Coffee guy's oversimplified guide to setting your PID"by 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
 
Posts: 4989
Joined: May 23, 2005
Location: Downingtown PA

Link to "Coffee guy's oversimplified guide to setting your PID"by 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: 9895
Joined: Apr 29, 2005
Location: Cary, NC
www.paradiseroasters.com: passion for coffees of distinction and quality
www.paradiseroasters.com: passion for coffees of distinction and quality

Link to "Coffee guy's oversimplified guide to setting your PID"by 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: 1646
Joined: Oct 28, 2005
Location: Idaho

Link to "Coffee guy's oversimplified guide to setting your PID"by 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: 405
Joined: Jun 11, 2006
Location: Lexington, KY

Link to "Coffee guy's oversimplified guide to setting your PID"by 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

Link to "Coffee guy's oversimplified guide to setting your PID"by 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
 
Posts: 4529
Joined: May 05, 2005
Location: Chicago

Link to "Coffee guy's oversimplified guide to setting your PID"by 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
Schectermatic, the oldest, most trusted brand of espresso grinder shnozzola
User avatar
AndyS
 
Posts: 895
Joined: May 05, 2005
Location: NY

Link to "Coffee guy's oversimplified guide to setting your PID"by 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: 405
Joined: Jun 11, 2006
Location: Lexington, KY

Link to "Coffee guy's oversimplified guide to setting your PID"by 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
Schectermatic, the oldest, most trusted brand of espresso grinder shnozzola
User avatar
AndyS
 
Posts: 895
Joined: May 05, 2005
Location: NY

Link to "Coffee guy's oversimplified guide to setting your PID"by 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
 
Posts: 4989
Joined: May 23, 2005
Location: Downingtown PA

Link to "Coffee guy's oversimplified guide to setting your PID"by JimG on Sun Jun 07, 2009 10:58 am

cannonfodder wrote: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.

The previous discussion about increasing grouphead temps was limited to Silvia's. That machine has an offset group and no thermosiphon.

The problem does not exist to nearly the same degree on high performance single boiler machines with E-61 groups. The testing I performed a few years back on the Alexia, and the testing I performed more recently on the Alex Duetto, shows that closely spaced shots do not create this overheating problem. Setting up a PID to recover quickly and maintain nearly flat line boiler temps is of value on this type of machine.

cannonfodder wrote:If you want to get real picky, the ambient temperature would need monitored as well.

I have found this to be helpful on my own Alexia. It is not very difficult to do. I have my PID programmed with a 23F offset, which I find is just right at ~75F. When the thermometer on the kitchen wall reads below 72F, I increase the offset by a degree, which bumps up both the boiler and the group temp. Likewise, when 78F or above, I decrease the offset. Really not very difficult or inconvenient.

cannonfodder wrote:I don't see any real benefit to putting a PID on a heat exchanger machine or a machine with an E61 group.

For the case of a high performance single boiler with an E-61 group, I completely disagree. Those machines (Isomac Zaffiro/Amica, Quickmill Alexia, VBM Domobar, etc.) are poster children for the benefits of PID control.

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

Link to "Coffee guy's oversimplified guide to setting your PID"by cannonfodder on Mon Jun 08, 2009 12:05 am

A PID for a single boiler machine under normal home conditions would make temperature management much better than something like an old school thermostat, I am not disputing that. My thoughts are specifically about a E61 grouped single boiler machine with an un-home like duty cycle. Any machine worth its muster should be able to pull a stable and repeatable temperature profile with shots spaced out every 3-5 minutes. But if you are pushing the limits and running a high volume back to back cycle that group is going to heat up. Eventually you are going to loose the heat sink effect you are getting from that big mass of brass and your temperatures are going to shoot up.

With a duty cycle of say one shot every 60-90 seconds with 8-10 shots you are going to start cooking coffee. How would you go about compensating for that rise beyond the obvious, don't run it that hard answer.
Dave Stephens
User avatar
cannonfodder
 
Posts: 4989
Joined: May 23, 2005
Location: Downingtown PA

Link to "Coffee guy's oversimplified guide to setting your PID"by rama3i on Thu Jun 11, 2009 11:52 pm

cannonfodder wrote:A PID for a single boiler machine under normal home conditions would make temperature management much better than something like an old school thermostat, I am not disputing that. My thoughts are specifically about a E61 grouped single boiler machine with an un-home like duty cycle. Any machine worth its muster should be able to pull a stable and repeatable temperature profile with shots spaced out every 3-5 minutes. But if you are pushing the limits and running a high volume back to back cycle that group is going to heat up. Eventually you are going to loose the heat sink effect you are getting from that big mass of brass and your temperatures are going to shoot up.

With a duty cycle of say one shot every 60-90 seconds with 8-10 shots you are going to start cooking coffee. How would you go about compensating for that rise beyond the obvious, don't run it that hard answer.


IMHO, then its time to add another PID, or use PID with multiple input. AFAIK there are lots of Industrial grade PID that has more than one thermocouple input to determine the temperature. The other thermocouple is placed in the group head to force PID to hold the boiler to re heat and avoid overshoot in the group head. The result is more stable group head, and minimize the chance to get overshoot in the high volume environment.
rama3i
 
Posts: 6
Joined: Apr 20, 2009
Location: Bali

Link to "Coffee guy's oversimplified guide to setting your PID"by Stuggi on Wed Oct 28, 2009 8:57 am

How do you go about adding that input? Since the group head might be at such different temperatures during the span of a session, how do you keep the PID from overcompensating for a cold group? In my mind you would need to just set it as a maximum point, so that the PID only regulates with that input in mind if the group is too hot, not too cold. Still, since I haven't used a PID I might be overthinking this. :D

A couple months ago I had an idea for the ideal machine, a triple boiler one if you will. The idea would be to have a steam, a brew and a group head boiler. The group head would have a saturated loop from the group head boiler, which would be controlled by a PID to achieve optimum temperature, but the probe for it would be in the group head. The heating loop in the group head would have a small circulation pump to keep the heated water flowing, and the group and boiler would have sufficient mass to flatten out the temperature curve as well. Then you would PID the brew water boiler as well, but this water would just enter through a pipe inside the saturated group head and exit the head as fast as possible, much like LM has done it, except that this design could be much more flexible as the group head doesn't have to be physically attached to a boiler. The downside is that you now have two PIDs, three boilers and more plumbing than an average house to deal with, which would add to the cost of the machine making it quite unpractical to make, but it would indeed be a very controlled environment. Maybe one could modify a E61 to accept the forced loop instead of the thermosyphon, and then make a one off, since the only complicated part to make is the group head, all other parts could either be made from scratch or bought off the shelves.
Sebastian "Stuggi" Storholm
LMWDP #136
User avatar
Stuggi
 
Posts: 432
Joined: Aug 06, 2007
Location: Jakobstad, Finland

Link to "Coffee guy's oversimplified guide to setting your PID"by CRCasey on Wed Oct 28, 2009 10:39 pm

I guess I have a common question that is never answered, what happens with the controller and the boiler when you select to do an auto tune?

I am guessing that you get to a stabilizing point for the probe, followed by several cycles of ramp up, then a ramp down in temp.

Then you use those delta numbers to figure out a set of PID constants for that boiler/probe system. Is this anywhere near correct?

-Cecil
Black as the devil, hot as hell, pure as an angel, sweet as love:LMWDP#244
User avatar
CRCasey
 
Posts: 597
Joined: Jan 20, 2009
Location: Lewisville, TX

Link to "Coffee guy's oversimplified guide to setting your PID"by Stuggi on Thu Oct 29, 2009 7:03 pm

Yeah, that's about how I've understood it. The PID measures the time it takes for the boiler to warm up, how it responds to heating and cooling and stuff. Basically the crucial measurements should in my mind be how quickly it heats up (heat absorption over time) and how quickly it cools down (heat dissipation over time). Then it calculates the numbers needed to work the P, I and D controls. Differences in water levels and suchlike should be compensated quickly enough by the different controllers that it shouldn't make a difference.
Sebastian "Stuggi" Storholm
LMWDP #136
User avatar
Stuggi
 
Posts: 432
Joined: Aug 06, 2007
Location: Jakobstad, Finland

Link to "Coffee guy's oversimplified guide to setting your PID"by shadowfax on Thu Oct 29, 2009 9:24 pm

CRCasey wrote:I guess I have a common question that is never answered, what happens with the controller and the boiler when you select to do an auto tune?

I am guessing that you get to a stabilizing point for the probe, followed by several cycles of ramp up, then a ramp down in temp.

Then you use those delta numbers to figure out a set of PID constants for that boiler/probe system.


Auto tuning PID parameters is an application of an iterative algorithm that converges to optimum values of P/I/D. I presume it's similar to what you describe other than that I bet it guesses, applies, evaluates and refines each cycle until either it calculates no (or minimal) parameter change or it reaches a limit of iterations and determines that it's not influencing an environment that can converge (like, say, if you forgot to connect the element), in which case it gives up. That being as opposed to iterative observations followed by a single calculation of the parameters.

But I'm just guessing. I am sure you could do it either way. I know from the Fuji PXR-3 manual, though, that the tuning does have a limit of iterations before it bails out.

Of course, if you're auto-tuning the news, it goes like this: 1) click play. 2) laugh.

Nicholas Lundgaard
User avatar
shadowfax
 
Posts: 2196
Joined: May 04, 2005
Location: Houston, TX


Return to Tips and Techniques