You are on page 1of 9

What Is PIDTutorial Overview

Get Tuning Tips Newsletter PID stands for Proportional, Integral, Derivative. Controllers are designed to eliminate the need for continuous operator attention. Cruise control in a car and a house thermostat are common examples of how controllers are used to automatically adjust some variable to hold the measurement (or process variable) at the set-point. The set-point is where you would like the measurement to be. Error is defined as the difference between set-point and measurement. (error) = (set-point) - (measurement) The variable being adjusted is called the manipulated variable which usually is equal to the output of the controller. The output of PID controllers will change in response to a change in measurement or set-point. Manufacturers of PID controllers use different names to identify the three modes. These equations show the relationships:

P I D

Proportional Band = 100/gain Integral = 1/reset Derivative = rate = pre-act

(units of time) (units of time)

Depending on the manufacturer, integral or reset action is set in either time/repeat or repeat/time. One is just the reciprocal of the other. Note that manufacturers are not consistent and often use reset in units of time/repeat or integral in units of repeats/time. Derivative and rate are the same. Choosing the proper values for P, I, and D is called "PID Tuning". Find out about PID Tuning Software

Proportional Band
With proportional band, the controller output is proportional to the error or a change in measurement (depending on the controller). (controller output) = (error)*100/(proportional band) With a proportional controller offset (deviation from set-point) is present. Increasing the controller gain will make the loop go unstable. Integral action was included in controllers to eliminate this offset.

Integral
With integral action, the controller output is proportional to the amount of time the error is present. Integral action eliminates offset. CONTROLLER OUTPUT = (1/INTEGRAL) (Integral of) e(t) d(t)

Notice that the offset (deviation from set-point) in the time response plots is now gone. Integral action has eliminated the offset. The response is somewhat oscillatory and can be stabilized some by adding derivative action. (Graphic courtesy of ExperTune Loop Simulator.) Integral action gives the controller a large gain at low frequencies that results in eliminating offset and "beating down" load disturbances. The controller phase starts out at 90 degrees and increases to near 0 degrees at the break frequency. This additional phase lag is what you give up by adding integral action. Derivative action adds phase lead and is used to compensate for the lag introduced by integral action.

Derivative
With derivative action, the controller output is proportional to the rate of change of the measurement or error. The controller output is calculated by the rate of change of the measurement with time.

dm CONTROLLER OUTPUT = DERIVATIVE ---dt


Where m is the measurement at time t. Some manufacturers use the term rate or pre-act instead of derivative. Derivative, rate, and pre-act are the same thing. DERIVATIVE = RATE = PRE ACT Derivative action can compensate for a changing measurement. Thus derivative takes action to inhibit more rapid changes of the measurement than proportional action. When a load or set-point change occurs, the derivative action causes the controller gain to move the "wrong" way when the measurement gets near the set-point. Derivative is often used to avoid overshoot. Derivative action can stabilize loops since it adds phase lead. Generally, if you use derivative action, more controller gain and reset can be used.

With a PID controller the amplitude ratio now has a dip near the center of the frequency response. Integral action gives the controller high gain at low frequencies, and derivative action causes the gain to start rising after the "dip". At higher frequencies the filter on derivative action limits the derivative action. At very high frequencies (above 314 radians/time; the Nyquist frequency) the controller phase and amplitude ratio increase and decrease quite a bit because of discrete sampling. If the controller had no filter the controller amplitude ratio would steadily increase at high frequencies up to the Nyquist frequency (1/2 the sampling frequency). The controller phase now has a hump due to the derivative lead action and filtering. (Graphic courtesy of ExperTune Loop Simulator.) The time response is less oscillatory than with the PI controller. Derivative action has helped stabilize the loop.

Control Loop Tuning


It is important to keep in mind that understanding the process is fundamental to getting a well designed control loop. Sensors must be in appropriate locations and valves must be sized correctly with appropriate trim. In general, for the tightest loop control, the dynamic controller gain should be as high as possible without causing the loop to be unstable. Choosing a controller gain is accomplished easily with PID Tuning Software PID Optimization Articles

Fine Tuning "Rules"


This picture (from the Loop Simulator) shows the effects of a PI controller with too much or too little P or I action. The process is typical with a dead time of 4 and lag time of 10. Optimal is red. You can use the picture to recognize the shape of an optimally tuned loop. Also see the response shape of loops with I or P too high or low. To get your process response to compare, put the controller in manual change the output 5 or 10%, then put the controller back in auto. P is in units of proportional band. I is in units of time/repeat. So increasing P or I, decreases their action in the picture.

Starting PID Settings For Common Control Loops

Loop Type Flow Liquid Pressure Gas Pressure Liquid Level Temperature Chromatograph

PB % 50 to 500 50 to 500 1 to 50 1 to 50 2 to 100 100 to 2000

Integral min/rep 0.005 to 0.05 0.005 to 0.05 0.1 to 50 1 to 100 0.2 to 50 10 to 120

Integral rep/min 20 to 200 20 to 200 0.02 to 10 0.1 to 1 0.02 to 5 0.008 to 0.1

Derivative min none none 0.02 to 0.1 0.01 to 0.05 0.1 to 20 0.1 to 20

Valve Type Linear or Modified Percentage Linear or Modified Percentage Linear Linear or Modified Percentage Equal Percentage Linear

These settings are rough, assume proper control loop design, ideal or series algorithm and do not apply to all controllers. Use ExperTune's PID Loop Optimizer to find the proper PID settings for your process and controller. (From Process Control Systems (Shinskey) p.99 and Tuning and Control Loop Performance (McMillan) p 39)

PID Controller
CIRCUIT

PID1.CIR

Tuning the PID controller can be like learning to roller blade, ski or maybe riding a bull. Until you've done it a few times, the literature you've read really doesn't hit home. But after after few attempts (and falls), you find it wasn't so bad after all - in fact it was kind of fun! The PID controller is every where - temperature, motion, flow controllers - and its available in analog and digital forms. Why use it? It helps get your output

(velocity, temperature, position) where you want it, in a short time, with minimal overshoot, and with little error. In many applications the PID controller can do the job - but as usual, with compromises. After a short intro to the PID terms and an example control system, you'll get a chance tune a PID controller.

THE PID CONTROLLER You've probably seen the terms defined before: P -Proportional, I - Integral, D Derivative. These terms describe three basic mathematical functions applied to the error signal , Verror = Vset - Vsensor. This error represents the difference between where you want to go (Vset), and where you're actually at (Vsensor). The controller performs the PID mathematical functions on the error and applies the their sum to a process (motor, heater, etc.) So simple, yet so powerful! If tuned correctly, the signal Vsensor should move closer to Vset. Tuning a system means adjusting three multipliers Kp, Ki and Kd adding in various amounts of these functions to get the system to behave the way you want. The table below summarizes the PID terms and their effect on a control system.
Term P Proportional I Integral D Derivative Math Function KP x Verror Effect on Control System

Typically the main drive in a control loop, KP reduces a large part of the overall error. Reduces the final error in a system. Summing even a KI x Verror dt small error over time produces a drive signal large enough to move the system toward a smaller error. Counteracts the KP and KI terms when the output KD x dVerror / dt changes quickly. This helps reduce overshoot and ringing. It has no effect on final error.

THE CONTROL SYSTEM PID CONTROLLER. How do we create the PID terms? To get the Proportional term, EP multiples Verror at V(2) by a fixed gain of 1 - easy enough! To get the Integral term, current source GI converts V(2) to a current and integrates it on C1=1F. Finally, the Derivative term is created by GD converting V(2) to a current and forcing it through L1. The resulting voltage becomes V(5) = L1 di / dt. A quick substitution of L1 = 1 H and i = Verror gets you V(5) = d Verror / dt. OUTPUT PROCESS. EOUT represents a very simplified model of a process to be controlled like motor velocity or heater temperature. The gain of 100 could represent an output transfer function of 100 RPM / V or 100 C / V. To include the effects of the motor's inertia or heater's thermal mass, we've added some time delay

into the output using two cascaded RC filters. Although Vout is simulated in volts, we know it really represents other variables like velocity in RPM or temperature in C. SENSOR. The sensor tells you, typically by a voltage, what's happening at the control system output. For motor velocity, a tachometer could generate 1 V / 100 RPM; for temperature, a thermistor circuit could produce 0.01 V / deg C. ESENSOR models this feedback device. Because a sensor does not respond instantly, an RC filter is also added here to model its finite response time.

TUNING THE PID CONTROLLER Although you'll find many methods and theories on tuning a PID, here's a straight forward approach to get you up and soloing quickly. 1. SET KP. Starting with KP=0, KI=0 and KD=0, increase KP until the output starts overshooting and ringing significantly. 2. SET KD. Increase KD until the overshoot is reduced to an acceptable level. 3. SET KI. Increase KI until the final error is equal to zero.

HANDS-ON DESIGN Run a simulation of the circuit file PID1.CIR. VSET generates a 10V step input voltage to the control system. You can adjust the PID terms at the EPID source that adds the P, I and D terms at V(3), V(4) and V(5). Initially, the PID multipliers are set to KP=1, KI=0 and KD=0.
EPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 1 0 0

SET KP. Plot the system input V(1) and the sensor output (12). Although the response looks smooth, what is the sensor voltage compared to the desired 10V? The output falls short by 5V! To reduce this error, increase KP to 10 (Change EPID to look like ... 10 0 0 ). Wow, the output now reaches 9V, reducing the error to 1V. But as you can see, the output is getting wild with overshoot and ringing. Push KP up higher to 20 or 30. Yes, the error reduces, but the overshoot gets worse. Eventually, your system will become unstable and break out into song (oscillate). Back off KP to 20 or so. SET KD. The derivative term can rescue the response by counteracting the KP drive when the output is changing. Start with a small value like KD=0.2 and rerun the simulation (Change EPID to look like ... 20 0 0.2 ). Now you're wrestling control back into the system - the ringing and

overshoot are reduced! Crank up KD some more. Improvement should continue to a point where the system becomes less stable and overshoot increases again. Return KD to around 0.5. SET KI. With KP=20, KI=0 and KD=0.5 the response looks respectable, but the final error is a disappointing 0.5V (or 5%)! Now, try the KI term. This will integrate the remaining error into a drive signal big enough to reduce the error further. Start with KI = 10 ( EPID should look like ... 20 10 0.5 ). Check out the last half of the V(12) - the sensor output moves slowly toward 10V! You might want to put up a cursor on the plot to monitor the exact value of V(12). The bigger you make KI, the faster it will move toward 10V. Like the other terms, a value is reached where the KI does more harm than good as the system becomes less stable.

DIVING DEEPER Diving a little deeper you can get a clearer view of the PID components. Before we go beneath the surface, set KP=10, KI=0 and KD=0. INSIDE P Run a couple of simulations with KP=10 and KP 20. Plot V(1) and V(12). What is the final error for each case? You may have noticed the errors of 1 and 0.5V are proportional to the gains of 10 and 20. You can estimate the error by Verror Vset / KP for large KP. What kind of gain do you need for a 1% error? You can easily calculate it as a gain of 100. However, we've already seen how large gain cause overshoot, ringing and oscillations! KP can't do it alone. INSIDE D KD counteracts KP - let's see how. Set KP back to 10 and run a simulation. Plot the P function V(3) which is really Verror. Now plot the D term V(5) which we know is dVerror / dt. To get a good view of D, set the Y-Axis limits to +100 /-200V. Notice how dVerror / dt swings negative when Verror is initially positive. How does this help? Essentially D counteracts the P term potentially reducing ringing and oscillations. The nice thing about the D term is that it goes to zero as the output settles. This makes sense - no change in output, no derivative term. Add in some of the D function by setting the multipliers to KP=10, KI=0 and KD=0.5. The initial overshoot should be significantly reduced. INSIDE I We've seen how a large gain produces a small error. However, big KP gets you into big trouble with overshoot and ringing. Alternatively, an integrator can also give you a big gain by accumulating even a small error over time. Run a simulation with KP=10, KI=0 and KD=0.5 and plot the I term at V(4). What does it look like? Notice, a ramp function, representing Verror integrated over over

time, builds up to a significant drive voltage. Add in the I function by setting KP=10, KI=40 and KD=0.5. The I term completes the controller's job by moving the output toward an error of zero.

SIMULATION NOTE Need a handy way to combine multiple signals such as the PID sum? A controlled source can be a function of multiple inputs described by a polynomial. What is this polynomial? The equation is defined by a coefficient list at the end of the statement. The example below
EPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 10 2 1

creates a polynomial of the form V(6,0) = 0 + 10 V(3,0) + 2 V(4,0) + 1 V(5,0) or more generally, VO = k0 + k1V1 + k2V2 + k3V3 In fact, you can get higher order terms and cross terms by extending the coefficient list VO = ...+ k4V1V1 + k5V1V2 + k6V1V3 + + k7V2V2 + k8V2V3 + + k9V3V3 If you're not using a term, you need to put a 0 in its place; you can't just leave it out. This feature is great for simpler polynomials. Keeping track of the coefficient list for large polynomials can get crazy fast.

SPICE FILE
Download the file or copy this netlist into a text file with the *.cir extention. PID1.CIR - THE PID CONTROLLER * * SET POINT VSET 1 0 PWL(0MS 0MV RSET 1 0 1MEG * * CALCULATE ERROR EERROR 2 0 1 12 1 RERROR 2 0 1MEG

1MS 10V

2000MS 10V)

* * P - PROPORTIONAL TERM EP 3 0 2 0 1 RP 3 0 1MEG * * I - INTEGRAL TERM GI 0 4 2 0 1 C1 4 0 1 R1 4 0 1MEG * * D - DERIVATIVE TERM GD 0 5 2 0 1 L1 5 0 1 * * ADD PID TERMS, ADJUST PID MULTIPLIERS EPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 1 0 0 RPID 6 0 1MEG * * AMPLIFIER EAMP 7 0 6 0 1 RAMP 7 0 1MEG * * PROCESS BLOCK WITH TIME LAG (PHASE SHIFT) EOUT 8 0 7 0 100 RP1 8 9 100K CP1 9 0 1UF RP2 9 10 100K CP2 10 0 1UF * * SENSOR BLOCK WITH TIME LAG ESENSOR 11 0 10 0 0.01 RP3 11 12 10K CP3 12 0 1UF * * ANALYSIS .TRAN 10MS 2000MS * * VIEW RESULTS .PRINT TRAN V(1) V(12) .PROBE .END

You might also like