The PID Control Algorithm
worked for Duke Power Company in Charlotte, N. C. and for Taylor Instrument
Company (now part of ABB, Inc.) in, N. Y. Rochester He is the author of over 20
articles and papers and continues to live in Rochester. Copyright 2003, John A. Shaw, All rights reserved. This work may not be resold,
either electronically or on paper. Permission is given, however, for this work to be
distributed, on paper or in digital format, to students in a class as long as this
copyright notice is included. Introduction iii
Table of Contents
Chapter 1 Introduction.....................................................................1
1.1 The Control Loop........................................................2
1.2 Role of the control algorithm.......................................3
1.3 Auto/Manual ...............................................................3
Chapter 2 The PID algorithm...........................................................5
2.1 Key concepts...............................................................5
2.2 Action .........................................................................5
2.3 The PID responses.......................................................5
2.4 Proportional.................................................................6
2.5 Proportional—Output vs. Measurement.......................7
6.7 Flow loops.................................................................42
Chapter 7 Multiple Variable Strategies..........................................44
Chapter 8 Cascade.........................................................................45
8.1 Basics........................................................................45 Introduction iv
8.2 Cascade structure and terminology ............................47
8.3 Guideline for use of cascade......................................47
8.4 Cascade Implementation Issues .................................48
8.5 Use of secondary variable as external feedback .........51
8.6 Tuning Cascade Loops ..............................................52
Chapter 9 Ratio .............................................................................53
9.1 Basics........................................................................53
9.2 Mode Change ............................................................54
9.3 Ratio manipulated by another control loop.................54
9.4 Combustion air/fuel ratio...........................................55
Chapter 10 Override ....................................................................57
10.1 Example of Override Control.....................................57
10.2 Reset Windup............................................................58
10.3 Combustion Cross Limiting.......................................59
Chapter 11 Feedforward ..............................................................61
Chapter 12 Bibliography..............................................................62
Introduction v
Table of Figures
Figure 1 Typical process control loop – temperature of heated water...............1
Figure 30 Process with multiple lags............................................................... 30
Figure 31 The step response for different numbers of lags............................... 31
Figure 32 Pseudo dead time and process time constant.................................... 32
Figure 33 Level control................................................................................... 33
Figure 34 Quarter wave decay......................................................................... 34
Figure 35 Overshoot following a set point change........................................... 35
Figure 36 Disturbance Rejection..................................................................... 35
Figure 37 Integration of error.......................................................................... 35
Figure 38 The Ziegler-Nichols Reaction Rate method..................................... 37
Figure 39 Tangent method. ............................................................................. 37
Figure 40 The tangent plus one point method.................................................. 38
Figure 41 The two point method. .................................................................... 39 Introduction vi
Figure 42 Constant amplitude oscillation. ....................................................... 40
Figure 43 Pseudo dead time and lag................................................................ 42
Figure 44 - Heat exchanger................................................................................ 45
Figure 45 - Heat exchanger with single PID controller....................................... 46
Figure 46 - Heat exchanger with cascade control. .............................................. 47
Figure 47 - Cascade block diagram.................................................................... 47
Figure 48 - The modes of a cascade loop. .......................................................... 49
Figure 49 - External Feedback used for cascade control..................................... 51
Figure 50 – Block Diagram of External Feedback for Cascade Loop ................. 52
Figure 51 - Simple Ratio Loop........................................................................... 53
Figure 52 – PID loop manipulates ratio.............................................................. 54
Figure 53 - Air and Fuel Controls ...................................................................... 56
Figure 54 - Override Loop................................................................................. 58
Figure 55 - External Feedback and Override Control ......................................... 59
Figure 56 - Combustion Cross Limiting............................................................. 60
single input, single output loops. Later we will discuss some multiple loop control
methods.
There are a number of algorithms that can be used to control the process. The
most common is the simplest: an on/off switch. For example, most appliances use
a thermostat to turn the heat on when the temperature falls below the set point and
then turn it off when the temperature reaches the set point. This results in a
cycling of the temperature above and below the set point but is sufficient for most
common home appliances and some industrial equipment.
Introduction 2
To obtain better control there are a number of mathematical algorithms that
compute a change in the output based on the controlled variable. Of these, by far
the most common is known as the PID (Proportional, Integral, and Derivative)
algorithm, on which this publication will focus.
First we will look at the PID algorithm and its components. We will then look at
the dynamics of the process being controlled. Then we will review several
methods of tuning (or adjusting the parameters of) the PID control algorithm.
Finally, we will look as several ways multiple loops are connected together to
perform a control function.
1.1 THE CONTROL LOOP
The process control loop contains the following elements:
• The measurement of a process variable
. A sensor, more commonly known as a
transmitter, measures some variable in the process such as temperature, liquid
level, pressure, or flow rate, and converts that measurement to a signal
(typically 4 to 20 ma.) for transmission to the controller or control system.
• The control algorithm
. A mathematical algorithm inside the control system is
executed at some time period (typically every second or faster) to calculate the
output signal to be transmitted to the final control element.
likely controlled by some other loop. The temperature of the cold water being
heated is a load variable. If the process is outside, the ambient temperature
and weather (rain, wind, sun, etc.) are load variables outside of our control. A
change in a load variable is a disturbance.
Other measured variables may be displayed to the operator and may be of
importance, but are not a part of the loop.
1.2 ROLE OF THE CONTROL ALGORITHM
The basic purpose of process control systems such as is two-fold: To manipulate
the final control element in order to bring the process measurement to the set
point whenever the set point is changed, and to hold the process measurement at
the set point by manipulating the final control element. The control algorithm
must be designed to quickly respond to changes in the set point (usually caused by
operator action) and to changes in the loads (disturbances). The design of the
control algorithm must also prevent the loop from becoming unstable, that is,
from oscillating.
1.3 AUTO/MANUAL
Most control systems allow the operator to place individual loops into either
manual or automatic mode.
In manual mode the operator adjusts the output to bring the measured variable to
the desired value. In automatic mode the control loop manipulates the output to
hold the process measurements at their set points. Introduction 4
Setpoint
Manual
Mode
Output
∆
Measured
• The PID algorithm must be “tuned” for the particular process loop.
Without such tuning, it will not be able to function.
To be able to tune a PID loop, each of the terms of the PID equation must be
understood. The tuning is based on the dynamics of the process response and is
will be discussed in later chapters.
2.2 ACTION
The most important configuration parameter of the PID algorithm is the action.
Action determines the relationship between the direction of a change in the input
and the resulting change in the output. If a controller is direct acting, an increase
in its input will result in an increase in its output. With reverse action an increase
in its input will result in a decrease in its output.
The controller action is always the opposite of the process action.
2.3 THE PID RESPONSES
The PID control algorithm is made of three basic responses, Proportional (or
gain), integral (or reset), and derivative. In the next several sections we will
discuss the individual responses that make up the PID controller.
In this book we will use the term called “error” for the difference between the
process and the set point. If the controller is direct acting, the set point is
subtracted from the measurement; if reverse acting the measurement is subtracted
from the set point. Error is always in percent.
Error = Measurement-Set point (Direct action)
Error = Set point-Measurement (Reverse action) The PID algorithm 6
2.4 PROPORTIONAL
The most basic response is proportional, or gain, response. In its pure form, the
output of the controller is the error times the gain added to a constant known as
“manual reset”.
Output = E x G + k
Gain
Decr.
Incr.
Figure 6 A lever used as a proportional only reverse acting
controller. The PID algorithm 7
2.5 PROPORTIONAL—OUTPUT VS. MEASUREMENT
One way to examine the response of a control algorithm is the open loop test. To
perform this test we use an adjustable signal source as the process input and
record the error (or process measurement) and the output.
As shown below, if the manual reset remains constant, there is a fixed relationship
between the set point, the measurement, and the output.
Time
Output
Error
%
%
Figure 7 Proportional only controller: error vs. output over time.
2.6 PROPORTIONAL—OFFSET
Proportional only control produces an offset. Only the adjustment of the manual
reset removes the offset.
Take, for example, the tank in Figure 8 with liquid flowing in and flowing out
under control of the level controller. The flow in is independent and can be
considered a load to the level control.
The flow out is driven by a pump and is proportional to the output of the
amount of gain that can be used. If this limit is exceeded the loop will oscillate.
2.7 PROPORTIONAL—ELIMINATING OFFSET WITH MANUAL
RESET
Offset can also be eliminated by adjusting manual reset. In the above example
(with a gain of two) if the operator increased the manual reset the valve would
open further, increasing the flow out. This would cause the level to drop. As the
level dropped, the controller would bring the valve closed. This would stabilize
the level but at a level lower than before. By gradually increasing the manual reset
the operator would be able to bring the process to the set point. The PID algorithm 9
2.8 ADDING AUTOMATIC RESET
With proportional only control, the operator “resets” the controller (to remove
offset) by adjusting the manual reset:
Setpoint
Output = e
×
G + Manual Reset
∆
Measured
Variable
e
Process
Σ
× Gain
e
×
G
constant. However, if the error is non-zero the output will continue to change until
it has reached a limit. The rate that the output ramps up or down is determined by
the time constant of the lag and the amount of the error and gain.
2.9 INTEGRAL MODE (RESET)
If we look only at the reset (or integral) contribution from a more mathematical
point of view, the reset contribution is:
Out = g × K
r
×
⌡
⌠
e dt
where g = gain
K
r
= reset setting in repeats per minute.
At any time the rate of change of the output is the gain time the reset rate times
the error. If the error is zero the output does not change; if the error is positive the
output increases. The PID algorithm 11
Shown below is an open loop trend of the error and output. We would obtain this
trend if we recorded the output of a controller that was not connected to a process
while we manipulated the error.
Time
Output
Error
%
%
%
0
+10
-10
Gain effect
Reset effect
τ
r
1 “Repeat” time
Figure 12 Calculation of repeat time
We can see two distinct effects of the change in the error. At the time the error
changed the output also changed. This is the “gain effect” and is equal to the
product of the gain and the change in the error. The second effect (the “reset
effect”) is the ramp of the output due to the error. If we measure the time from
when the error is changed to when the reset effect is equal to the gain effect we
will have the “repeat time.” Some control vendors measure reset by repeat time
(or “reset time” or “integral time”) in minutes. Others measure reset by “repeats
per minute.” Repeats per minute is the inverse of minutes of repeat.
2.11 DERIVATIVE
Derivative is the third and final element of PID control. Derivative responds to the
rate of change of the process (or error). Derivative is normally applied to the
process only). It has also been used as a part of a temperature transmitter (“Speed-
Act™” - Taylor Instrument Companies) to overcome lag in transmitter
measurement. Derivative is also known as Preact™ (Taylor) and Rate.
The derivative contribution can be expressed mathematically:
Out = g × K
d
×
de
is higher than the dashed line for the time that the process is increasing due the
addition of the rate of change to the gain effect. We can also look at the solid line
as being “leading” the dashed line by some amount of time (
τ
d
).
The amount of time that the derivative action advances the output is known as the
“derivative time” (or Preact time or rate time) and is measured in minutes. All
major vendors measure derivative the same: in minutes. The PID algorithm 14
2.12 COMPLETE PID RESPONSE
If we combine the three terms (Proportional gain, Integral, and Derivative) we
obtain the complete PID equation.
Setpoint
Manual
Reset
Output
∆
Measured
Variable
×
G
e
Σ
e×G
d
dt
CHAPTER 3 IMPLEMENTATION DETAILS OF THE PID
EQUATION
The description of the PID algorithm shown on the previous page is a “text book”
form of the algorithm. The actual form of the algorithm used in most industrial
controllers differs somewhat from the equation and diagram of shown on the
previous page.
3.1 SERIES AND PARALLEL INTEGRAL AND DERIVATIVE
The form of the PID equation shown Figure 14, which is the way the PID is often
represented in text books, differs from most industrial implementations in the
basic structure. Most implementations place the derivative section in series with
the integral or reset section.
We can modify the diagram shown above to reflect the series algorithm:
Setpoint
Output
∆
Measured
Variable
× G
e
Σ
e×G
Σ
dt
D
d
dt
R
Figure 15 The series form of the complete PID response.
Unless derivative is used there is no difference between the parallel (non-
interactive) and series (interactive) forms.
3.2 GAIN ON PROCESS RATHER THAN ERROR
The gain causes the output to change by an amount proportional to the change in
the error. Because the error is affected by the set point, the gain will cause any
change in the set point to change the output.
This can become a problem in situations where a high gain is used where the set
point may be suddenly changed by the operator, particularly where the operator
enters a new set point into a CRT. This will cause the set point, and therefore the
output, to make a step change.
In order to avoid the sudden output change when the operator changes the set
point of a loop, the gain is often applied only to the process. Set point changes
affect the output due to the loop gain and due to the reset, but not due to the
derivative.
3.3 DERIVATIVE ON PROCESS RATHER THAN ERROR
The derivative acts on the output by an amount proportional to the rate of change
of the error. Because the error is affected by the set point, the derivative action
will be applied to the change in the set point.
This can become a problem in situations where the set point may be suddenly
changed by the operator, particularly in situations where the operator enters a new
set point into a CRT. This causes the set point to have a step change. Applying
derivative to a step change, even a small step change, will result in a “spike” on
the output.
In order to avoid the output spike when the operator changes the set point of a
loop, the derivative is often applied only to the process. Set point changes affect
the output due to the loop gain and due to the reset, but not due to the derivative.
Most industrial controllers offer the option of derivative on process or derivative
on error.
3.4 DERIVATIVE FILTER
The form of derivative implemented in controllers also includes filtering. The
×+××=
2
2
dt
Errord
DerivativeErrorsetRateReGain
dt
dOut
This program is run every second. If the control loop is in manual, the output is
adjusted by the operator through the operator interface software. If the control
loop is in Automatic, the output is computed by the PID algorithm.
Each pass the output is changed by adding the change in output to the previous
pass output. That change is found by adding:
•
the change in error (Err-ErrLast)
•
the error multiplied by the reset rate, and
•
the second derivative of the error (Err-2*ErrLast+ErrLastLast) times the
derivative.
The total is then multiplied by the gain.
This simple version of the PID controller work well in most cases, and can be
tuned by the standard PID tuning methods (some of which are discussed later). It
has “Parallel” rather than “Series” reset and derivative, and derivative is applied
to the error rather than the input only.
Variables:
Input Process input
InputD Process input plus derivative
InputLast Process input from last pass, used in deriv. calc.
9. ErrLastLast=ErrLast
10. ErrLast=Err
11. ELSE
12. InputLast=Input
While loop in manual, stay ready for bumpless switch to Auto.
13. ErrLastLast=Err
14. ErrLast=Err
15. ENDIF
16. IF OutP > 100 THEN OutP=100
Limit output to between
17. IF OutP < 0 THEN OutP=0
0 and 100 percent
The only serious problem with this form of the algorithm occurs when the output
has reached an upper or lower limit. When it does, a change in the measurement
can unexpectedly pull the output away from the limit. For example, Figure 16
illustrates the set point, measurement, and output of an open loop direct acting
controller with a high gain and slow reset. When the input (blue line) rises above
the set point (red line) the output (green line) first increases due to the
proportional response and then continues to ramp up due to the reset response.
The ramp ends when the output is limited at 100%.
Note the spike (noise) in the input at about 5 minutes. That spike results in a spike
in the output, in the same direction. Compare this with the similar spike at about
61 minutes. Rather than cause an upward output spike as expected, the spike
causes the output to pull away from the upper limit. It slowly ramps back to the
limit. This is because the limit blocks the leading (increasing) side of the spike but
does nothing to the trailing (decreasing) side of the spike.
0