You are on page 1of 5

What is a PID controller?

Return to Contents PID stands for Proportional-Integral-Derivative. This is a type of feedback controller whose output, a control variable (CV), is generally based on the error (e) between some user-defined set point (SP) and some measured process variable (PV). Each element of the PID controller refers to a particular action taken on the error: Proportional: error multiplied by a gain, Kp. This is an adjustable amplifier. In many systems Kp is responsible for process stability: too low and the PV can drift away; too high and the PV can oscillate. Integral: the integral of error multiplied by a gain, K i. In many systems Ki is responsible for driving error to zero, but to set Ki too high is to invite oscillation or instability or integrator windup or actuator saturation. Derivative: the rate of change of error multiplied by a gain, K d. In many systems Kd is responsible for system response: too high and the PV will oscillate; too low and the PV will respond sluggishly. The designer should also note that derivative action amplifies any noise in the error signal.

Tuning of a PID involves the adjustment of Kp, Ki, and Kd to achieve some user-defined "optimal" character of system response. Although many architectures exist for control systems, the PID controller is mature and well-understood by practitioners. For these reasons, it is often the first choice for new controller design. It satisfies Occams Razor in being the simplest solution for most cases. A simple digital implementation of a PID controller, in which rectangular integration is assumed, is as follows: Pk = Kp (ek ek-1) Ik = K i T e k Dk = (Kd/T) (ek 2 ek-1 + ek-2) CVk = CVk-1 + Pk + Ik + Dk where ek = SPk PVk, and T is the sampling interval. This is referred to as two-degree-of-freedom (two-DOF) design. Notice for this implementation its assumed that all three controller actions involve e k. Many practitioners try to avoid this: applying Kp and/or Kd to the set point can magnify transient errors introduced by rapid changes to the SP. Consider the alternative implementation, in which Kp and Kd are applied only to the PV: Pk = - Kp (PVk PVk-1) Ik = K i T e k Dk = -(Kd/T) (PVk 2 PVk-1 + PVk-2) ...which is one-DOF. You can apply any level of complexity to a PID implementation simply by basing it on a different type of integration. Consider this implementation based on trapezoidal integration: Pk = - Kp (PVk PVk-2) Ik = + (Ki T/2) (ek + 2 ek-1 + ek-2) Dk = 2 (Kd/T) (PVk 2 PVk-1 + PVk-2)

CVk = CVk-2 + Pk + Ik + Dk Increasing complexity is not necessarily wise, however: this alone will not make derivative action noise go away, nor will it make an inherently unstable system stable. The practice of having Kp=0 and Kd=0 acting on the SP are only special cases of two-DOF design and are mostly used in process industries. There is nothing wrong in having greater K p acting on the SP than on the PV in applications where SP tracking is required. The effect is improved transient response to SP change. In transfer function terms, this is zero placement. If the proportional term uses the error signal, then the closed loop transfer function (CLTF) will have a lead term (or, numerator zero). This can give rise to quick, large changes if the command contains steps (derivative action makes things worse). Asea Brown Boveri is one manufacturer providing a more than true two-DOF controller. It uses the ideal form with a weighting factor (beta) in the SP path. You can then tune for optimum load rejection (K p and Kd on error) and then adjust beta to weigh the extent to which the SP is included in the proportional action; e.g. if beta=0, you have an I-PD controller; if beta=1 you have an IP-D controller. Some tuning methods allow you to calculate beta to position the resulting closed-loop zero optimally.

Motion control
In many cases, you might not want to let the SP make steps, even if the user requests it. Steps can cause integrator windup, actuator saturation, stresses, and other nonlinear effects. A motion controller (for instance) would ramp the SP from one position to another at a velocity and acceleration the motor can handle. In motion control, a full PID might include a first-order filter in front of the SP memory, to separate the system poles. This is essential if you choose PID on single loops instead of some multivariable method for motion control. In motion control applications, the SP is governed by a trajectory generator. Besides the standard parameters (Kp, Ki, and Kd), other parameters are involved: velocity, acceleration, and friction feedforward. Their purpose is to reduce tracking error during acceleration/deceleration, at higher speeds and at motion start/stop. These are equivalent to variable gain and SP weighting.

When must a PID be tuned, and why?

Return to Contents You may not encounter the same process twice. If you dont, you wont see the same type of controller twice. There are different types of objectives to be addressed by a controller: error can be minimized in different ways, as can CV activity. Some systems have interactions, and those interactions may be of various strengths. And any interaction affects tuning of an individual PID. There is no single definition of best tuned that applies to all loops, so no single tuning aid will tune all loops optimally. Tuning is part of the design of the loop. You might see a need for a loop to be tuned if it responds slowly, or if it oscillates too much, or if it has a steady-state error; and most definitely if its unstable! :-)


Careful consideration was not given to the units of gains and other parameters.

The process dynamics were not well-understood when the gains were first set, or the dynamics have (for any reason) changed. Some characteristics of the control system are direction-dependent (e.g. actuator piston area, heat-up/cool-down of powerful heaters). You (as designer or operator) think the controller can perform better.

Always remember to check the hardware first. You may not have to tune the controller at all.


A control valve sticks. (You may be able to spot this without leaving the control room.) Valves must be able to respond to commands. A control valve is stripped out from high-pressure flow. A valves response to a command must have some effect on the system. Measurement taps are plugged, or sensors are disconnected. Bad measurements may have you correcting for errors that dont exist.

How is a PID tuned?

Return to Contents Coming up with first-pass tuning values is very easy: make a step change on the output, trend the response, pull two values off the trend, and apply a few simple equations. You then check how well the tuning works in real life. That's the hard part. And for many loops, this works fine. But you have to be able to come up with acceptable control for the problem loops as well, and that doesn't reduce to a simple procedure.

The operator
In a process plant you do NOT block the operator from doing anything unless it is absolutely unsafe. In all other areas, the operator is the driver and has a free hand.

Gain scheduling
Systems in which process dynamics will change in known ways during operation will often benefit from gain scheduling, in which Kp (at least) is the result of a closed-form expression or a table look-up based on a known process characteristic. This technique depends on good knowledge or prediction of the process.

Feedforward control
Systems in which set point changes or disturbances can be anticipated can sometimes benefit from feedforward action, in which the anticipated changes are processed independently of process error. You can compensate for them approximately, before they have a chance to influence process dynamics. One reader does this with cascade control loops on the Honeywell DCS by using the SP as feedforward input, then optimizing feedback response with the normal tuning constants, and adjusting feedforward gain to optimize the SP response separately.

Inner loop control

Sometimes you may want to control separate quantities within the same system, e.g. position and velocity in motion control. In those cases you might have an outer loop for position, and an inner (faster responding) loop for velocity. (Dont apply Kd twice!)

Special problems in realization and implementation

Return to Contents

Differentiation noise
If a signal is noisy, the noise content will be greatly amplified by differentiation this is why even digital controllers will almost never implement a pure derivative. If the rate of the process variable cannot be fed back directly, practitioners will often use low-pass filters in conjunction with the differentiator to attenuate noise. (In the analog world, youd need such a filter just to make the differentiator realizable.) The following is a listing (written in Java) for a nonlinear digital rate algorithm used until recent years in Centaur upper-stage launch vehicles. This algorithm has as inputs eta (error in quantized bits, and the quantizer is included here), and ddr (the current rate, in error units/sec). eta = (double) ((int) (xPID0 / RES)); if ((eta - etak)*ddr > 0) { rddr = (eta - etak) * RES / (K * TS); r = (rddr > ddr) ? ((rddr - ddr) - ADDR) : ((ddr - rddr) - ADDR) ; etak = eta ; K = 1 ; if (r < 0) ddr = rddr; if (!(r < 0) && rddr > ddr) ddr += ADDR; if (!(r < 0) && rddr < ddr) ddr -= ADDR; } else { if (eta > etak && !(ddr > 0)) ddr += FDDR; if (eta < etak && !(ddr < 0)) ddr -= FDDR; q = (ddr > 0) ? ( ddr*K*TS - RES) : (-ddr*K*TS - RES) ; if (q > 0) ddr *= TAU; K++; } // end of DDR algorithm This algorithm provides some interesting features: 1. phase lead maintained for a decade of higher frequency than with a linear low-pass filter; 2. better performance in the presence of (small amounts of) noise. In order to implement such a rate algorithm in your PID, youd need the following: 1. RES, your quantizer resolution in error units/bit 2. ADDR, a "large" increment of rate added or subtracted each duty cycle. For Atlas/Centaur, engineers would use somewhere around one-third to one-fifth the smallest rate detectable by a very simple differentiator: RES/TS (one bit of error over one sampling interval). 3. FDDR, a "small" increment of rate. For Atlas/Centaur, engineers would use somewhere around one-fifth to one-tenth of RES/TS.

4. TAU, a multiplier (less than 1) used in case the rate increments given by ADDR and FDDR still turn out to be just too big. Atlas/Centaur used 0.5 to 0.9 in many cases.

Integrator windup
Integrator windup is a condition that results when integral action saturates a controller without the controller driving the error signal toward zero. If the integrator does not have saturation, then it can increase without bound, and without leading to faster system response. This is a condition that can potentially affect all controllers with integral action. It can result in limit cycling or even instability. In the area of multibody articulated dynamic systems, this area can be of particular concern. Consider the Space Station photovoltaic arrays in sun-tracking mode. The beta gimbals would rotate the arrays at the orbit rate, 4 deg/min. In a situation in which operators wanted to avoid a thermal problem with the arrays, they might command the arrays to flip 180 degrees. A step command of 180 degrees would saturate the (PID) beta gimbal control system, and integrator windup would occur. Rocketdyne saw instability of the beta gimbal as a result. Rocketdyne's solution was to individually limit each action of the controller: proportional, integral and derivative alike; they then would limit controller output. This indeed solved the integrator windup problem, at the expense of a slower response. If we think of the controller output as P k + Ik + Dk at time k, a large step would quickly cause Pk and Ik to saturate. Then, as soon as Dk = -Pk - Ik, the control signal is nulled and controller output becomes zero, so the gimbal slews at constant rate. Here are four methods for dealing with windup in your controller without unnecessarily limiting P k and Dk: 1. Conditional Integration. If the controller output is saturated, and input and output are of the same sign, then set integrator input to zero. 2. Limited Integration. If the integrator is saturated, and controller input is of the same sign, then set integrator input to zero. 3. Tracking Anti-Windup. If the controller output is saturated, reduce the integrator input by some constant times the difference between unsaturated and saturated controller output. 4. Modified Tracking Anti-Windup. Limit integrator input by some constant times the sum of I k and saturated (Pk + Dk), so that if either of those two components exceeds your limits, the integrator is off.