The text of a manual · part 9 of 38
DL06 Micro PLC User Manual, Volume 2 of 2, pages 80 to 89
Pages 80 to 89 of 370
The original document is the PDF (6.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Page 80
Chapter 8: PID Loop Operation
1 Introduction to PID Control What is PID Control? 2 In this discussion, we will explain why PID control is used in process control instead of trying to provide control by simply using an analog input and a discrete output. 3 There are many types of analog controllers available, and the proper selection will depend upon the particular application. There are two types of analog controllers that are used throughout industry: 4 1. The ON-OFF controller, sometimes referred to as an open loop controller. 2. The PID controller, sometimes called a closed loop controller. 5 Regardless of type, analog controllers require input signals from electronic sensors such as pressure, differential pressure, level, flow meter or thermocouples. As an example, one of the 6 most common analog control applications is located in your house for controlling either heat or air conditioning, the thermostat. 7 You wish for your house to be at a comfortable temperature so you set a thermostat to a desired temperature (setpoint). You then select the “comfort” mode, either heat or A/C. A temperature sensing device, normally a thermistor, is located within the thermostat. If the 8 thermostat is set for heat and the setpoint is set for the furnace will be turned on to provide heat at, normally, below the setpoint. In this case, it would turn on at When 9 the temperature reaches above setpoint, the furnace will turn off. In the opposite example, if the thermostat is set for A/C (cooling), the thermostat will turn the A/C unit 10 on/off opposite the heat setting. For instance, if the thermostat is set to cool at the A/C unit will turn on when the sensed temperature reaches above the setpoint or and turn off when the temperature reaches This would be considered to be an ON-OFF 11 controller. The waveform below shows the action of the heating cycle. Note that there is a slight overshoot at the turn-off point, also a slight undershoot at the turn-on point. 12 13 14 A B The ON-OFF controller is used in some industrial control applications, but is not practical C in the majority of industrial control processes. The most common process controller that is used in industry is the PID controller. D 71°
OFF
OFF
SETPOINT
69°
67°
ON
ON
ON
TIME
8–4
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 81
Chapter 8: PID Loop Operation The PID controller controls a continuous feedback loop that keeps the process output (control variable) flowing normally by taking corrective action whenever there is a deviation from the desired value (setpoint) of the process variable (PV) such as, rate of flow, temperature, voltage, etc. An “error” occurs when an operator manually changes the setpoint or when an event (valve opened, closed, etc.) or a disturbance (cold water, wind, etc.) changes the load, thus causing a change in the process variable. The PID controller receives signals from sensors and computes corrective action to the actuator from a computation based on the error (Proportional), the sum of all previous errors (Integral) and the rate of change of the error (Derivative). We can look at the PID controller in more simple terms. Take the cruise control on an automobile as an example. Let’s say that we are cruising on an interstate highway in a car equipped with cruise control. The driver decides to engage the cruise control by turning it ON, then he manually brings the car to the desired cruising speed, say 70 miles per hour. Once the cruise speed is reached, the SET button is pushed fixing the speed at 70 mph, the setpoint. Now, the car is cruising at a steady 70 mph until it comes to a hill to go up. As the car goes up the hill, it tends to slow down. The speed sensor senses this and causes the throttle to increase the fuel to the engine. The vehicle speeds up to maintain 70 mph without jerking the car and it reaches the top at the set speed. When the car levels out after reaching the top of the hill it will speed up. The speed sensor senses this and signals the throttle to provide less fuel to the engine, thus, the engine slows down allowing the car to maintain the 70 mph speed. How does this application apply to PID control? Lets look at the function of P, I and D terms: • Proportional - is commonly referred to as Proportional Gain. The proportional term is the corrective action which is proportional to the error, that is, the change of the manipulated variable is equal to the proportional gain multiplied by the error (the activating signal). In mathematical terms: Proportional action = proportional gain X error Error = Setpoint (SP) - Process Variable (PV) Applying this to the cruise control, the speed was set at 70 mph which is the Setpoint. The speed sensor senses the actual speed of the car and sends this signal to the cruise controller as the Process Variable (PV). When the car is on a level highway, the speed is maintained at 70 mph, thus, no error since the error would be SP - PV = 0. When the car goes up the hill, the speed sensor detected a slow down of the car, SP-PV = error. The proportional gain would cause the output of the speed controller to bring the car back to the setpoint of 70 mph. This would be the Controlled Output. • Integral - this term is often referred to as Reset action. It provides additional compensation to the control output, which causes a change in proportion to the value of the error over a period of time. In other words, the reset term is the integral sum of the error values over a period of time. • Derivative - this term is referred to as rate. The Rate action adds compensation to the control output, which causes a change in proportion to the rate of change of error. Its job is to anticipate the probable growth of the error and generate a contribution to the output in advance.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
8–5
Page 82
Chapter 8: PID Loop Operation
DL06 PID Control 1 Introducing The DL06 is capable of controlling a process variable such as those already mentioned. As previously mentioned, the control of a variable, such as temperature, at a given level 2 (setpoint) as long as there are no disturbances (cold water) in the process. The DL06 PLC has the ability to directly accept signals from electronic sensors, such as 3 thermocouples, pressure, VFDs, etc. These signals may be used in mathematically derived control systems. 4 In addition, the DL06 has built-in PID control algorithms that can be implemented. The basic function of PID closed loop process control is to maintain certain process characteristics at desired setpoints. As a rule, the process deviates from the desired setpoint reference as a 5 result of load material changes and interaction with other processes. During this control, the actual condition of the process characteristics (liquid level, temperature, motor control, etc.) 6 is measured as a process variable (PV) and compared with the target setpoint (SP). When deviations occur, an error is generated by the difference between the process variable (actual value) and the setpoint (desired value). Once an error is detected, the function of the control 7 loop is to modify the control output in order to force the error to zero. The DL06 PID control provides feedback loops using the PID algorithm. The control output 8 is computed from the measured process variable as follows: Let: 9 K = proportional gain T = Reset or integral time 10 T = Derivative time or rate SP = Setpoint 11 PV(t) = Process Variable at time “t” e(t) = SP-PV(t) = PV deviation from setpoint at time “t” or PV error. 12 Then: M(t) = Control output at time “t” 13 M(t) = Kc [ e(t) + 1/T 兰 e(x) dx + T d/dt e(t) ] + M 14 The analog input module receives the process variable in analog form along with an operator A entered setpoint; the CPU computes the error. The error is used in the algorithm computation to provide corrective action at the control output. The function of the control action is based on an output control, which is proportional to the instantaneous error value. B The integral control action (reset action) provides additional compensation to the control output, which causes a change in proportion to the value of the change of error over a period C of time. The derivative control action (rate change) adds compensation to the control output, which causes a change in proportion to the rate of change of error. These three modes are D used to provide the desired control action in Proportional (P), Proportional-Integral (PI), or c i d t i
0 d
Proportional-Integral-Derivative (PID) control fashion.
8–6
DL06 Micro PLC User Manual, 3rd Edition Rev. A o
Page 83
Chapter 8: PID Loop Operation Standard DL05/06 analog input modules are used to interface to field transmitters to obtain the PV. These transmitters normally provide a 4-20mA current or an analog voltage of various ranges for the control loop. For temperature control, thermocouple or RTD can be connected directly to the appropriate module. The PID control algorithm, residing in the CPU memory, receives information from the user program, primarily control parameters and setpoints. Once the CPU makes the PID calculation, the result may be used to directly control an actuator connected to a 4-20mA current output module to control a valve. With DirectSOFT 5, additional ladder logic programming, both time proportioning (eg. heaters for temperature control) and position actuator (eg. reversible motor on a valve) type of control schemes can be easily implemented. This chapter will explain how to set up the PID control loop, how to implement the software and how to tune the loop. The following block diagram shows the key parts of a PID control loop. The path from the PLC to the manufacturing process and back to the PLC is the closed loop control.
External Disturbances
Loop Configuring and Monitoring PLC System Setpoint Value +
Error T erm
Loop Calculation
Control Output
Manufacturing Process
–
Process Variable
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
8–7
Page 84
Chapter 8: PID Loop Operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 8–8
Process Control Definitions Manufacturing Process – the set of actions that adds value to raw materials. The process can involve physical changes and/or chemical changes to the material. The changes render the material more useful for a particular purpose, ultimately used in a final product. Process Variable – The controlled variable part of the process that you wish to control. It may be temperature, pressure, level, flow, composition, density, the ratio of two streams, etc. Also known as the actual value. Setpoint – This is the target for the process variable. When all conditions of the process are correct, the process variable will equal the setpoint. Control Output – The result of the loop calculation, which becomes a command for the process (such as the heater level in an oven). This is sometimes referred to as control variable. Error Term – The algebraic difference between the process variable and the setpoint. This is the control loop error, and is equal to zero when the process variable is equal to the setpoint (desired) value. A well-behaved control loop is able to maintain a small error term magnitude. Manipulated Variable – This is what is used to effect the controlled variable. For example, the fuel used in a furnace might be manipulated in order to control the temperature. Disturbance – Something in the system that changes such that corrective action is required. For instance, when controlling a flow and the upstream pressure drops, the control valve must open wider in order to keep flow constant. The drop in upstream pressure is the disturbance. Final Control Element – This is the physical device used to control the manipulated variable. Valves are probably the most widely used final control element. Lag Time – The time it takes for the process to respond to a change in manipulated variable. This is also known as the capacitance of the system. When you’re in the shower and you turn up the hot water a little, the time it takes before the water gets hot is the lag time. Dead Time – The time it takes for a change in the process to be recognized. Composition analyzers and quality control are usually sources of significant dead time. Loop Configuring – Operator-initiated selections which set up and optimize the performance of a control loop. The loop calculation function uses the configuration parameters in real time to adjust gains, offsets, etc. Loop Monitoring – The function which allows an operator to observe the status and performance of a control loop. This is used in conjunction with the loop configuring to optimize the performance of a loop (minimize the error term).
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 85
Chapter 8: PID Loop Operation
PID Loop Operation The Proportional–Integral–Derivative (PID) algorithm is widely used in process control. The PID method of control adapts well to electronic solutions, whether implemented in analog or digital (CPU) components. The DL06 CPU implements the PID equations digitally by solving the basic equations in software. I/O modules serve only to convert electronic signals into digital form (or vice versa). The DL06 uses two types of PID controls: “position” and “velocity”. These terms usually refer to motion control situations, but here we use them in a different sense: • PID Position Algorithm – The control output is calculated so it responds to the displacement (position) of the PV from the SP (error term). • PID Velocity Algorithm – The control output is calculated to represent the rate of change (velocity) for the PV to become equal to the SP.
Position Form of the PID Equation Referring to the control output equation on page 8-6, the DL06 CPU approximates the output M(t) using a discrete position form of the PID equation. Let: Ts = Sample rate Kc = Proportional gain Ki = Kc * (Ts/Ti) = Coefficient of integral term Kr = Kc * (Td/Ts) = Coefficient of derivative term Ti = Reset or integral time Td = Derivative time or rate SP = Setpoint PVn = Process variable at nth sample en = SP – PVn = Error at nth sample Mo = Value to which the controller output has been initialized Then: Mn = Control output at nth sample n
Mn = Kc * en + Ki 兺 ei + Kr (en - en-1) + Mo i=1
This form of the PID equation is referred to as the position form since the actual actuator position is computed. The velocity form of the PID equation computes the change in actuator position. The CPU modifies the standard equation slightly to use the derivative of the process variable instead of the error as follows: n
Mn = Kc * en + Ki 兺 ei + Kr (PVn - PVn-1) + Mo i=1
These two forms are equivalent unless the setpoint is changed. In the original equation, a large step change in the setpoint will cause a correspondingly large change in the error resulting in a bump to the process due to derivative action. This bump is not present in the second form of the equation.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
8–9
Page 86
Chapter 8: PID Loop Operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 8–10
The DL06 also combines the integral sum and the initial output into a single term called the bias (Mx). This results in the following set of equations: Mxo = Mo Mx = Ki * en + Mxn-1 Mn = Kc * en - Kr(PVn-PVn-1) + Mxn The DL06 by default will keep the normalized output M in the range of 0.0 to 1.0. This is done by clamping M to the nearer of 0.0 or 1.0 whenever the calculated output falls outside this range. The DL06 also allows you to specify the minimum and maximum output limit values (within the range 0 to 4095 in BCD if using 12 bit unipolar). NOTE: The equations and algorithms , or parts of, in this chapter are only for references. Analysis of these equations can be found in most good text books about process control.
Reset Windup Protection Reset windup can occur if reset action (integral term) is specified and the computation of the bias term Mx is: Mx = Ki * en + Mxn-1 For example, assume the output is controlling a valve and the PV remains at some value greater than the setpoint. The negative error (en) will cause the bias term (Mx) to constantly decrease until the output M goes to 0 closing the valve. However, since the error term is still negative, the bias will continue to decrease becoming ever more negative. When the PV finally does come back down below the SP, the valve will stay closed until the error is positive for long enough to cause the bias to become positive again. This will cause the process variable to undershoot. One way to solve the problem is to simply clamp the normalized bias between 0.0 and 1.0. The DL06 CPU does this. However, if this is the only thing that is done, then the output will not move off 0.0 (thus opening the valve) until the PV has become less than the SP. This will also cause the process variable to undershoot. The DL06 CPU is programmed to solve the overshoot problem by either freezing the bias term, or by adjusting the bias term.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 87
Chapter 8: PID Loop Operation
Freeze Bias
1 2 3 M = Kc * e - Kr(PV - PV ) + Mx 4 if M < 0 M =0 M = M if 0 ⭐ M ⭐ 1 5 M =1 if M > 1 6 Mx = Mx if 0 ⭐ M ⭐ 1 otherwise Mx = Mx Thus in this example, the bias will probably not go all the way to zero so that, when the PV 7 does begin to come down, the loop will begin to open the valve sooner than it would have if the bias had been allowed to go all the way to zero. This action has the effect of reducing the 8 amount of overshoot. Adjusting the Bias 9 The normal action of the CPU is to adjust the bias term when the output goes out of range as shown below. 10 Mx = Ki * e + Mx M = Kc * e - Kr(PV - PV ) + Mx 11 M =0 if M < 0 12 M = M if 0 ⭐ M ⭐ 1 M =1 if M > 1 13 Mx = Mx if 0 ⭐ M ⭐ 1 Mx = M - Kc * e - Kr(PV - PV ) otherwise 14 By adjusting the bias, the valve will begin to open as soon as the PV begins to come down. If the loop is properly tuned, overshoot can be eliminated entirely. If the output went out of A range due to a setpoint change, then the loop probably will oscillate because we must wait for the bias term to stabilize again. B The choice of whether to use the default loop action or to freeze the bias is dependent on the application. If large, step changes to the setpoint are anticipated, then it is probably better to select the freeze bias option (see page 8-34). C D If the “Freeze Bias” option is selected when setting up the PID loop (discussed later) then the CPU simply stops changing the bias (Mx) whenever the computed normalized output (M) goes outside the interval 0.0 to 1.0. Mx = Ki * en + Mxn-1 n n n-1 n n-1 n n n n n n-1 n n-1 n n n n n n n n n n-1
DL06 Micro PLC User Manual, 3rd Edition Rev. A
8–11
Page 88
Chapter 8: PID Loop Operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 8–12
Step Bias Proportional to Step Change in SP This feature reduces oscillation caused by a step change in setpoint when the adjusting bias feature is used. if the loop is direct acting Mx = Mx * SPn / SPn-1 Mx = Mx * SPn-1 / SPn if the loop is reverse acting if Mx < 0 Mxn = 0 Mxn = Mx if 0 ⭐ Mx ⭐ 1 Mxn = 1 if M > 1
Eliminating Proportional, Integral or Derivative Action It is not always necessary to run a full three mode PID control loop. Most loops require only the PI terms or just the P term. Parts of the PID equation may be eliminated by choosing appropriate values for the gain (Kc), reset (Ti) and rate (Td) yielding a P, PI, PD, I and even an ID and a D loop. Eliminating Integral Action The effect of integral action on the output may be eliminated by setting Ti = 9999. When this is done, the user may then manually control the bias term (Mx) to eliminate any steady-state offset. Eliminating Derivative Action The effect of derivative action on the output may be eliminated by setting Td = 0 (most loops do not require a D parameter; it may make the loop unstable). Eliminating Proportional Action Although rarely done, the effect of proportional term on the output may be eliminated by setting Kc = 0. Since Kc is also normally a multiplier of the integral coefficient (Ki) and the derivative coefficient (Kr), the CPU makes the computation of these values conditional on the value of Kc as follows: Ki = Kc * (Ts / Ti) if Kc ⫽ 0 Ki = Ts / Ti if Kc = 0 (I or ID only) Kr = Kc * (Td / Ts) if Kc ⫽ 0 Kr = Td / Ts if Kc = 0 (ID or D only)
Velocity Form of the PID Equation The standard position form of the PID equation computes the actual actuator position. An alternative form of the PID equation computes the change in actuator position. This form of the equation is referred to as the velocity PID equation and is obtained by subtracting the equation at time “n” from the equation at time “n-1”. The velocity equation is given by: ⌬Mn = M - Mn-1 ⌬Mn = Kc * (en - en-1) + Ki * (PVn - 2 * PVn-1 + PVn-2)
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 89
Chapter 8: PID Loop Operation
Bumpless Transfer
1 2 3 4 5 Loop Alarms 6 The DL06 allows the user to specify alarm conditions that are to be monitored for each loop. Alarm conditions are reported to the CPU by setting up the alarms in DirectSOFT 5 using 7 the PID setup alarm dialog when the loop is setup. The alarm features for each loop are: • PV Limit – Specify up to four PV alarm points. 8 High-High PV rises above the programmed High-High Alarm Limit. High PV rises above the programmed High Alarm Limit. Low PV fails below the Low Alarm Limit. 9 Low-Low PV fails below the Low-Low Limit. • PV Deviation Alarm – Specify an alarm for High and Low PV deviation from the 10 setpoint (Yellow Deviation). An alarm for High High and Low Low PV deviation from the setpoint (Orange Deviation) may also be specified. When the PV is further from the setpoint than the programmed Yellow or Orange Deviation Limit the 11 corresponding alarm bit is activated. • Rate of Change – This alarm is set when the PV changes faster than a specified rate-of12 change limit. • PV Alarm Hysteresis – The PV Limit Alarms and PV Deviation Alarms are programmed using threshold values. When the absolute value or deviation exceeds the threshold, 13 the alarm status becomes true. Real-world PV signals have some noise on them, which can cause some fluctuation in the PV value in the CPU. As the PV value crosses an 14 alarm threshold, its fluctuations will cause the alarm to be intermittent and annoy process operators. The solution is to use the PV Alarm Hysteresis feature. A B C D The DL06 loop controller provides for bumpless mode changes. A bumpless transfer from manual mode to automatic mode is achieved by preventing the control output from changing immediately after the mode change. When a loop is switched from Manual mode to Automatic mode, the setpoint and Bias are initialized as follows: Position PID Algorithm Velocity PID Algorithm SP = PV SP = PV Mx = M The bumpless transfer feature of the DL06 is available in two types: Bumpless I and Bumpless II (see page 8-26). The transfer type is selected when the loop is set up.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
8–13