PID Algorithm
PID Algorithm
Advanced Topics
3. PID Algorithm
2
ff
fi
ff
3.1 Definitions
Before proceeding, we must ensure that we de ne the key
terminology. In Chapter 2 we de ned PV (the process variable that
we wish to control, also called controlled variable CV) and MV (the
manipulated variable). The reader should note that some texts use
this abbreviation to mean ‘measured value’, i.e. what we call PV.
3
fi
fi
fi
3.1 Definitions
The error (E) is de ned as the deviation from SP but its de nition
varies between DCS. Our de nition in this chapter is
4
fi
fi
fi
fi
fi
3.2 Proportional Action
The principle behind proportional control is to keep the controller
output (M) in proportion to the error (E).
5
3.2 Proportional Action
6
fi
fi
3.2 Proportional Action
In other words, if the process gain is positive,
the controller should be reverse acting; if the
process gain is negative, it should be direct PV
acting. This de nition is consistent with the
concept of negative feedback where the
product of all the gain terms in a control loop
(known as the loop gain) must be negative. MV
Some base the action on increasing E, rather than PV. If they also
de ne error as SP – PV, then our heater temperature controller
would need to be con gured as direct acting.
7
fi
ff
fi
fi
fi
3.2 Proportional Action
Some texts take this into account when specifying the action of
the controller. However, most DCS di erentiate between the
output from the controller, which is displayed to the operator, and
what is sent to the valve.
To the operator and the controller all outputs represent the fraction
(or percentage) that the valve is open. Any reversal required is
performed after this. Under these circumstances, valve action
need not be taken into account when specifying controller action.
8
fi
ff
3.2 Proportional Action
Full Position Form
Subtracting gives
9
fi
3.2 Proportional Action
10
fi
fi
3.2 Proportional Action
11
fi
3.2 Proportional Action
12
fi
3.2 Proportional Action
13
3.2 Proportional Action
14
3.2 Proportional Action
15
3.2 Proportional Action
Remembering that for our red heater example
the controller is reverse acting, the controller
will thus make a step increase to fuel ow
proportional to the increase in temperature SP.
Kc=2
16
ff
fi
fl
3.2 Proportional Action
Of course, increasing the fuel will cause the temperature
to rise and reduce the error – so the controller output will
only remain at this new value until the process deadtime PV
has expired. The full trend is shown in the gure below
MV
17
fi
3.2 Proportional Action
This demonstrates the main limitation of proportional
control in that an o set will always exist at steady state.
The PV will never reach SP except at initial conditions.
The o set can be reduced by increasing Kc but with increasing
oscillatory behaviour. These oscillations, on any process, become
unstable before
o set can be
reduced to zero.
18
ff
ff
ff
3.2 Proportional Action - Example
19
3.2 Proportional Action - Example
If the inlet ow fi(t) increases, the response of the system with a
proportional controller is shown. The controller returns the
controlled variable to a steady value but not to the set point
required. The di erence between the set point and the new steady
state is the o set. The proportional controller is not “intelligent
enough” to drive the controlled variable back to set point. The new
steady-state value satis es the controller.
20
fl
ff
ff
fi
3.2 Proportional Action - Example
The obvious question is: Why does this o set occur? Let us now
look at a simple explanation to this question. Consider again the
liquid-level control system shown in with the same operating
conditions as those given previously, that is, fi = f = = 150 gpm, h
= 4 ft, and with a required signal to the valve of 50%CO to deliver
150 gpm. Assume now that the inlet ow increases up to 170 gpm.
21
fl
fl
ff
3.2 Proportional Action - Example
To deliver this new ow, the outlet valve must be open more than
before, when it needed to deliver 150 gpm. Because the valve is
fail-closed, let us assume that the new signal to the valve required
to deliver 170 gpm is 60%. That is, the output from the controller
must be 60%. Constant Variable
22
ff
fl
3.2 Proportional Action - Example
Constant Variable
23
ff
3.2 Proportional Action - Example
Constant Variable
24
ff
fi
3.3 Integral Action
The main purpose of integral (or reset) action is to eliminate o set.
Ti (or i) is known as the integral time (or reset time) and is the
means by which the engineer can dictate how much integral action
is taken. Some manufacturers use the reciprocal of reset time, the
reset rate .
25
𝝉
ff
3.3 Integral Action
Converting the equation to its discrete form (where ts is the
controller scan interval) gives
I
P
27
3.3 Integral Action
Kc = 1
31
3.4 Derivative Action
Derivative action attempts to prevent this by changing the output
in proportion to the rate of change of error, i.e.
And subtracting
32
𝝉
3.4 Derivative Action
In order to demonstrate the e ect of derivative action we will
formulate a proportional plus derivative (PD) controller. This
probably has no practical application but including integral action
would make the trends very di cult to interpret.
Proportional Control
P Derivative Control
33
ff
ffi
3.4 Derivative Action Proportional Derivative Control
Not a step
change to the
SP, instead it
has been
ramped.
The initial step change in the output is not then the result of P action
but the D action responding to the change, from zero, in the rate of
change of error. The subsequent ramping of the output is due to the
P action responding to the ramping error.
34
3.4 Derivative Action Proportional Derivative Control
Shown is the
response of
this controller,
up to the point
where the
deadtime
expires.
The P action will eventually change the output by the same amount as
the initial D action. The time taken for this is Td which, like Ti , can be
expressed in units such as minutes or repeats per minute, depending
on the DCS.
35
3.4 Derivative Action Proportional Derivative Control
Also shown in
green is what the
controller
response would
be without D
action, i.e. P‐only.
It can be seen that D action takes action immediately and that the P
action takes Td minutes to do. In e ect it has anticipated the need for
corrective action, even though the error was zero at the time.
36
ff
3.4 Derivative Action
We have seen that P action is based on current error and I on past
errors.
37
ff
fi
fi
fi
3.4 Derivative Action
Indeed, if the θ/τ ratio is small, instability can be caused by relatively
small amounts of D action. However, we will demonstrate later that D
action permits Kc to be increased and so can be very useful in
speeding the recovery from a load change – even if the θ/τ ratio is
close to zero.
It is often said that D action should only be used in temperature
controllers. It is true that temperatures, such as those on the outlet of
a red heater and on distillation column trays, will often exhibit
signi cantly more deadtime than measurements such as ow, level
and pressure. However this is not universally the case, as illustrated
in the gure
Manipulating the bypass of the stream on which
we wish to install a temperature controller, in this
case around the tube side of the exchanger, will
provide an almost immediate response. Indeed, if
accurate control of temperature is a priority, this
would be preferred to the alternative
con guration of bypassing the shell side.
38
fi
fi
fi
fi
fl
3.4 Derivative Action
While there are temperatures with a very short deadtime there will
be other measurements (like levels !!) that, under certain
circumstances, show a long deadtime.
41
fi
3.4 Derivative Action
43
fi
fi
fi
3.4 Derivative Action
The problem can also arise from the use of digital eld transmitters,
even if the analog‐to‐ digital conversion is done to a high resolution,
say, to 0.1% of range.
44
fi
fi
fi
3.4 Derivative Action
This gure
shows the
performance of
the full PID
controller as
described in the
above equation.
While the amplitude of the noise may be very small, it will cause a
high rate of change of the PV. Derivative action will therefore amplify
this.
46
3.4 Derivative Action
shows that the change in output caused by the D action will also
be sinusoidal (shifted in phase), with the same frequency, but
ampli ed by 2πf.
The higher the frequency, the greater will be the ampli cation.
The possible presence of noise is perhaps another reason why
there may be a reluctance to use D action. However modern DCS
provide a range of ltering techniques which can permit it to be
applied e ectively.
47
ff
fi
ff
fi
fi
3.4 Derivative Action
This gure shows the bene t of including D action. The open loop
response was produced by making a step change to the MV of the
same magnitude as that ultimately made by the controllers.
48
fi
fi
3.4 Derivative Action
By applying the methods detailed
earlier, the reader can con rm that
this is a long deadtime process
with a θ/τ ratio of about 2.7.
The closed loop responses were
placed by overlaying their trends
so that the change in SP is at the
same point in time as the start of
the open loop test.
With such a process an optimally tuned PID controller will
outperform an optimally tuned PI controller by reaching SP in about
30% less time.
51
3.5. Proportional‐on‐PV Controller
Conversely it is important to
recognise that the proporional‐
on‐PV algorithm can be
Proportional-on-PV algorithm
M
Let us examine the behaviour
of each part of the I proportional-on-error
proportional-on-error
control algorithm in response P
to the SP change above.
53
3.5. Proportional‐on‐PV Controller
proportional-on-error
The gure below shows the same M
disturbance but with the
proportional-on-PV algorithm. Note I
that the vertical scale is much larger
than that in the gure above.
As expected, there is no proportional P
kick and, since the action is now based
on PV, the proportional part does not D
return to zero.
D
The derivative action behaves in almost
the same way as in the proportional- P
on-error case, but the correction is
larger because of the higher controller
gain. 54
fi
fi
fi
3.5. Proportional‐on‐PV Controller
proportional-on-error
M
It was shown earlier that the I
performance of a retuned proportional-
on-PV controller would, on a real
process, be indistinguishable from the P
original proportional-on-error controller.
D
55
3.5. Proportional‐on‐PV Controller
proportional-on-error
M
I
proportional-on-PV
I
retuned proportional-on-PV
58
fi
fl
3.5. Proportional‐on‐PV Controller
Switching the algorithm between proportional-on-error and
proportional-on-PV has no a ect on the way it responds to load
changes. The di erence we see is due to the di erence in tuning.
The more tightly tuned algorithm deviates from SP by less than half
and the duration of the upset is also halved.
59
ff
ff
ff
3.5. Proportional‐on‐PV Controller
M
I
Response to a load change (both algorithms)
D
60
fi
3.5. Proportional‐on‐PV Controller
Response to a load change
Response to a SP change
(proportional-on-error algorithm)
61
fi
fi
ff
3.5. Proportional‐on‐PV Controller
Even if SP changes are rare, when they
are made, the controller will now react far
too quickly. In our example the MV has
overshot its steady-state change by
Response to a SP change
to proportional-on-error
for SP changes.
63
3.5. Proportional‐on‐PV Controller
As expected the proportional-on-PV algorithm does not perform as
well as the proportional-on-error algorithm for SP changes.
While this might at rst appear signi cant, it should be compared
against the impact it has when the process is subjected to a load
change.
Impact of switching from proportional-on-PV
to proportional-on-error
for SP changes.
64
fi
fi
3.5. Proportional‐on‐PV Controller
Secondaries of cascades generally have a very small / ratio and so
the improvement in the response to load changes, from selecting the
proportional-on-PV algorithm, is likely to be around 600 %. The
price we pay for this is around a 10 % increase in ITAE when the SP
is changed.
/ 66
𝜽
𝝉
fl
3.5. Proportional‐on‐PV Controller
to proportional-on-error
/ 68
𝜽
𝝉
fi
fi
𝜽
𝝉
3.5. Proportional‐on‐PV Controller
Some DCS include an algorithm described as the two degrees of
freedom controller. This has the form
where
69
𝜶
3.5. Proportional‐on‐PV Controller
while setting them both to 1 will give the recommended form of the
controller as described by the equation
70
3.5. Proportional‐on‐PV Controller
and β = 0
and β = 1
Optimising the tuning, for both load and SP changes, will always
result in value for a of 1 (and higher if permitted). However this
ignores the requirement that the controller should handle both
disturbances well with the same tuning constants. For this to be
achievable, must be 0.
The optimised value for β will be that which generates the maximum
permitted derivative spike, i.e. β will be zero if no spike is permitted.
71
𝜶
𝜶
𝜶
𝜶
fi
3.5. Proportional‐on‐PV Controller
Another option available in some systems is an integral only
algorithm. This has the form
In the same way that derivative action ampli es noise, integral action
attenuates it.
The full position discrete form of the algorithm, shows how integral
action is based on the sum of all previous values of the error. This
averages out any noise.
73
fi
fl
fi
3.6. Bumpless Transfer and Windup Protection.
To achieve a smooth transition, functions in addition to those
illustrated in the gure are required. Similar requirements apply to
all control con gurations and usually increase in complexity with
the complexity of the control con guration
• The PID controller must not be allowed to wind up. Windup is
a phenomenon associated with the reset (intergal) mode and is
often referred to as reset windup. The PID block invokes
windup protection when the controller output is driven to either
of the controller output limits. However, there are external
factors that can result in windup. The condition for windup to
occur is stated as follows:
Reset windup occurs in a controller when changes in the
controller output have no e ect on the process variable.
76
3.6. Bumpless Transfer and Windup Protection.
Implementations of the PID block must provide at least one of
these, but con guring such features is not normally represented
on P&I diagrams.
The logic required to address these issues can easily exceed the
logic for the normal control functions. Ignoring the requirements
for bumpless transfer and windup protection will have
consequences.
77
fi
3.6. Bumpless Transfer and Windup Protection.
78
fl
fl
fi
fl
fi
3.7. TUNING FEEDBACK CONTROLLERS
Probably 80 to 90% of feedback controllers are tuned by
instrument technicians or control engineers based on their
previous experience. For the 10 to 20% of cases where no
previous experience exists, or for personnel without previous
experience, there exist several organized techniques to obtain
an “initial guess ” close to the “optimum” settings.
79
ff
fi
3.7. TUNING FEEDBACK CONTROLLERS - Online Tuning
ultimate period ultimate gain
Some tuning rules are based on the idea of ultimate gain and
ultimate period. The gure plots the closed loop response for
a unit step change in the set-point of a rst order plus dead
time process for a P only controller as the controller gain is
increased. 80
fi
fi
3.7. TUNING FEEDBACK CONTROLLERS - Online Tuning
τD -- -- PU/6.3
82
τI -- PU/1.2 PU/2
τD -- -- PU/8
As discussed before, D
action is however used Tyreus -Luyben
rarely in practice due to KC -- KU/3.2 KU/2.2
noise ampli cation. The PI
algorithm is most τI 2.2PU 2.2PU
commonly used in the
industry. τD -- -- PU/6.3
83
fi
ff
ff
3.7. TUNING FEEDBACK CONTROLLERS - Online Tuning
ZN or TL settings can h
be used for calculation
of tuning parameters. a
4h
KU =
aπ
85
3.7. TUNING FEEDBACK CONTROLLERS - Offline Tuning
The data required for the o ine tuning techniques are obtained
from the step testing method presented in Chapter 2, that is, Kp,
, and to (or ).
Almost all control loops in the process industry are one of the
following
Some heuristics are discussed for tuning these loops that re ect
common industrial practice.
88
fl
3.7.1. Flow Loops
Flow loops are the most common loops in the process industries.
Consider the loop shown in the gure. Assume that the controller
is in manual and a step change in controller output is induced.
89
𝜽
fl
fi
3.7.1. Flow Loops
to (or )≈ 0 min.
In every tuning equation for controller gain, the dead time appears
in the denominator of the equation. Thus the results would show a
need for an in nite controller gain, but the signal from the ow
sensor is often noisy due to turbulent ow so that a large
proportional band (150% or more) is required. Analysis of these
types of fast processes indicates that the controller needed is an I
only.
Because pure I controllers were not available when only analog
instrumentation was available, a PI controller was used with very
small P and a large I action.
91
𝜽
fl
𝜏
ff
𝝉
𝝉
3.7.2. Level Loops.
92
fi
fi
𝜏
3.7.2. Level Loops.
If the input ow varies as shown in the gure, to control the level
tightly at set point the output ow must also vary, as shown. We
referred to this as tight level control. However, the changes in
output ow will act as disturbances to the downstream process
unit. If this unit is a reactor, separation column, lter, and so on,
the disturbance may have a major e ect on its performance.
93
fl
fl
fl
ff
fi
fi
3.7.2. Level Loops.
Often, it is desired to smooth the ow feeding the downstream
unit. To accomplish this objective, the level in the tank must be
allowed to “ oat” between a high and a low level. Thus, the
objective is not to control the level tightly but rather, to smooth the
output ow with some consideration of the level. We referred to
this objective as average level control. Let us look at how to tune
the level controller for each objective.
94
fl
fl
fl
Tight level control.
3.7.2. Level Loops.
Tight level control.
If the level process happens to be self-regulated, that is, if it is
possible to obtain Kp, , and to, the tuning techniques already
presented in this chapter can be used.
If the level process is integrating, the following equation for a
proportional controller is proposed:
96
3.7.2. Level Loops.
Tight level control.
If the level process is integrating, the following equation for a
proportional controller is proposed:
97
𝝉
3.7.2. Level Loops.
Average level control.
To review what we had previously said, the objective of average level
control is to smooth the output ow from the tank. To accomplish
this objective, the level in the tank must be allowed to “ oat”
between a high and a low level.
Obviously, the larger the di erence between the high and low levels,
the more “capacitance” is provided, and the more smoothing of the
ow is obtained.
98
fl
ff
fl
fl
3.7.2. Level Loops.
Average level control.
99
fi
3.7.2. Level Loops.
Average level control.
To explain the second way to tune the controller: The gure shows
two deviations, D1 and D2. D1 indicates the expected ow deviation
from the average ow. D2 indicates the allowed level deviation from
set point.
With this information we can
now write the tuning
equation:
100
fl
fl
fi
3.7.2. Level Loops.
Average level control.
The equation is composed of two ratios, and both ratios
must be dimensionless. This equation allows you to
(1) use less than the span of the
transmitter if it is necessary for
some reason, and
101
fl
3.7.2. Level Loops.
Average level control.
102
fl
3.7.2. Level Loops.
Average level control.
Note that the use of PI controllers for level control of surge
capacities is not recommended, as a change in the inlet ow
would require that the outlet ow increase above the inlet ow
before becoming equal to the inlet ow in order to bring the level
back to its set-point (zero o set).
103
fl
fi
fi
fl
ff
fl
fl
fl
fl
3.7.3. Pressure Loops
The dynamics of pressure can be very fast ( ow like) or slow (level
like) depending on the process system. For example, the pressure
dynamics are extremely fast for a valve throttling the vapour outlet
line from a tank. On the other hand, the dynamics are slow for the
cooling water ow adjusting the pressure in a condenser due to
the heat transfer and water ow lag.
PI controllers are usually used for pressure loops with a small
proportional band (10-20%) and integral time (0.2-2 mins) for
tight pressure control.
105
3.7.5. Quality Loops
Composition control loops are usually applied for maintaining the
product quality. In terms of relative importance, these loops are
probably the most crucial for process pro tability.
If the product quality shows large variability, the process must be
operated at a mean product quality that is signi cantly better than
the quality speci cation to ensure the production of on-spec or
better quality product all the time.
106
fi
ff
fi
fi
fi
3.7.5. Quality Loops
Typical composition measurements involve large dead-times or
lags. For example the dead-time introduced by a gas-
chromatograph can vary from a few minutes to an hour. Some
compositions may be measured once a shift or once a day
through laborious analytical measurements.
fi
End of Chapter 3