SNAP PAC PID Control Tutorial
SNAP PAC PID Control Tutorial
Wired+Wireless controllers and brains and N-TRON wireless access points are licensed under one or more of the following
patents: U.S. Patent No(s). 5282222, RE37802, 6963617; Canadian Patent No. 2064975; European Patent No. 1142245;
French Patent No. 1142245; British Patent No. 1142245; Japanese Patent No. 2002535925A; German Patent No. 60011224.
Opto 22 FactoryFloor, Optomux, and Pamux are registered trademarks of Opto 22. Generation 4, ioControl, ioDisplay,
ioManager, ioProject, ioUtilities, mistic, Nvio, [Link] Web Portal, OptoConnect, OptoControl, OptoDataLink, OptoDisplay,
OptoEMU, OptoEMU Sensor, OptoEMU Server, OptoOPCServer, OptoScript, OptoServer, OptoTerminal, OptoUtilities, PAC
Control, PAC Display, PAC Manager, PAC Project, SNAP Ethernet I/O, SNAP I/O, SNAP OEM I/O, SNAP PAC System, SNAP
Simple I/O, SNAP Ultimate I/O, and Wired+Wireless are trademarks of Opto 22.
ActiveX, JScript, Microsoft, MS-DOS, VBScript, Visual Basic, Visual C++, Windows, and Windows Vista are either registered
trademarks or trademarks of Microsoft Corporation in the United States and other countries. Linux is a registered
trademark of Linus Torvalds. Unicenter is a registered trademark of Computer Associates International, Inc. ARCNET is a
registered trademark of Datapoint Corporation. Modbus is a registered trademark of Schneider Electric. Wiegand is a
registered trademark of Sensor Engineering Corporation. Nokia, Nokia M2M Platform, Nokia M2M Gateway Software, and
Nokia 31 GSM Connectivity Terminal are trademarks or registered trademarks of Nokia Corporation. Sony is a trademark of
Sony Corporation. Ericsson is a trademark of Telefonaktiebolaget LM Ericsson. CompactLogix, MicroLogix, SLC, and RSLogix
are trademarks of Rockwell Automation. Allen-Bradley and ControlLogix are a registered trademarks of Rockwell
Automation. CIP and EtherNet/IP are trademarks of ODVA.
All other brand or product names are trademarks or registered trademarks of their respective companies or organizations.
Chapter 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How to Use This Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Skills You’ll Learn in this Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Lesson 1: Basic PID Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
Lesson 2: Understanding Proportional, Integral, and Derivative . . . . . . . . . . . . . . . . . . .2
What You Need. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
SNAP PAC Learning Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Purchasing a SNAP PAC Learning Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Downloading Sample Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Creating a Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Ready for the Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
For Those Who Can’t Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Configuring a PID Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Features of the PID Inspect Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
PID Debug Mode—Plot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Features of the Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Moving a Plot’s Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Displaying Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Changing the Cursor Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Using Delta-X and Delta-Y Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Resetting Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
PID Debug Mode—I/O Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PID Debug Mode—Misc. Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Debug PID—IVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Debug PID—Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
PID Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Defining a New Control Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
1: Introduction
NOTE: This probe is referred to as a “temperature sensor” in the SNAP PAC Learning Center Guide
Figure 1-1: SNAP PAC Learning Center and its PID simulator
To use this tutorial, make sure your PID simulator is connected and that all the analog points
and wiring are connected as described in the SNAP PAC Learning Center Guide (form 1638).
Getting Started
Creating a Strategy
You will need a strategy to configure and tune a PID loop; but once it’s configured, the PID
loop runs independently of a strategy. In other words, you can run a PID loop without any
flowchart logic in your strategy.
1. From the Windows Start menu, select Programs > Opto 22 > PAC Project > PAC Control
Basic
c. In the Create New Strategy dialog box, type PID Tutorial and click Open.
c. Navigate to the directory where you stored your sample tag database. For example,
c:\Program Files\Opto22\SNAP PAC Learning Center
Control engine
It is essential that points 09 and 12 are configured. The configuration for these points is
shown below:
Point 09, Heater
Once the basic configuration settings are made, the following must be done:
• The strategy must be downloaded to the SNAP PAC.
• The strategy must be run to save the PID configuration to the I/O unit.
• The Mode must be set to Auto. (Auto is the default setting.)
• Communication with PAC Control must be Enabled. (Enabled is the default setting.)
Concepts
What is PID?
A proportional integral derivative (PID) control system monitors a process variable,
compares the process variable to a setpoint, and calculates an output to correct any
difference (error) between the setpoint and process variable. The mathematical formulas
that do this vary, but all PID systems share fundamental concepts:
• They evaluate a process variable against its setpoint.
• They control an output to reduce the difference between the process variable and
setpoint.
• The output is the result of proportional, integral, and derivative calculations.
• The effects of proportional, integral, and derivative calculations are modified by
user-determined P, I, and D constants.
• The P, I, and D constants need to be adjusted (or tuned) for each system.
In the SNAP PAC R, both PAC Control and PID run on the same hardware, but the two parts
remain independent.
In this tank heating system, the process variable (PV) is the temperature of the tank. The
setpoint is supplied by a thermostat. The controller compares the setpoint to the process
variable and decides the appropriate output to achieve the setpoint. But the system
becomes complex because of the following:
• The output of the PID loop must be scaled to the output device. For example, to turn
up the heat, the controller must convert a difference in temperature to a setting on a
gas valve controlling a heater. Increasing the temperature by 10 degrees may mean
opening the gas valve by 10%, 5%, or 50%—this varies according to the device.
• The difference between the setpoint and the process variable is called the error. This
error is changing in time, so the controller output must also be changing to avoid
overshooting the setpoint.
• A PID algorithm not only maintains a process variable at a setpoint; it must also react to
disturbances, which are external factors affecting the stability of the system. Typical
disturbances are a change in load (for example, filling the tank) or a change in setpoint.
• Equipment and safety limitations may restrict how quickly you can change a setting in
the output device or what conditions determine when the output device can be
turned on or off.
• The range of valid input for the process variable should be defined so the PID can
properly react to or ignore out-of-range inputs.
70° F 70
Input to PID
80 80 degrees
NOTE: PAC Control calculates error by subtracting the Setpoint from the Process Variable. This
calculation creates a negative error when the Process Variable is below the setpoint. This mode
is used for “pump-up” control, such as maintaining level, pressure, flow, and heating.
Process
Variable Process variable
System disturbance,
restored to setpoint
e.g., tank is filled
0° F
Time
Output Variable
Gas valve 80% open
100%
Output
0%
Time
Gas valve 20% open
In these graphs, the Y-axis represents the values of the process variable, setpoint, and
controller output. The X-axis represents time. The X-axis is shown with demarcations for
units of time. Though the process variable is changing continuously, the controller only
knows its value when the process variable is scanned. The vertical lines represent the scan
interval, which is an important component in configuring a PID loop.
Error at time
of scan
Setpoint
Process Variable
(Input)
Time
Output
(Correction) Controller output at time of scan
Time
Scan
interval
Figure 2-4: Actual Values of Process Variable, Setpoint, and Output over Time
NOTE: The input change is truly continuous, as it is shown here. The output,
however, is a step shape. At each scan, the controller sets an output value that
continues unchanged until the next scan.
Figure 2-4 shows how the configured scan interval affects the controller output. With
shorter scan intervals, the output graph resembles a continuous curve, with frequent
controller adjustment and therefore better control of the process variable. Setting an
appropriate scan interval is critical to successful PID tuning.
To summarize, Figures 2-1 through 2-4 show the following concepts relevant to PID
configuration and tuning:
• Setpoint, process variable, output, and scan interval are the key components of the
system.
• Setpoint can be from an input device or any variable accessible to the controller.
• The output device can be a physical device that effects change, or it can be used as the
input or setpoint to another PID. In this example, the output controls a heater.
• The setpoint and process variable are on the same scale.
• The output device (heater) may be on the same scale as the process variable and the
setpoint, but often it is not.
• Scan interval is the interval at which the controller evaluates the process variable
against the setpoint and calculates the output.
System is stable
Controller
Output
Change in process variable observed
Process
Variable
A scan interval should be shorter than one-third of the system dead time, measured by
changing the output in a stable system. This formula is not absolute, as any system may
have qualities that determine the scan interval.
Change in
Output
System dead time
Stable system
Process
Variable
Controller
Output
For example, equipment limitations may require longer intervals. In many systems,
however, the scan interval is faster than the time required to observe a change in the
process variable, which can cause the controller to overcorrect. Any overcorrection can be
removed with proper tuning of the PID, which is explained in Lesson 2.
In Activity 1, you will configure a PID loop controlling a heating system and observe the lag
in this system. This activity will provide practice with using the PID in manual mode and
with manipulating its plot.
Preparation
1. Start PAC Control.
2. Open your strategy.
Configure PID
You will configure only the basic components needed to observe system dead time.
Configuring additional features may interfere with determining the system dead time. For
example, you do not want your PID loop to exercise any control, so you will want to be in
Manual mode. Rather, you just want to plot the input (process variable), setpoint, and
output (controller output).
1. Select Mode > Configure.
2. Open PID Loop configuration.
a. In the strategy tree, right-click the PIDs folder.
c. Select the first loop (which should be selected by default) and click Add.
3. Enter PID configuration settings.
a. Type or select the following configuration information (some of these will be
selected as defaults):
– Name: Control_Tank_Temperature
– Input: Select I/O Point from the first list and Temperature from the second list
– Low Range: 0
– High Range: 100
– Setpoint: Select Host from the first list and type 0 in the initial value field
– Output: Select I/O Point from the first list and Heater from the second list
– Lower Clamp: 0
– Upper Clamp: 100
– Mode: Manual
– Scan Rate: 1
Notice change in both the PID Input and PID Output graphs.
It takes a few minutes for your system to stabilize. Viewing the input graph at a finer
resolution helps you know when the system has stabilized.
b. If your graph has stopped tracking, which can happen when focus is on any of the
tuning fields, choose Reset Scale Tracking from the Time Axis menu (or click the
graph).
Until you are familiar with the PID plot, it is recommended that you avoid using the
shortest settings (10 seconds or 1 second) for the time axis. After you’ve observed a
change in the input, you can zoom in on the graph, which is described later.
Note: If your temperature doesn’t stabilize, a likely cause is a varying room temperature. Make
sure your PID simulator probe is not too near to a heating or cooling outlet.
Observe the graph of the input field. The system is stable when the input value does
not vary significantly (some drift in the input value can be expected). Stabilization may
take several minutes, depending on the type of system.
8. Under the Time Axis menu, choose Reset.
a. Click the Time Axis button.
b. Click Reset Scale Tracking.
This is a precautionary step, as changing settings on the plot can cause the trend to
stop plotting data. Resetting the time axis ensures that you are viewing the real-time
values.
NOTE: Be prepared to do the following step quickly. In Step 9 you change the output. A
change in the input will occur within a couple of seconds. As soon as you see a change in
input, you will click and drag the time axis (X-Axis), which will stop the plot so you can closely
examine the system dead time.
c. Click and drag the Time Axis (X-Axis) so that the plot shows the change in output
and the change in input.
10. Display a Delta X cursor.
a. From the Data menu, select Cursor.
The Delta X cursor displays the time difference between the two vertical bars.
3: Understanding Proportional,
Integral, and Derivative
Concepts
PID Controller
Process Calculate Error
Variable (PV)
(Input)
Setpoint
A successful PID loop requires well-chosen constants for gain, integral, and sometimes
derivative (many loops work with P and I constants only). Choosing your constants is part
understanding their role in the PID algorithm (explained in this tutorial) and part trial and
error, a process referred to as tuning.
The SNAP PAC offers five PID algorithms:
• Velocity Type B (the default type)
• Velocity - Type C (available only for PAC-R, EB, and SB with firmware version 8.5e and
higher)
• ISA
• Parallel
• Interacting
The offering of five algorithms illustrates that there is no one formula for PID control. Each
algorithm has unique qualities, but the general concepts of proportional, integral, and
derivative, and tuning constants, is similar across all. The following discussion describes
generalizations of the effect of P, I and D components of the calculation. Specific attributes
of the calculation will be explained as well.
E = Error
P = Proportion constant
P constant can be positive, negative,
whole number, or fraction. CO = Controller output
Output
response
Setpoint (Heater)
Input: Temperature
Setpoint
Input: Temperature
Gain multiplies P
and I terms.
Figure 3-1: Portions of the PID Algorithms Showing the Use of the
Gain-Tuning Constant
NOTE: These are parts of the algorithms selected to emphasize the role of the
gain-tuning constant. In these parts of the algorithms, Velocity B and Velocity C are the
same. For the complete algorithms, see “PID Algorithms.” on page 79.
If process
variable is: Error is: Controller output is:
65 –5 –2 10
60 –10 –2 20
55 –15 –2 30
Heat 50 –20 –2 40
So in this example, the controller output matches the heat needed to maintain the
temperature's current status. There is no guarantee that this equilibrium occurs at the
setpoint. If it did, it would do so for one load, one setpoint, and one gain setting. If setpoint,
load, or both change, an offset would still occur.
Setpoint Steady-state
error, or offset
Controller
Output
Understanding Integral
In some systems it may be possible to increase the gain to reduce the offset error, but
usually it is better to use an integral term. For example, if you are using the Learning Center’s
PID probe at room temperature with a setpoint 5 degrees above room temperature, you
may see little performance improvement among gain settings of -10, -20, and -30.
However, by giving the I tuning constant a positive value, such as 0.5, you enable the
calculation that generates an I term.
The I term affects the controller output by increasing or decreasing the value that would be
produced by gain alone. (The I constant doesn’t need to be high, sometimes just enough to
get the integral factored into the calculation.)
Generally, the I term modifies the controller output as shown in Figure 3-13.
Cumulative error at
time of scan
Setpoint Steady-state
error, or offset
Controller
Output
Setpoint
Mathematical
Integral
The integral is the area between the setpoint
and the process variable.
Each of the available algorithms calculates an I Term, which determines the extent to which
error over time (accumulated error) influences the controller output. Also, each of these
calculations approximates the integral measurement. For example, the Velocity algorithms
estimate integral by multiplying the scan interval by the error.
Error
Process
Variable
Current
Integral
The approximation is due to the scan interval: an infinitely fast scan interval would produce
a perfect integral, but such a scanning rate is not practical. In addition, the influence of the I
term must be tunable.
The influence of the I Term in the Velocity B and C algorithms is calculated with this
equation:
Term I = Tune I * System Interval * Err.
Term I is 0 until a positive Tune I constant is provided. (NOTE: Tune I must be a positive
number.)
The Interacting, ISA, and Parallel algorithms estimate integral by measuring the
accumulated error from the current and previous scans.
Setpoint
Process
Variable Error
Integral = 36 + 3 = 38
Current
Integral Integral = 29 + 7 = 36
Integral = 20 + 9 = 29
Integral = 10 + 10 = 20
Integral = 0 + 10 = 10
The influence of the I term in the Interacting, ISA, and Parallel algorithms is calculated in
these two equations:
Integral = Integral + Error
Term I = Tune I * System Interval * Integral
Term I is 0 until a Tune I constant is provided. Tune I must be a positive number.
With typical scan rates of 0.1 seconds, none of these algorithms measures the true
mathematical integral. Nor do they need to, because the Tune I constant determines how
effective Term I is in the particular application. This setting is not determined
mathematically, but empirically, by watching the effect of various settings in your PID
system.
Integral Windup
The Integral component of a PID calculation looks at the error over time. This allows the
Integral to efficiently correct for offset. However, there are times when the cumulative error
is not relevant to the necessary controller output. In our tank-heating scenario, imagine that
the heater failed overnight and was not repaired until the following morning. After the
repair, the heater runs at 100 percent for a significant length of time. Adding the error
accumulated during the night makes no difference to the output —it’s still at 100 percent
with or without the integral.
Integral Windup
Setpoint
Integral accumulated
Process error
Variable When the system
returns to normal, the
historical error is
Current irrelevant and should be
Integral The historical error at this point discarded.
has no beneficial contribution to
a controller output that is
already at maximum.
Controller
Output
Integral windup refers to an integral measurement that exceeds a practical limit within the
PID calculation. Typically, anytime the controller output exceeds the range of the output
device, the accumulated error is irrelevant or impairs effective control when the system
returns to normal.
The Velocity algorithms measure integral by multiplying the current error by the scan
interval. Because this calculation only considers the current error, the Velocity algorithms do
not suffer from integral windup.
The Velocity Algorithms’ Simplified Integral Calculation Current integral is the scan
interval multiplied by the
Scan interval current error.
Setpoint
Process Error
Variable
Current
Integral
Previous integral
calculations aren't
considered in the
current calculation
In the ISA, Interacting, and Parallel algorithms, the integral measurement is an accumulation
of error. These algorithms have an override function, called anti-integral windup, that is
invoked when the controller output exceeds the range of the output device. (The range of
the output device is set by the PID configuration settings Input–Low Range and Input–High
Range.) The anti-integral windup feature does the following:
• Disables the derivative calculation (if the D tuning constant is not 0) while the output is
out of range.
• Recalculates an integral value to moderate change in output when control is restored
to the PID algorithm. This creates a soft landing; in contrast, the true integral or a zero
integral may cause an abrupt change.
• Maintains a designated output setting (if configured to do so in the output options for
when input is out of range).
• Monitors the process variable in order to relinquish control to the PID algorithm when
the process variable has returned to the valid range.
When anti-integral windup is in effect for the ISA, Parallel, and Interacting algorithms, you
are not able to see the regular PID calculations until the output returns within the range and
control is restored to the algorithm.
2 x Gain
Gain too 1 2 3
high
Optimal
Gain 4 5 6
0.5 x Gain
(Gain too 7 8 9
low)
Figure 3-20 represents nine tests in which a stable system is disturbed by a change in
setpoint. The columns and rows represent the same disturbance but with different gain and
integral tuning constants. Top to bottom rows represent too much gain, optimum gain, and
too little gain. When your system resembles one of the graphs in the second row, you then
try various integral settings. Left to right columns represent too little integral, optimum
integral, and too much integral.
In most systems, best results come from first tuning gain and then integral. The optimal
gain and integral tuning depends on your application.
If your system requires better response to changing loads or better dampening of change,
then apply a derivative constant in addition.
Understanding Derivative
A derivative term is based on the rate of change in the process variable. The measurement
of derivative produces a term that increases or decreases the controller output based on the
speed at which the process variable is approaching or moving away from setpoint.
Mathematically, the derivative is a line that is tangential to the graph of the process variable
at a point in time. By analyzing the slope of the line, which way it points and how steep it is,
the derivative term adjusts the controller output.
Mathematical Derivative
Setpoint
Derivative
contribution will try
to reduce any
over-correction.
Derivative contribution
becomes less influential.
Like integral, a true mathematical derivative may require more processing power than the
PID calculation needs, so the measurement is simplified, and tuning parameters help
correct for the estimate (as well as adjust the algorithm to the unique needs of a real
system).
In the ISA, Parallel and Interacting algorithms, the final D term is based on the slope
multiplied by a ratio of the D tuning parameter to the scan interval.
Scan interval
Setpoint
Process
Variable
Derivative measurement calculates the
slope of a line between the current and
previous process variables.
Previous process
variable Current process
variable
Slope of line
The D constant will either increase or decrease the influence of the slope,
depending on 1) whether Tune D is greater or less than the system
interval, and 2) whether the scan interval is greater than 1.
In the Velocity algorithms, the final D term is based on the difference between the current
slope and the previous slope multiplied by a ratio of the D tuning parameter to the scan
interval. This is similar to the other algorithms, but the last two slopes are considered in the
calculation of the D term.
Process
Variable Previous slope
PV_2
Current slope
PV_1
Scan Interval
Current slope minus
previous slope
Difference between
slopes
The D constant will either increase or decrease the influence of the slope,
depending on 1) whether Tune D is greater or less than the system
interval, and 2) whether the scan interval is greater than 1.
• Try D tune values close to your scan interval, and observe the effects of higher and
lower values.
Gain: –5
A final gain constant will be determined by tuning, but before you can tune your
PID, your gain constant must be either a positive or negative according to the type
of system you have. PAC Control’s PID algorithms calculate error by subtracting
setpoint from the input (PV – Input), therefore producing a negative error when
heat needs to be applied. To convert the error to the appropriate output, gain must
be a negative value.
Tune I: 0
Tune D: 0
b. Click OK to close
the Edit PID Loop
dialog box.
The following steps are based on an ambient temperature of 75° F degrees. Hopefully,
your ambient temperature isn’t too far from this.
4. Change your setpoint.
a. In the Setpoint
field, type a
value that is 5°
F warmer than
ambient
temperature.
For example, if
your ambient
temperature is
75, type 80.
b. Click Apply.
NOTE: You can also choose Center on Setpoint from the Input Axis menu, but you may still
need to drag the scale up or down to show both graphs.
Tune Gain
In tuning the gain, you should be prepared to recognize the following:
• Process instability
• Steady-state error
• Expected workload of your output device
An unstable PID loop will oscillate above and below setpoint, with each oscillation
diverging farther from setpoint. This is unlikely to happen with the Learning Center’s PID
simulator, as the potting of the temperature probe and heat element creates a slow heat
loss and the heating element is not very powerful. With a real application, you must be
careful to reduce the chance of creating an unstable PID loop by starting with low gain
settings and gradually increasing. (In a real application, you may also clamp output and
configure safe settings for when input is out of range.)
You will start with low gain settings, just as in a real application, but you will be evaluating
whether your gain settings produce what you think is a reasonable response from the
controller. For example, if a 5-degree error produces an output of 5 percent, this is less than
what is expected with our heater. It is safe to push our heater to 80 or 100 percent to
respond to our 5-degree load change.
You can raise the gain significantly and never attain the desired control. You need to
recognize when to use an I constant without overshooting the gain.
After you find gain settings that allow the controller to run the range of the output device,
you will look for a tendency for the input (process variable, temperature) to stabilize at the
wrong value. This is steady-state error and an indication that an integral term is needed.
At a gain of –30, you should be able to raise the output to 80 percent or higher. In this
example, the output went out of range briefly before dropping to 35 percent.
A gain of –30 drives the output across the full range of the heater, and the process is
showing a steady-state error. At this point, you can test the gain by trying the 5-degree
load change with gain settings between –10 and –30.
3. Change the setpoint to 70 and wait for your system to stabilize at the ambient
temperature.
This step assumes your ambient temperature is around 75 degrees. If your temperature
is different, choose any setting below ambient temperature that sets the output to 0.
You may need to wait a few minutes for your input to reach ambient temperature.
4. Test a gain of –20.
a. Make sure you wait until the input is stable at room temperature.
b. In the Gain field, type –20.
This value is chosen because it is halfway between –10 and –30, and therefore it
will narrow the range of gain values.
c. In the Setpoint field, type a value 5° F above ambient temperature, for example, 80.
d. Click Apply to apply both changes.
5. Watch the input response and the output.
In the example shown here, the gain of –20 resulted in an initial controller output of about
80 percent, which quickly diminished. If you compare this graph to the graph in Step 2 (on
page 55), you’ll see that gains of –20 and –30 have a similar result: both drive the input to
within 2° F of setpoint. Since a gain of –30 is not more effective than a gain of –20, it’s
reasonable to suspect that we have reached the useful limit of gain. (NOTE: Because of
differences in your environment and equipment, you may achieve this point with a different
gain setting.)
b. Click and drag the lower red cursor to the input graph.
In this example, the steady state error is about 1.5° F below setpoint, and a gain of -20 yields
an output around 80 percent of the range of the output device. At this point it is reasonable
to deploy an integral term to correct for the steady-state error.
In this example, an integral constant of 0.1 corrected the offset and continued to maintain
the input close to setpoint with gradual changes in the output:
If your results are different, try higher or lower integral values, for example, 0.05 or 0.2. Also
be aware that reducing the offset within a degree is acceptable, especially if your ambient
temperature is fluctuating. You do not need to get perfect results, as the final tuning
involves testing the tuning parameters against load changes.
Two of three objectives are being met with these tuning parameters:
• The setpoint is being maintained.
2 x Gain
(Gain too 1 2 3
high)
Optimal
Gain 4 5 6
0.5 x Gain
(Gain too 7 8 9
low)
In this example, the graph most closely resembles graphs 6 and 9, suggesting that the gain
may too low, but integral is definitely too high.
Your results may vary, but you can apply the same method to your PID loop. Identify the
curve that best matches your results, and experiment with changes to gain and integral. It is
recommended that you change only one tuning constant in each test.
5. The following steps will test if higher gain produces a graph more like graph 6. Then,
depending on the results, lower integral will be tested.
6. Repeat load change test with more gain.
a. In the Gain field, type –30
b. In the Setpoint field, type a low setpoint, such as 70
c. Click Apply.
d. Wait for your input to stabilize at ambient temperature.
e. Change the setpoint to create a 5° F load change; for example, if your ambient
temperature is 74° F, change setpoint to 79° F.
The following graphic shows the response to a 5° F load change with the tuning constants
shown.
In many applications, the minor fluctuation around the setpoint is acceptable, and
these applications use gain and integral only. In some applications, the fluctuations at
the setpoint indicate that the gain is too high (too much gain makes a system
unstable) or that a derivative constant is required.
At this point, your PID loop should be well tuned using just the gain and integral
constants. You may wish to try setpoint changes with this integral setting but with
different gain values. For example, compare the graph above with the graph below.
The major difference between these is the gain setting. The gain –30 (above) achieved
a better response to the load change. A gain setting of –20 resulted in a slower
response.
Tune Derivative
Derivative is not necessary for this loop, and it is likely that you will not improve the
loop’s performance with a D tuning constant. But to examine the effect of derivative
constants, do the following:
1. Make sure your PID setpoint is at 5° F above ambient temperature.
(It should be from previous steps.)
2. Set the view the Input Axis to 1 percent of span.
This will allow you to see minor changes affected by the derivative term.
3. Use the Delta-Y Cursor to measure error.
4. Apply D tuning constant.
a. In the Tune D field, type 0.1 and click Apply.
b. Observe the graph for a minute.
5. Try various settings from 0.1 to 10.
For the purpose of examining the derivative term, you may wish to return your Gain
and Integral tuning constants to previous, less-effective settings and then compare
Many PID systems are effectively controlled with Gain and Integral constants only and no Derivative
constant. In this example, the Gain and Integral settings are maintaining the temperature at 0.07 from
setpoint. To demonstrate the effect of the derivative constant, the resolution of the Input axis was
increased to show a 1 percent span. At this resolution, the plot reveals changes of 0.01 degrees F.
The left side of the plot shows the effect of Gain at -30, Integral at 0.1, and no Derivative constant. The
arrow shows when a Derivative constant of 10 was applied. The right side of the plot shows how the
Derivative constant is keeping the input closer to setpoint. However, the biggest difference is the
spikes in the output. Factors to consider are whether it’s more important to have precise adherence to
setpoint or to have steady output. Spikes in the output can cause mechanical stress on your process or
accelerate device failure times.
Follow-up
This tutorial has provided a basic introduction to the concepts behind PID control and some
hands-on practice using PAC Control’s PID features. With the basic skills taught in this
tutorial, you should be able to explore many other features on your own. Here are a few
areas you may wish to start with:
• Repeat the tuning process with each of the four PID algorithms. To select a different
algorithm, return to Configure mode.
• Try Min. Change and Max. Change settings to simulate output devices that need their
operation restricted.
• Experiment with Feed Forward constants.
Reference
• Input: The process variable being monitored by the PID loop. Input options are I/O
Point, Host, or PID Output.
– Choose I/O Point if this PID will get its process variable from an I/O point, and then
choose an I/O point from the drop-down list of configured points (or type a point
name to configure a new point on the same I/O unit).
– Choose Host if this PID will get its process variable from PAC Control, for example,
from a PID or I/O point on another I/O unit, or from a process variable that must be
manipulated before use in the PID loop. Type an initial value for the Input.
– Choose PID if this PID is getting its process variable from the output of another PID
on this brain (used in cascading control loops). Choose a PID from the drop-down
list of configured PID loops on this brain.
• Square Root: If you chose I/O Point or PID for step C, you can check this box if you wish
the error to be calculated based on the square root of the process variable. (This is
applicable to flow control systems where volumetric flow is proportional to the square
root of a signal from a flow transducer.)
• Low Range and High Range: Set the valid range of the process variable by typing a
number for the low range and the high range. This range tells the PID what is valid
input and is also used to create a Span term that aligns the input and output scales;
therefore this range affects the tuning of the PID loop. (Options for responding to
out-of-range input are described under Output options for when input is out of range.)
• Setpoint: Choose the source for the setpoint: I/O point, Host, or PID Output.
– Choose I/O Point if you wish to control the setpoint using a device such as a
potentiometer, and then choose an I/O point from the drop-down list of
configured points (or type a point name to configure a new point).
– Choose Host if you wish to control setpoint using PAC Control or PAC Display™, for
example, from a PID or I/O point on another I/O unit, or from a process variable that
must be manipulated before use in the PID loop. Type an initial value for the Input.
– Choose PID Output if this PID is part of a cascading control system in which
another PID loop on the brain will control the setpoint of this PID Loop.
• Output: Choose the destination for the controller output: I/O Point or Host.
– Choose I/O Point to use an output point to correct the process variable (input),
and then choose an I/O point from the drop-down list of configured points (or type
a point name to configure a new point).
– Choose Host to use the output for controlling the setpoint or input to another PID.
The output can be preset or changed at any time through PAC Control by first
switching to Manual mode. For example, if you have determined that the output
should start at 40 percent whenever the system is activated, switch to Manual mode
and then set the PID output to this value. Then switch back to Auto mode.
• Lower Clamp and Upper Clamp: Set the valid range of the output by typing a
number for the Lower and Upper Clamp. This range tells the PID what is valid output
and is also used to create a Span term that aligns the input and output scales; therefore
this range affects the tuning of the PID loop.
Setting clamps is particularly important if the device controlled by the output signal
has “dead areas” at either end. For example, say the output is scaled 0-10. It is
connected to a valve that begins to open at 1.25 and is “effectively” fully open at 5.75
(even though it may only be 70 percent open). Set Lower Clamp to 1.2 (valve closed)
and Upper Clamp to 5.75 (valve effectively fully open). This prevents reset windup,
potentially resulting in dramatically improved control when the output value has
reached either limit and has to suddenly reverse direction.
The upper and lower clamp settings prevent the output from exceeding a desirable
range. Minimally, these should correspond to the range of an output point (for
example, the heater is scaled to 0 to 100 percent and so the lower and upper clamps
are 0 and 100).
These settings can also be used to ensure that the output device doesn’t shut off (for
example, keeping a heater or circulation pump running regardless of the PID output) or
that the output never reaches a destructively high setting (for example, keeping a
burner or motor below maximum).
• Minimum Change and Maximum Change: (Optional) The minimum and maximum
change allow you to do two things:
– Minimum Change allows you to prevent an output device from turning on until
there is a minimum desirable workload. For example, you may not want the heater
to turn on to correct a 1 degree error, only to quickly turn off again. A value of 0
disables Minimum change.
– Maximum Change allows you to prevent undesirable effects from too drastic a
change in output. For example, you could use this to moderate the increase in a
pump’s output to prevent pipe breakage. A value of 0 disables Maximum Change.
The Minimum Change and Maximum Change are for each scan period, and therefore
these settings may be a factor in choosing your scan rate.
• Output options for when input is out of range: In the event that the input variable
goes out of range, you can instruct the PID to 1) freeze output at the current value, 2)
switch to Manual mode and stay there until PAC Control logic or an operator
intervenes, 3) set output at a desired minimum or maximum, or both 2 and 3 (set the
output and go to Manual mode).
– For 1, leave these options unchecked.
– For 2 only, check Switch to manual mode when input goes out of range.
– For 3 only, check Force output when input is out of range and type output values for
when the input is below or above the range. (NOTE: This action is independent of 2,
meaning the output can be forced and the PID can be switched to Manual mode;
however, when the PID is being operated in Manual mode, this feature is not
active.)
– For 2 and 3, check both options and type out-of-range values.
Add Watch allows you to select the following PID values for inclusion in a Watch
Window: input, setpoint, output, gain, integral constant, derivative constant,
system interval and mode.
Displaying Cursors
Choose Cursor under the Data menu to display numeral data. Cursors allow you to drag
vertical or horizontal lines to identify Input, Setpoint, Output, or Time values. Once
displayed you can drag the red line to the desired place on the plot.
Resetting Tracking
When you manipulate the time axis of the cursors, the plot remains as a fixed point. To
restore the view of the current values, choose Reset Scale Tracking under the Time Axis
menu.
Debug PID—IVAL
The IVAL tab shows the difference between the PID XVALs and IVALs:
• The XVAL, or external value, is the “real” or hardware value as seen by the I/O unit. This
value is external to the control engine.
• The IVAL, or internal value, is a logical or software copy of the XVAL that is in the control
engine. The IVAL may or may not be current, since it is updated to match the XVAL only
when a strategy in the control engine reads from or writes to a PID. In the example
below, the Setpoint is configured to Host, so it has an IVAL.
This is a view of the PID IVALs while a strategy is running. The strategy reads the Input
value (PAC Control command Get PID Input), which updates all of the PID IVALs.
Debug PID—Algorithm
PID Algorithms
OutputHigh and OutputLow are from upper
and lower output clamps.
InputHigh and Inputlow are from input high
range and low range.
4. In the Control Engine Name field, type any name, for example SNAP PAC R
5. Type the IP address of your SNAP PAC, for example [Link]
6. Click OK.
You can now associate your Control Engine.