PID - Control & Ziegler-Nichols
PID - Control & Ziegler-Nichols
PID Control
6.1 Introduction
The PID controller is the most common form of feedback. It was an es-
sential element of early governors and it became the standard tool when
process control emerged in the 1940s. In process control today, more than
95% of the control loops are of PID type, most loops are actually PI con-
trol. PID controllers are today found in all areas where control is used.
The controllers come in many different forms. There are stand-alone sys-
tems in boxes for one or a few loops, which are manufactured by the
hundred thousands yearly. PID control is an important ingredient of a
distributed control system. The controllers are also embedded in many
special-purpose control systems. PID control is often combined with logic,
sequential functions, selectors, and simple function blocks to build the
complicated automation systems used for energy production, transporta-
tion, and manufacturing. Many sophisticated control strategies, such as
model predictive control, are also organized hierarchically. PID control is
used at the lowest level; the multivariable controller gives the setpoints
to the controllers at the lower level. The PID controller can thus be said
to be the “bread and buttert’t’ of control engineering. It is an important
component in every control engineer’s tool box.
PID controllers have survived many changes in technology, from me-
chanics and pneumatics to microprocessors via electronic tubes, transis-
tors, integrated circuits. The microprocessor has had a dramatic influence
on the PID controller. Practically all PID controllers made today are based
on microprocessors. This has given opportunities to provide additional fea-
tures like automatic tuning, gain scheduling, and continuous adaptation.
216
6.2 The Algorithm
Zt
1 de(t)
u(t) = K e(t) + e(τ )dτ + Td (6.1)
Ti dt
0
217
Chapter 6. PID Control
K =5
K =2
1
K =1
0
0 5 10 15 20
K =5
K =2
2 K =1
−2
0 5 10 15 20
Figure 6.1 Simulation of a closed-loop system with proportional control. The pro-
cess transfer function is P(s) = 1/(s + 1)3 .
Ti = 1
Ti = 2
Ti = 5
1
Ti = ∞
0
0 5 10 15 20
Ti = 1
2 Ti = 2
Ti = 5
1 Ti = ∞
0
0 5 10 15 20
Figure 6.2 Simulation of a closed-loop system with proportional and integral con-
trol. The process transfer function is P(s) = 1/(s + 1)3 , and the controller gain is
K = 1.
A Perspective
There is much more to PID than is revealed by (6.1). A faithful imple-
mentation of the equation will actually not result in a good controller. To
obtain a good PID controller it is also necessary to consider
218
6.3 Filtering and Set Point Weighting
Td = 0.1
Td = 0.7
1
Td = 4.5
0
0 5 10 15 20
−2
0 5 10 15 20
• Windup
• Tuning
• Computer implementation
In the case of the PID controller these issues emerged organically as the
technology developed but they are actually important in the implemen-
tation of all controllers. Many of these questions are closely related to
fundamental properties of feedback, some of them have been discussed
earlier in the book.
Filtering
Differentiation is always sensitive to noise. This is clearly seen from the
transfer function G (s) = s of a differentiator which goes to infinity for
large s. The following example is also illuminating.
219
Chapter 6. PID Control
d y(t)
= cos t + n(t) = cos t + anω cos ω n t
dt
The signal to noise ratio for the original signal is 1/ an but the signal to
noise ratio of the differentiated signal is ω / an . This ratio can be arbitrarily
high if ω is large.
In a practical controller with derivative action it is therefor necessary to
limit the high frequency gain of the derivative term. This can be done by
implementing the derivative term as
sK Td
D=− Y (6.2)
1 + sTd / N
lim C (s) = − K (1 + N )
s→∞
220
6.3 Filtering and Set Point Weighting
1
F ( s) =
(1 + sT f )n
where T f is the filter time constant and n is the order of the filter. The
choice of T f is a compromise between filtering capacity and performance.
The value of T f can be coupled to the controller time constants in the
same way as for the derivative filter above. If the derivative time is used,
T f = Td / N is a suitable choice. If the controller is only PI, T f = Ti / N
may be suitable.
The controller can also be implemented as
1 1
C ( s) = − K 1 + + sTd (6.3)
sTi (1 + sTd / N )2
This structure has the advantage that we can develop the design meth-
ods for an ideal PID controller and use an iterative design procedure. The
controller is first designed for the process P(s). The design gives the con-
troller parameter Td . An ideal controller for the process P(s)/(1 + sTd / N )2
is then designed giving a new value of Td etc. Such a procedure will also
give a clear picture of the trade-off between performance and filtering.
Zt
1 dr(t) d y(t)
u(t) = K br(t) − y(t) + e(τ )dτ + Td c − (6.4)
Ti dt dt
0
where b and c are additional parameter. The integral term must be based
on error feedback to ensure the desired steady state. The controller given
by (6.4) has a structure with two degrees of freedom because the signal
path from y to u is different from that from r to u. The transfer function
from r to u is
U ( s) 1
= Cr (s) = K b + + csTd (6.5)
R( s ) sTi
221
Chapter 6. PID Control
1.5
Output y
1
0.5
0
0 5 10 15
4
Input u
0
0 5 10 15
Time t
Figure 6.4 Response to a step in the reference for systems with different set point
weights b = 0 dashed, b = 0.5 full and b = 1.0 dash dotted. The process has the
transfer function P(s) = 1/(s + 1)3 and the controller parameters are k = 3, ki = 1.5
and kd = 1.5.
Set point weighting is thus a special case of controllers having two degrees
of freedom.
The system obtained with the controller (6.4) respond to load distur-
bances and measurement noise in the same way as the controller (6.1)
. The response to reference values can be modified by the parameters b
and c. This is illustrated in Figure 6.4, which shows the response of a PID
controller to setpoint changes, load disturbances, and measurement errors
for different values of b. The figure shows clearly the effect of changing b.
The overshoot for setpoint changes is smallest for b = 0, which is the case
where the reference is only introduced in the integral term, and increases
with increasing b.
The parameter c is normally zero to avoid large transients in the con-
trol signal due to sudden changes in the setpoint.
222
6.4 Different Parameterizations
transfer function
1
G ( s) = K 1 + + sTd (6.7)
sTi
A slightly different version is most common in commercial controllers.
This controller is described by
1 TdP 1
G P ( s) = K P 1 + (1 + sT P
) = K P
1 + + + sT P
(6.8)
sTiP d
TiP sTiP d
TiP + TdP
K = KP
TiP
Ti = TiP + TdP (6.9)
TiP TdP
Td =
TiP + TdP
Ti ≥ 4Td
K p
KP = 1+ 1 − 4Td / Ti
2
T p
TiP = (6.10)
i
1+ 1 − 4Td / Ti
2
Ti p
TdP = 1− 1 − 4Td / Ti
2
223
Chapter 6. PID Control
when both the I and the D parts of the controller are used. If we only use
the controller as a P, PI, or PD controller, the two forms are equivalent.
Yet another representation of the PID algorithm is given by
ki
G PP (s) = k + + skd (6.11)
s
K
k= K ki = kd = K Td
Ti
kPi
G PI (s) = kP +
s
G PD (s) = 1 + kPd s
Notice that the proportional gain of the PD controller must be one in order
to have zero steady state error. The input-output relation of the complete
controller is
kPi
U (s) = kP R(s) + ( R(s) − Y (s)) − ( kP + kPd hPi ) Y (s) − kP kPd sY (s)
s
Which shows that the controller is thus identical to the controller given
224
6.4 Different Parameterizations
r u y
Σ PI Σ Process
PD
r e y
Σ PI Σ P
PD
−1
k = kP + kPd kPi
ki = kPi
kd = kP kPd
kP + kPd kPi kP
Ti = =
kPi kPi
P P
kk
Td = P d
ki
kP
b= P
k + kPd hPi
c=0
225
Chapter 6. PID Control
uncertainty. When this is done the response to set points can be adjusted
by choosing the parameters b and c. The controller parameters appear in
a much more complicated way in the PIPD controller.
6.5 Windup
Although many aspects of a control system can be understood based on
linear theory, some nonlinear effects must be accounted for in practically
all controllers. Windup is such a phenomena, which is caused by the inter-
action of integral action and saturations. All actuators have limitations:
a motor has limited speed, a valve cannot be more than fully opened or
fully closed, etc. For a control system with a wide range of operating condi-
tions, it may happen that the control variable reaches the actuator limits.
When this happens the feedback loop is broken and the system runs as
an open loop because the actuator will remain at its limit independently
of the process output. If a controller with integrating action is used, the
error will continue to be integrated. This means that the integral term
may become very large or, colloquially, it “winds up”. It is then required
that the error has opposite sign for a long period before things return to
normal. The consequence is that any controller with integral action may
give large transients when the actuator saturates. We will illustrate this
by an example.
226
6.5 Windup
2 y
1
ysp
0
0 20 40 60 80
0.1
u
−0.1
0 20 40 60 80
I
2
−2
0 20 40 60 80
Figure 6.6 Illustration of integrator windup. The diagrams show process output
y, setpoint ysp, control signal u, and integral part I.
under labels like preloading, batch unit, etc. Although the problem was
well understood, there were often restrictions caused by the analog tech-
nology. The ideas were often kept as trade secrets and not much spoken
about. The problem of windup was rediscovered when controllers were im-
plemented digitally and several methods to avoid windup were presented
in the literature. In the following section we describe some of the methods
used to avoid windup.
Setpoint Limitation
One attempt to avoid integrator windup is to introduce limiters on the
setpoint variations so that the controller output never reaches the actua-
tor limits. This frequently leads to conservative bounds and poor perfor-
mance. Furthermore, it does not avoid windup caused by disturbances.
Incremental Algorithms
In the early phases of feedback control, integral action was integrated
with the actuator by having a motor drive the valve directly. In this
case windup is handled automatically because integration stops when the
valve stops. When controllers were implemented by analog techniques,
227
Chapter 6. PID Control
–y
KT d s
Actuator
model Actuator
e = r− y
K Σ
K 1 – +
Ti
Σ Σ
s
1 es
Tt
Figure 6.7 Controller with anti-windup where the actuator output is estimated
from a mathematical model.
228
6.5 Windup
ysp
1
y
0.5
0
0 10 20 30
0.15
u
0.05
−0.05
0 10 20 30
0
I
−0.4
−0.8
0 10 20 30
Figure 6.8 Controller with anti-windup applied to the system of Figure 6.6. The
diagrams show process output y, setpoint ysp, control signal u, and integral part I.
process input remains constant. There is, however, a feedback path around
the integrator. Because of this, the integrator output is driven towards a
value such that the integrator input becomes zero. The integrator input
is
1 K
es + e
Tt Ti
where e is the control error. Hence,
K Tt
es = − e
Ti
K Tt
v = ulim + e
Ti
where ulim is the saturating value of the control variable. This means that
the signal v settles on a value slightly out side the saturation limit and the
control signal can react as soon as the error changes time. This prevents
229
Chapter 6. PID Control
ysp Tt = 3
Tt = 2
1
Tt = 0.1, Tt = 1
0
0 10 20 30
0.1 Tt = 3
Tt = 0.1 Tt = 2
0 Tt = 1
−0.1
0 10 20 30
Figure 6.9 The step response of the system in Figure 6.6 for different values of
the tracking time constant Tt . The upper curve shows process output y and setpoint
ysp, and the lower curve shows control signal u.
the integrator from winding up. The rate at which the controller output is
reset is governed by the feedback gain, 1/ Tt , where Tt can be interpreted
as the time constant, which determines how quickly the integral is reset.
We call this the tracking time constant.
It frequently happens that the actuator output cannot be measured.
The anti-windup scheme just described can be used by incorporating a
mathematical model of the saturating actuator, as is illustrated in Fig-
ure 6.7.
Figure 6.8 shows what happens when a controller with anti-windup is
applied to the system simulated in Figure 6.6. Notice that the output of
the integrator is quickly reset to a value such that the controller output
is at the saturation limit, and the integral has a negative value during
the initial phase when the actuator is saturated. This behavior is drasti-
cally different from that in Figure 6.6, where the integral has a positive
value during the initial transient. Also notice the drastic improvement in
performance compared to the ordinary PI controller used in Figure 6.6.
The effect of changing the values of the tracking time constant is il-
lustrated in Figure 6.9. From this figure, it may thus seem advantageous
to always choose a very small value of the time constant because the
integrator is then reset quickly. However, some care must be exercised
when introducing anti-windup in systems with derivative action. If the
time constant is chosen too small, spurious errors can cause saturation
of the output, which accidentally resets the integrator. The tracking time
constant Tt should be larger than Td and smaller than Ti . A rule of thumb
230
6.5 Windup
y sp P
b Σ K
y sKTd D
−1 Σ
1+ sTd / N
e K 1 I v
Ti Σ s
Σ
1
Tt
w + –
Σ
y sp
SP v
y MV PID
w TR
Figure 6.10 Block diagram and simplified representation of PID module with
tracking signal.
√
that has been suggested is to choose Tt = Ti Td .
231
Chapter 6. PID Control
A
SP
MV PID Actuator
TR
B
Actuator model
SP
v u
MV PID Actuator
TR
Figure 6.11 Representation of the controllers with anti-windup in Figure 6.7 us-
ing the basic control module with tracking shown in Figure 6.10.
6.6 Tuning
All general methods for control design can be applied to PID control. A
number of special methods that are tailor-made for PID control have also
been developed, these methods are often called tuning methods. Irrespec-
tive of the method used it is essential to always consider the key elements
of control, load disturbances, sensor noise, process uncertainty and refer-
ence signals.
The most well known tuning methods are those developed by Ziegler
and Nichols. They have had a major influence on the practice of PID
control for more than half a century. The methods are based on character-
ization of process dynamics by a few parameters and simple equations for
the controller parameters. It is surprising that the methods are so widely
referenced because they give moderately good tuning only in restricted
situations. Plausible explanations may be the simplicity of the methods
and the fact that they can be used for simple student exercises in basic
control courses.
232
6.6 Tuning
Table 6.1 PID controller parameters obtained for the Ziegler-Nichols step response
method.
Controller K Ti Td Tp
P 1/a 4L
PI 0.9/a 3L 5.7L
PID 1.2/a 2L L/ 2 3.4L
Figure 6.12.
The point where the slope of the step response has its maximum is
first determined, and the tangent at this point is drawn. The intersections
between the tangent and the coordinate axes give the parameters a and L.
The controller parameters are then obtained from Table 6.1. An estimate
of the period Tp of the closed-loop system is also given in the table.
233
Chapter 6. PID Control
0.5
−0.5
−1
−0.5 0 0.5 1
Controller K Ti Td Tp
P 0.5K u Tu
PI 0.4K u 0.8Tu 1.4Tu
PID 0.6K u 0.5Tu 0.125Tu 0.85Tu
process starts to oscillate. The gain when this occurs is K u and the period
of the oscillation is Tu . The parameters of the controller are then given by
Table 6.2. An estimate of the period Tp of the dominant dynamics of the
closed-loop system is also given in the table.
The frequency response method can be viewed as an empirical tuning
procedure where the controller parameters are obtained by direct experi-
ments on the process combined with some simple rules. For a proportional
controller the rule is simply to increase the gain until the process oscil-
lates and then reduce it by 50%.
234
6.6 Tuning
kp
P1 (s) = e−sL
1 + sT
kv −sL
P2 (s) = e
s
The transfer function P1 (s), which is called a first order system with time
delay or a K LT model. Parameter L is determined from the intercept
of the tangent with largest slope with the time axis as was described in
Figure 6.12. Parameter T is also determined as shown in the figure as
the difference between the time when the step response reaches 63% of
its steady state value. Parameter kp is the static gain of the system. The
parameter kv is the largest slope of the unit step response. Parameter
L is called the apparent time delay and parameter T the apparent time
constant or the apparent lag. The adverb apparent is added to indicate
that parameters are based on approximations. The parameter
L
τ =
L+T
235
Chapter 6. PID Control
1
P1 (s) =
(s + 1)(0.2s + 1)
1
P2 (s) =
(s + 1)4
1
P3 (s) = e−1.2s
0.05s + 1)2
The process P1 (s) has lag dominated dynamics, process P3 (s) has delay
dominated dynamics and process P2 (s) has balanced dynamics.
Figure 6.14 shows the response to a step change in the reference at
time zero and a step change in a load disturbance at the process input
for PI control of the process P1 (s). The dashed lines show the responses
obtained by the Ziegler-Nichols step response method and the full line
shows the response obtained with the improved rule which restricted the
maximum sensitivity to 1.4. The oscillatory responses to obtained by the
Ziegler-Nichols method are clearly visible in the figure which reflects the
design choice of quarter amplitude damping. The response to load distur-
bances obtained by the Ziegler-Nichols method comes at a price of poor
sensitivity. There is also a very large overshoot in the response to refer-
ence values. Figure 6.15 shows the corresponding responses for the system
P4 (s). The oscillatory character obtained with Ziegler Nichols tuning is
clearly visible. Figure 6.16 shows the response for a process that is delay
dominated. The figure shows that Ziegler-Nichols tuning performs very
poorly for this process. Overall we find that the improved tuning rules
work for a wide range of processes and that they give robust systems
with good responses.
236
6.7 Computer Implementation
a
2
1.5
1
y
0.5
0
0 1 2 3 4 5 6 7 8 9 10
t
b
15
10
5
u
−5
−10
0 1 2 3 4 5 6 7 8 9 10
t
Figure 6.14 Behavior of closed loop systems with PI controllers designed by the
Ziegler-Nichols rule (dashed) and the improved tuning rules (solid). The process
has lag dominated dynamics with the transfer function P(s) = (s+1)(10.2s+1) .
Sampling
When the controller is implemented in a computer, the analog inputs are
read and the outputs are set with a certain sampling period. This is a
drawback compared to the analog implementations, since the sampling
introduces dead-time in the control loop.
When a digital computer is used to implement a control law, the ideal
sequence of operation is the following.
1. Wait for clock interrupt
2. Read analog input
3. Compute control signal
4. Set analog output
237
Chapter 6. PID Control
a
2
1.5
1
y
0.5
0
0 10 20 30 40 50 60 70 80
t
b
2.5
1.5
1
u
0.5
−0.5
0 10 20 30 40 50 60 70 80
t
Figure 6.15 Behavior of closed loop systems with PI controllers designed by the
Ziegler-Nichols rule (dashed) and the improved tuning rules (solid). The process
has balanced dynamics with the transfer function P(s) = (s+11)4 .
Aliasing
The sampling mechanism introduces some unexpected phenomena, which
must be taken into account in a good digital implementation of a PID
controller. To explain these, consider the signals
s(t) = cos(nω s t ± ω t)
and
sa (t) = cos(ω t)
238
6.7 Computer Implementation
1.5
y
1
0.5
0
0 2 4 6 8 10 12 14 16 18 20
t
b
1.2
0.8
0.6
u
0.4
0.2
−0.2
0 2 4 6 8 10 12 14 16 18 20
t
Figure 6.16 Behavior of closed loop systems with PI controllers designed by the
Ziegler-Nichols rule (dashed) and the improved tuning rules (solid). The process
has delay dominated dynamics with the transfer function P(s) = 0.05s1+1)2 e−1.2s .
The signals s and sa thus have the same values at the sampling instants.
This means that there is no way to separate the signals if only their
values at the sampling instants are known. Signal sa is, therefore, called
an alias of signal s. This is illustrated in Figure 6.17. A consequence of the
aliasing effect is that a high-frequency disturbance after sampling may
appear as a low-frequency signal. In Figure 6.17 the sampling period is
1 s and the sinusoidal disturbance has a period of 6/5 s. After sampling,
the disturbance appear as a sinusoid with the frequency
5
fa = 1 − = 1/6 Hz
6
239
Chapter 6. PID Control
sa
1
0 s
−1
0 1 2 3 4 5
Figure 6.17 Illustration of the aliasing effect. The diagram shows signal s and its
alias sa .
Prefiltering
The aliasing effect can create significant difficulties if proper precautions
are not taken. High frequencies, which in analog controllers normally
are effectively eliminated by low-pass filtering, may, because of aliasing,
appear as low-frequency signals in the bandwidth of the sampled control
system. To avoid these difficulties, an analog prefilter (which effectively
eliminates all signal components with frequencies above half the sampling
frequency) should be introduced. Such a filter is called an anti-aliasing
filter. A second-order Butterworth filter is a common anti-aliasing filter.
Higher-order filters are also used in critical applications. The selection of
the filter bandwidth is illustrated by the following example.
(ω s /2ω b )2 = 16
Hence,
1
ωb = ωs
8
240
6.7 Computer Implementation
Discretization
To implement a continuous-time control law, such as a PID controller in
a digital computer, it is necessary to approximate the derivatives and the
integral that appear in the control law. A few different ways to do this
are presented below.
P = K (bysp − y)
where { tk } denotes the sampling instants, i.e., the times when the com-
puter reads the analog input.
It follows that
dI K
= e (6.14)
dt Ti
The derivative is approximated by a forward difference gives
I (tk+1 ) − I (tk ) K
= e(tk )
h Ti
This leads to the following recursive equation for the integral term
Kh
I (tk+1) = I (tk ) + e(tk ) (6.15)
Ti
Derivative Action The derivative term is given by Equation (6.2), i.e.
Td dD dy
+ D = − K Td (6.16)
N dt dt
This equation can be approximated in the same way as the integral
term. In this case we approximate the derivatives by a backward differ-
ence.
Td D (tk ) − D (tk−1 ) y(tk ) − y(tk−1 )
+ D (tk ) = − K Td
N h h
241
Chapter 6. PID Control
Td K Td N
D (tk ) = D (tk−1 ) − ( y(tk ) − y(tk−1 )) (6.17)
Td + Nh Td + Nh
Velocity Algorithms
The algorithms described so far are called positional algorithms because
the output of the algorithms is the control variable. In certain cases the
control system is arranged in such a way that the control signal is driven
directly by an integrator, e.g., a motor. It is then natural to arrange the
algorithm in such a way that it gives the velocity of the control variable.
The control variable is then obtained by integrating its velocity. An al-
gorithm of this type is called a velocity algorithm. A block diagram of a
velocity algorithm for a PID controller is shown in Figure 6.18.
Velocity algorithms were commonly used in many early controllers
that were built around motors. In several cases, the structure was re-
tained by the manufacturers when technology was changed in order to
maintain functional compatibility with older equipment. Another reason
is that many practical issues, like wind-up protection and bumpless pa-
rameter changes, are easy to implement using the velocity algorithm. This
is discussed further in Sections 6.5 and 6.7. In digital implementations
velocity algorithms are also called incremental algorithms.
Incremental algorithm
The incremental form of the PID algorithm is obtained by computing the
time differences of the controller output and adding the increments.
242
6.7 Computer Implementation
s2 KTd
ed
1+ sTd / N
External
du integrator
dt
ep sK Σ 1
s
u
e K
Ti
One advantage with the incremental algorithm is that most of the com-
putations are done using increments only. Short word-length calculations
can often be used. It is only in the final stage where the increments are
added that precision is needed.
243
Chapter 6. PID Control
A
e 1 u
K s
s
B
e u
K s Σ 1
s
+ −
Σ
+
ub
as
∆ u(t) = u(t) − u(t − h) = K e(t) + ub − u(t − h)
where h is the sampling period.
Feedforward control
In feedforward control, the control signal is composed of two terms,
u = uF B + uF F
244
6.7 Computer Implementation
the windup problem. These strategies do, however, lead to a less effective
feedforward.
Incremental algorithms are efficient for feedforward implementation.
By first adding the increments of the feedback and feedforward compo-
nents,
∆u = ∆uF B + ∆uF F
and then forming the control signal as
windup is avoided. This requires that the feedback control blocks have
inputs for feedforward signals.
Operational Aspects
Practically all controllers can be run in two modes: manual or automatic.
In manual mode the controller output is manipulated directly by the
operator, typically by pushing buttons that increase or decrease the con-
troller output. A controller may also operate in combination with other
controllers, such as in a cascade or ratio connection, or with nonlinear
elements, such as multipliers and selectors. This gives rise to more oper-
ational modes. The controllers also have parameters that can be adjusted
in operation. When there are changes of modes and parameters, it is es-
sential to avoid switching transients. The way the mode switchings and
the parameter changes are made depends on the structure chosen for the
controller.
245
Chapter 6. PID Control
+
MCU
–
M 1 u
A s
y sp
Inc PID
y
+
MCU
–
M u
Σ
A
y sp
PD
y 1
1+ sTi
Figure 6.21 Bumpless transfer in a PID controller with a special series imple-
mentation.
PD
A
M
A
∆I u
1
+
Σ Σ
s
−
M
− +
Σ
Figure 6.22 A PID controller where one integrator is used both to obtain integral
action in automatic mode and to sum the incremental commands in manual mode.
246
6.7 Computer Implementation
1
Σ
Tt +
–
+ 1 1
− Tm
Σ s
y sp
PD
y
M
e K 1 u
Ti
Σ s Σ
A
– +
Σ
1
Tt
Figure 6.23 PID controller with parallel implementation that switches smoothly
between manual and automatic control.
247
Chapter 6. PID Control
Zt
xI = e(τ )dτ
K
I= xI
Ti
248
6.7 Computer Implementation
Track
Σ
1
Tt
Manual 1 1
Tm
Σ
s
TR
M
M
Computer Code
As an illustration, the following is a computer code for a PID algorithm.
The controller handles both anti-windup and bumpless transfer.
"Compute controller coefficients
bi=K*h/Ti "integral gain
ad=(2*Td-N*h)/(2*Td+N*h)
bd=2*K*N*Td/(2*Td+N*h) "derivative gain
a0=h/Tt
"Control algorithm
r=adin(ch1) "read setpoint from ch1
y=adin(ch2) "read process variable from ch2
249
Chapter 6. PID Control
TR M
Manual M
input
Manual TR
M
set point M
External
M
set point SP
Measured MV PID
value TR A
The computation of the coefficients should be done only when the con-
troller parameters are changed. Precomputation of the coefficients ad, ao,
bd, and bi saves computer time in the main loop. The main program must
be called once every sampling period. The program has three states: yold,
I, and D. One state variable can be eliminated at the cost of a less readable
code. Notice that the code includes derivation of the process output only,
proportional action on part of the error only (b = 1), and anti-windup.
6.8 Summary
In this Section we have given a detailed treatment of the PID controller,
which is the most common way controller. A number of practical issues
have been discussed. Simple controllers like the PI and PID controller
are naturally not suitable for all processes. The PID controller is suit-
able for processes with almost monotone step responses provided that the
250
6.8 Summary
251