Tuning PID controllers for use in espresso machines (very long)
- From: "gscace" <gregory.scace@xxxxxxxx>
- Date: 28 Dec 2005 14:16:14 -0800
Hi:
I've been doing some work tuning and retuning espresso machines with
PID controllers and I thought it might be useful to try to write down a
few observations and a methodology that seems to work for me. Since
lots of us use the Fuji PXR series controllers, my comments will be
oriented towards these.
The Fuji controller (and others) can be tuned using the autotune method
that is accessed via keypad, but this is not the best way to tune them.
Usually espresso machines possess powerful heaters that allow them to
quickly recover temperature when brewing or steaming takes place. But
espresso machines do not cool quickly by comparison. The main
mechanism for heat removal is by conduction through the boiler wall,
and then convection into the surrounding environment. There is no
cooling loop with similar power to that of the heating element. So the
heating "transfer function" is different from the cooling transfer
function, and this can make autotuning a second-best method for
optimizing control. Autotuning assumes that you want the most stable
system at a specific temperature setpoint, but that may not really be
the case at all. In espresso machines one can tolerate a bit of
instability in trade for speed of response. And in espresso machines,
the response requirements for brewing / steaming are different than
they are for steady state idling. Unlike idling, when brewing or
steaming we impose high heat loads on the system. The brewing process
includes replacing water in the hx or brew boiler with cold feedwater.
The steaming process includes conversion of liquid water to steam and
periodic replacement of the gaseous water with cold feedwater in order
to maintain sufficient levels of water in the boiler.
Let's now develop an alternative manual tuning method specifically
for espresso machines. For reference, users of Fuji controllers should
download Appendix B of the Fuji PXZ controller manual from TTI
Global's website. This gives instructions for manual tuning of Fuji
controllers, which we can modify for our nefarious purposes. Fuji
controllers used for espresso machines should be configured for the
proper temperature sensor type (parameter P-n2 in block 2), fastest
allowable cycle time (parameter TC in block 2), and should have fuzzy
logic enabled (parameter CTrL in block 2). These and other parameters
are discussed in the PXR3 Operation Manual, also downloadable from TTI
Global's website.
The Fuji controller has 6 parameters that are useful to us in tailoring
the controller to specific machines. Two of them are used to tailor the
temperature scale of the controller to the temperature specifically
used by espresso machines. One parameter sets a maximum setpoint
limit. The three remaining parameters are used to tailor the
controller response to the specific espresso machine.
The Fuji controller comes configured by the factory to measure
temperature over a wide range. For example, if type K thermocouple
with 0.1 degree resolution is selected, the Fuji controller will read
from 32 degrees F to 752 degrees F. Of course we don't ever need to
read 752 degrees. In fact, one important control parameter that we
will adjust is specified as a percentage of the temperature range, so
it pays to reduce this temperature range in order to increase the
tuneability of the temperature controller. By adjusting parameters
P-SL and P-SU (contained in block 2), one can whittle down the
temperature measurement window to a useful range. For my 2-group LM
Linea, I set these values to 50 and 250 degrees F respectively. The
importance of this step will be apparent later.
Block 3 contains parameter SV-H, which limits the maximum temperature
setpoint. This is a useful parameter to set because it prevents you
from inadvertently entering a value that could cause trouble. My Linea
has a thermal cutout that protects the brew boiler from runaway heating
that could be caused by SSR failure in the "On"state. I set my
SV-H parameter to be slightly less than the temperature that would trip
the thermal cutout.
Block 3 contains parameter SV-L, which similarly sets a minimum
temperature setpoint. Since there is no danger from setting a minimum
temperature (except to your poor taste buds), and since one can't
enter a temperature setpoint less than the lower temperature limit
specified by parameter P-SL, I don't bother to set this parameter at
all.
Now we are ready to systematically tune the controller according to
Appendix B of the Fuji PXZ manual with some modification. Parameters
used to tune the controller are P, proportional band, I, integral time,
and D, derivative time. These three parameters are contained in block
2.
The proportional band is the temperature range over which the
controller provides proportional temperature control. The band is
specified as a percentage of the temperature range that was previously
set using P-SL and P-SU. For example, setting P to 1% of a temperature
range from 50 to 250 degrees gives 0.01 * (250 - 50) = 2. In this
example the proportional band extends to +- 2 degrees of setpoint.
The heater will operate in a full-on state at temperatures below
setpoint minus 2 degrees, and there will be no added heat in any
proportion of the cycle at temperatures greater than 2 degrees above
the setpoint.
The integral parameter looks at the actual temperature over a period of
time, compares it to the setpoint temperature, and adjusts the
proportion of heater "on-time" during each cycle so that the
difference between the actual temperature and setpoint temperature is
driven to zero. In a perfectly stable system, the amount of heat that
must be added to the system can be predicted based on temperature
measurement over a very short interval. But espresso machines are not
that stable. Hot water moves in currents within the boiler, and
brewing / steaming upset the apple cart. So it is useful for the
controller to make adjustments to the heater's on time based on
temperature measurements smoothed out over time. The integral time is
adjusted so that the controller is not too sluggish in response to
brewing or steaming, but not so reactive that it jumps to conclusions
based on a very small sample of temperature measurements.
The derivative parameter adjusts the heater on time based on the rate
of change in measured temperature. If the temperature begins to change
quickly, the derivative parameter quickly alters the heater on time
accordingly, and the system appears to "snap" to the setpoint
temperature. This parameter is adjusted so that the controller is
sufficiently reactive to the rate of temperature change over time, but
not so reactive that the system becomes unstable, overreacting to the
slightest indication that temperature is beginning to change.
Tuning the controller is accomplished in three steps. The proportional
band is set first, with integral and derivative turned off. The
integral time is then determined, followed by the derivative. It's
not too hard to do, but it takes patience and a chunk of time. Figure
on several hours of your undivided attention. The well equipped pro at
this will log the temperature of the boiler and plot out the
temperature over time in order to quickly arrive at the right
parameters. Since most of us don't have access to those sorts of
tools, we have to make do. It really helps to have some sort of
indicator light rigged so that you can see if the heater is pulsing on
/ off. Fortunately, many machines are supplied with an indicator light
that tells you when the heater is activated.
Pre-tuning housecleaning: Turn on your espresso machine and dial in an
appropriate temperature setpoint for making espresso. Disable the
integral and derivative functions. On the Fuji, these are disabled by
setting them to zero. Set the proportional band (P) to a very small
value, such as 0.1%
Setting the proportional band: We can tolerate some instability in
temperature because the brew water temperature fluctuations get damped
out considerably on the way to the coffee. So our tuning strategy is
to see how much temperature overshoot the system exhibits, decide how
much overshoot we want to tolerate, and then use this data to establish
the smallest proportional band that we can get away with. This will
allow us to develop a very reactive set of control parameters that
provide maximum heating or cooling until the process temperature is
close to the setpoint, without incurring unacceptable overshoot when
heating.
As configured above, the controller will heat up the espresso machine
with the heaters running full blast until the setpoint is almost
reached. Then the temperature will overshoot beyond the setpoint
because the internal temperature of the heating element will be a lot
hotter than the water, and this heat will migrate to the surface of the
element and then to the water in the boiler. Observe and write down
the amount of overshoot. Let the temperature drop back to the setpoint
and pull a blank shot. If you have one of my thermofilters you can
simulate the real thing with the water flow rate closely mimicking a
real shot. Pulling the blank shot upsets the thermal applecart and
the heater will activate. Observe and record the amounts of
temperature undershoot from pulling the blank shot and the overshoot.
Record several cycles of blank shots. Subtract the undershoot from the
overshoot value and you'll get a temperature window that reflects how
much heat gets added to the system from the heater. Ballpark the
magnitude of the proportional band using the procedure illustrated in
the following example: Let's assume the magnitude of the window is 2
degrees and that the temperature range that you previously set is 200
degrees. It's pretty reasonable to allow a 1 degree overshoot, so
subtract 1 degrees from the 2 degrees and that sets the maximum
temperature relative to the setpoint temperature that will give you a
half degree overshoot with the heater full on IN THE VERY SPECIAL CASE
OF PULLING SHOTS. The case of pulling shots is really the only one we
care about here. The relative difference in our example is 1 degrees,
which is 0.5% of the 200 degree temperature range. Set the
proportional band parameter to 0.5 and test it by pulling a series of
blank shot, writing down the amount of overshoot and checking your
work. Adjust the value of P as needed to get the desired maximum
overshoot value when pulling blank shots.
Now that you've systematically gotten the proportional band as small
as you can reasonably get it, it's time to set the integral
parameter, I. Up till now there has been no integral effect and we
don't know what the effect is, so dive in and pick a big number like
100. Pull a blank shot and observe the temperature. If there's not
much effect and the temperature moves sluggishly and or doesn't
converge to the setpoint then reduce I by 50%. Repeat the blank shot
experiment and observe the temperature as it goes to setpoint. If it
takes forever or doesn't converge to the setpoint, then reduce I by
50%. Use the indicator light as a guide. If the indicator light
doesn't start flashing proportional control when the actual
temperature is below setpoint, then the I value is too large. Continue
reducing I until the process temperature demonstrates convergence to
the setpoint temperature when you pull a bland shot. Now watch the
temperature without pulling blank shots and record it every few seconds
for several minutes. Reduce I by 50% if the temperature stays very
steady and repeat the observations for a few minutes. Repeat the
reduction of I by 50% until the temperature begins to oscillate about
the setpoint at a more or less constant rate. From observing the
heater indicator light, one should see the proportion of heater on time
increasing smoothly as temperature drops below setpoint, and reducing
to zero as the temperature goes above setpoint. Now increase I by 50%
in order to get a reasonably stable, yet reactive value for the
integral.
Adding derivative makes the control system react quickly to temperature
fluctuations that occur when brewing. Start adding derivative by
inputting a small number (like maybe 0.5) and observing the system
behavior when pulling blank shots. Write down the temperature response
to several blank shots. Does the temperature quickly return to
setpoint? If not, then increase the D value by 50% and repeat the
observations. If the system is still not quickly reactive to blank
shots, then increase D by 50% again. I favor reactive control when it
comes to responding to blank shots. I want my controllers to blast
heat to the system in response to pulling shots, so I like to add
derivative until the system responds very quickly and displays a couple
of tenths of a degree oscillation around setpoint. To me this is the
most desireable setup. The controller will react very quickly to small
changes in water temperature, and the small deviations in temperature
caused by slightly excessive derivative values are damped out as brew
water makes it to the coffee cake.
-Greg "Glad to get that one off my chest" Scace
.
- Follow-Ups:
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: Tibor Dek
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: Andy Schecter
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: jim schulman
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: RBeech
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: Marshall
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: Ken Fox
- Re: Tuning PID controllers for use in espresso machines (very long)
- From: Ian Smith
- Re: Tuning PID controllers for use in espresso machines (very long)
- Prev by Date: Re: Espresso Shot Temperature Stability . . . . . from a Heat Exchanger
- Next by Date: And now for a crystal clear message about coffee
- Previous by thread: This coffee is really the shit...LOL no kidding
- Next by thread: Re: Tuning PID controllers for use in espresso machines (very long)
- Index(es):
Relevant Pages
|