PID controller
From Wikipedia, the free encyclopedia
A proportional-integral-derivative controller (PID controller) is a common feedback loop component in industrial control systems (see also control theory).
The controller takes a measured value from a process or other apparatus and compares it with a reference setpoint value. The difference (or "error" signal) is then used to adjust some input to the process in order to bring the process' measured value back to its desired setpoint. Unlike simpler controllers, the PID can adjust process outputs based on the history and rate of change of the error signal, which gives more accurate and stable control. PID controllers do not require advanced mathematics to design and can be easily adjusted (or "tuned") to the desired application, unlike more complicated control algorithms based on optimal control theory.
Contents |
[edit] Control loop basics
Intuitively, the PID loop tries to automate what an intelligent operator with a gauge and a control knob would do. The operator would read a gauge showing the output measurement of a process, and use the knob to adjust the input of the process (the "action") until the process's output measurement stabilizes at the desired value on the gauge. In older control literature this adjustment process is called a "reset" action. The position of the needle on the gauge is a "measurement", "process value" or "process variable". The desired value on the gauge is called a "setpoint" (also called "set value"). The difference between the gauge's needle and the setpoint is the "error".
A control loop consists of three parts:
- Measurement by a sensor connected to the process (or the "plant"),
- Decision in a controller element,
- Action through an output device ("actuator") such as a control valve.
As the controller reads a sensor, it subtracts this measurement from the "setpoint" to determine the "error". It then uses the error to calculate a correction to the process's input variable (the "action") so that this correction will remove the error from the process's output measurement.
In a PID loop, correction is calculated from the error in three ways: cancel out the current error directly (Proportional), the amount of time the error has continued uncorrected (Integral), and anticipate the future error from the rate of change of the error over time (Derivative).
For example: suppose a water tank is used to supply water for use in several parts of a plant, and it is necessary to keep the water level constant. A sensor would measure the height of water in the tank, producing the "measurement", and continuously feed this data to the controller. The controller would have a "setpoint" of (for example) 75% full. The controller would have its output (the "action") connected to a proportionally-controlled characterized control valve controlling the make-up water feed. Opening the valve would increase the rate of water entering the tank, closing the valve would decrease it. The controller would use the measurement of how the level is changing over time to calculate how to manipulate the control valve to maintain a constant level at the "setpoint".
A PID controller can be used to control any measurable variable which can be affected by manipulating some other process variable. For example, it can be used to control temperature, pressure, flow rate, chemical composition, speed, or other variables. Automobile cruise control is an example of a process outside of industry which utilizes crude PID control.
Some control systems arrange PID controllers in cascades or networks. That is, a "master" control produces signals used by "slave" controllers. One common situation is motor controls: one often wants the motor to have a controlled speed, with the "slave" controller (often built into a variable frequency drive) directly managing the speed based on a proportional input. This "slave" input is fed by the "master" controllers' output, which is controlling based upon a related variable.
Coupled and cascaded controls are common in chemical process control, heating, ventilation, and air conditioning systems, and other systems where many parts cooperate.
[edit] Theory
The PID loop adds positive corrections, removing error from the process's controllable variable (its input).
Differing terms are used in the process control industry: The "process variable" is also called the "process's input" or "controller's output." The process's output is also called the "measurement" or "controller's input."
This "up a bit, down a bit" movement of the process's input variable is how the PID loop automatically finds the correct level of input for the process. "Turning the control knob" reduces error, adjusting the process's input to keep the process's measured output at the setpoint.
The error is found by subtracting the measured quantity from the setpoint.
"PID" is named after its three correcting calculations, whose sum constitutes the output of the PID controller.
- Proportional - To handle the immediate error, the error is multiplied by a constant P (for "proportional"), and added to the controlled quantity. P is only valid in the band over which a controller's output is proportional to the error of the system. For example, for a heater, a controller with a proportional band of 10 °C and a setpoint of 20 °C would have an output of 100% at 10 °C, 50% at 15 °C and 10% at 19 °C. Note that when the error is zero, a proportional controller's output is zero.
- Integral - To learn from the past, the error is integrated (added up) over a period of time, and then multiplied by a constant I (making an average), and added to the controlled quantity. A simple proportional system either oscillates, moving back and forth around the setpoint because there's nothing to remove the error when it overshoots, or oscillates and/or stabilizes at a too low or too high value. By adding a proportion of the average error to the process input, the average difference between the process output and the setpoint is continually reduced. Therefore, eventually, a well-tuned PID loop's process output will settle down at the setpoint. As an example, a system that has a tendency for a lower value (heater in a cold environment), a simple proportional system would oscillate and/or stabilize at a too low value because when zero error is reached P is also zero thereby halting the system until it again is too low.
- Derivative - To handle the future, the first derivative (the slope of the error) over time is calculated, and multiplied by another constant D, and also added to the controlled quantity. The derivative term controls the response to a change in the system. The larger the derivative term, the more rapidly the controller responds to changes in the process's output. Its D term is the reason a PID loop is also sometimes called a "predictive controller." The D term is reduced when trying to dampen a controller's response to short term changes. Practical controllers for slow processes can even do without D term.
More technically, a PID loop can be characterized as a filter applied to a complex frequency-domain system. This is useful in order to calculate whether it will actually reach a stable value. If the values are chosen incorrectly, the controlled process input can oscillate, and the process output may never stay at the setpoint.
A PID controller is called a PI, PD, or P controller in the absence of respective control actions. It may be noted that EWMA (Exponential Weighted Moving Average) controller is equivalent to PI controller.
The generic transfer function for a PID controller of the interacting form is
- ,
with C being a constant which depends on the bandwidth of the controlled system.
Traditionally, the output of the controller (i.e. the input to the process) is given by
where Pcontrib, Icontrib, and Dcontrib are the feedback contributions from the PID controller, defined below:
Where e(t) = Setpoint − Measurement(t) is the error signal, and Kp, Ki, Kd are contants that are used to tune the PID control loop:
- Kp: Proportional Gain - Larger Kp typically means faster response since the larger the error, the larger the feedback to compensate.
- Ki: Integral Gain - Larger Ki implies steady state errors are eliminated quicker. The tradeoff is larger overshoot: any negative error integrated during transient response must be integrated away by positive error before we reach steady state.
- Kd: Derivative Gain - Larger Kd decreases overshoot, but slows down transient response.
Normally the controller is implemented with the Kp gain applied to the Icontrib, and Dcontrib terms as well in the following form;
Where and in relation to the constants defined above.
Most standard tuning methods, such as Ziegler-Nichols and others, are based on this form, as it reduces interaction. In this form, the Kip and Kdp gains relate only to dynamics of the process, and the Kp (proportional gain) relates to the gain of the process.
Often, one deals with discrete time intervals instead of the continuity. Thus, the PID controller may also be dealt with recursively:
Here, the first term is integral, the second proportional, and the third derivative. Note that in this form, Ki must be identically 1, otherwise the controller will not converge to the setpoint. This integral is analagous, but not identical, to the integral in the continuous form.
In practice, most PID controllers employ 3 slightly different constants which correspond to these proportional, integral, and derivative gain.
- Proportional Band - Often abbreviated Pb, this is the band where proportional gain acts upon. To get larger Kp Pb is decreased as follows:
- Integral Time - Often abbreviated It, this is the time over which error is averaged. Because It has dimensions of time, one can conclude the following with dimensional analysis:
- Derivative Time - Often abbreviated Dt, this is the time over which the derivative of the error is evaluated. Because Dt has dimensions of time, one can conclude the following with dimensional analysis:
[edit] Parameter nomenclature
The parameters of PID control were originally named after the adjustments on mechanical controllers and so were called proportional band, reset and rate. These quantities are based on the interacting algorithm. Modern practice is to refer to gain, integral gain, and derivative gain since this better matches the usage in digital controllers.
There are several different forms of the PID controller. The terms "interacting" and "non-interacting" are used many ways and can lead to confusion.
- The parallel or "non-interacting" form, where the P, I and D parts of the controller are all given the same error input in parallel and their output is added together. This allows independent adjustment of the proportional, integral and derivative constants.
- The series or "interacting" form, where the output of each part of the controller is used as the input for another part, so that separate P, D and I controllers are connected together in series. This is effectively how older pneumatic and analog electronic controllers worked. It is the more restricted form of the two.
Note that the most common form of PID controller effectively has the P part in series, with its output feeding the I and D parts in parallel. This mixture of the two forms contributes to the confusion surrounding this terminology.
Gain and proportional band are related but inverse quantities. A controller setting of 100% proportional band means that a 100% change of the error signal (setpoint – process variable) will result in 100% change of the output, which is a gain of 1.0. A 20% proportional band indicates that 20% change in error gives a 100% output change, which is a gain of 5.
The reset and rate values are scaled based on the proportional band of the interacting control algorithm. Reset is measured in minutes to correct the output by the proportional band. Rate is measured in proportional band/minute.
[edit] Loop tuning
"Tuning" a control loop is the adjustment of its control parameters (gain/proportional band, integral gain/reset, derivative gain/rate) to the optimum values for the desired control response. The optimum behavior on a process change or setpoint change varies depending on the application. Some processes must not allow an overshoot of the process variable from the setpoint. Other processes must minimize the energy expended in reaching a new setpoint. Generally stability of response is required and the process must not oscillate for any combination of process conditions and setpoints. Tuning of loops is made more complicated by the response time of the process; it may take minutes or hours for a setpoint change to produce a stable effect. Some processes have a degree of non-linearity and so parameters that work well at full-load conditions don't work when the process is starting up from no-load. This section describes some traditional manual methods for loop tuning.
There are several methods for tuning a PID loop. The choice of method will depend largely on whether or not the loop can be taken "offline" for tuning, and the response speed of the system. If the system can be taken offline, the best tuning method often involves subjecting the system to a step change in input, measuring the output as a function of time, and using this response to determine the control parameters.
If the system must remain online, one tuning method is to first set the I and D values to zero. Increase the P until the output of the loop oscillates. Then increase I until oscillation stops. Finally, increase D until the loop is acceptably quick to reach its reference. A fast PID loop tuning usually overshoots slightly to reach the setpoint more quickly; however, some systems cannot accept overshoot.
Effects of increasing parameters | ||||
Parameter | Rise Time | Overshoot | Settling Time | S.S. Error |
Kp | Decrease | Increase | Small Change | Decrease |
Ki | Decrease | Increase | Increase | Eliminate |
Kd | Small Change | Decrease | Decrease | Small Change |
Another tuning method is formally known as the "Ziegler-Nichols method", introduced by John G. Ziegler and Nathaniel B. Nichols. As in the method above, the I and D gains are first set to zero. The "P" gain is increased until it reaches the "critical gain" Kc at which the output of the loop starts to oscillate. Kc and the oscillation period Pc are used to set the gains as shown:
Ziegler-Nichols method | ||||
Control Type | Kp | Ki | Kd | |
P | 0.5·Kc | - | - | |
PI | 0.45·Kc | 1.2Kp / Pc | - | |
PID | 0.6·Kc | 2Kp / Pc | KpPc / 8 |
Most modern industrial facilities no longer tune loops using the manual calculation methods shown above. Instead, PID tuning and loop optimization software are used to ensure consistent results. These software packages will gather the data, develop process models, and suggest optimal tuning. Some software packages can even develop tuning by gathering data from reference changes.
Mathematical PID loop tuning induces an impulse in the system, and then uses the controlled system's frequency response to design the PID loop values. In loops with response times of several minutes, mathematical loop tuning is recommended, because trial and error can literally take days just to find a stable set of loop values. Optimal values are harder to find, and yet can save a company huge amounts of money. Commercial software is available from several sources, and can easily pay for itself if a PID loop runs a large, or expensive process. Some digital loop controllers offer a self-tuning feature in which very small setpoint changes are sent to the process, allowing the controller itself to calculate optimal tuning values.
Other formulas are available to tune the loop according to different performance criteria.
[edit] Limitations
The PID controller algorithm itself has some limitations. In practice most problems arise from instrumentation connected to the controller.
One common problem is "integral windup". It might take too long for the output value to ramp up to the necessary value when the loop first starts up. Sometimes this can be fixed with a more aggressive differential term. Sometimes the loop has to be "preloaded" with a starting output. Another option is to disable the integral function until the measured variable has entered the proportional band.
Some PID loops control a valve or similar mechanical device. Wear of the valve or device can be a major maintenance cost. In these cases, the PID loop may have a "deadband" to reduce the frequency of activation of the mechanical device. This is accomplished by designing the controller to hold its output steady if the change would be small (within the defined deadband range). The calculated output must leave the deadband before the actual output will change. Then, a new deadband will be established around the new output value.
Another problem with the differential term is that small amounts of noise can cause large amounts of change in the output. Sometimes it is helpful to filter the measurements, with a running average, or a low-pass filter. However, low-pass filtering and derivative control cancel each other out, so reducing noise by instrumentation means is a much better choice. Alternatively, the differential band can be turned off in most systems with little loss of control. This is equivalent to using the PID controller as a PI controller.
The proportional and differential terms can also produce undesirable results in systems subjected to instantaneous "step" inputs (such as when a computer changes the setpoint). To avoid this, some PID algorithms incorporate various schemes:
- derivative of output Many industrial PID systems actually measure the differential of the output quantity, which is always continuous (i.e., never has a step function), and usually moves in the same direction as the error.
- setpoint weighting Setpoint weighting uses several setpoints. The errors from the two setpoints are combined to reduce upsets. Some schemes slowly reduce the proportion of error from an "old" setpoint, and increase the proportion of error from a "new" setpoint. Other schemes have multiple setpoints controlled by different outside controllers. The error in the integral term must be the true control error to avoid steady-state control errors. These parameters do not affect the response to load disturbances and measurement noise.
Digital implementations of a PID algorithm may have limitations owing to the sampling rate of the data, and the limits of internal calculation and precision. For example, very old programmable logic controller (PLC) systems may have used only 12 or 16 bits to represent internal variables. Additionally, some software implementations do not correctly handle internal overflow or extreme values, or may arbitrarily limit the values for the adjustable gain parameters.
Another problem faced with PID controllers is that they are linear. Thus performance of PID controllers in non-linear systems (such as HVAC systems) is variable. Often PID controllers are enhanced through methods such as scheduling or fuzzy logic.
[edit] Implementation
A PID loop can be implemented with any physical system that can produce ratiometric behavior and integration.
Software PID loops are the most stable, because they do not wear out, and their expense has been decreasing. PID controller functionality is a common feature of PLCs used by many factories.
A PID controller can also be purchased for industrial uses as a panel-mounted controller. These often control only one or two loops and are still used for small stand-alone systems where a PLC or computer control is unnecessary.
In the early history of automatic process control the PID controller was implemented as a mechanical device, often energized by compressed air. Mechanical systems (once the cheapest) can use a lever, spring and a mass. Pneumatic controllers were once common, but have been largely replaced by digital electronic controllers.
Electronic analog controllers are now very cheap, and can be made from a solid-state or tube amplifier, a capacitor and a resistance. Electronic analog PID control loops were often found within more complex electronic systems, for example, the head positioning of a disk drive, the power conditioning of a power supply, or even the movement-detection circuit of a modern seismometer. Nowadays, they are replaced with digital controllers implemented in microcontrollers or FPGA.
[edit] External links
- PID Tutorial
- Tuning loops quickly at start-up
- PID Without a PhD: a beginner's guide to PID loop theory with sample programming code
- PID Loop Optimization: A Library of Resources
- Learn how PID and other process tuning works
- PID controller laboratory, Java applets for PID tuning
- Collection of Java Applets for PID Controller Tuning (Tampere University of Technology)
- sci.engr.* FAQ on PID controller tuning
- Information, including tutorial, on PID control algorithm
- Good, basic PID simulation in Excel
- Shows how to build a PID controller with basic electronic components go to page 22
- Parts of a Typical Control System
- Example application: Adding a PID to an espresso machine.
- Articles, Whitepapers, and tutorials on PID control
- Azeotropic Distillation Column Control with Fuzzy Logic