Process Control: Designing Process and Control Systems for Dynamic Performance Chapter 8. The PID Controller Copyright © Thomas Marlin 2013 The copyright holder provides a royalty-free license for use of this material at non-profit educational institutions CHAPTER 8: THE PID CONTROLLER When I complete this chapter, I want to be able to do the following. • Understand the strengths and weaknesses of the three modes of the PID • Determine the model of a feedback system using block diagram algebra • Establish general properties of PID feedback from the closed-loop model CHAPTER 8: THE PID CONTROLLER Outline of the lesson. • General Features and history of PID • Model of the Process and controller - the Block Diagram • The Three Modes with features - Proportional - Integral - Derivative • Typical dynamic behavior CHAPTER 8: THE PID CONTROLLER PROPERTIES THAT WE SEEK IN A CONTROLLER • Good Performance - feedback measures from Chapter 7 • Wide applicability - adjustable parameters • Timely calculations - avoid convergence loops • Switch to/from manual bumplessly • Extensible - enhanced easily v1 TC v2 CHAPTER 8: THE PID CONTROLLER SOME BACKGROUND IN THE CONTROLLER • Developed in the 1930-40’s, remains workhorse of practice • Not “optimal”, based on good properties of each mode • Programmed in digital control equipment • ONE controlled variable (CV) and ONE manipulated variable (MV). Many PID’s used in a plant. v1 TC v2 CHAPTER 8: THE PID CONTROLLER MV = controller output Proportional E + Integral Derivative Note: Error = E SP - CV Final element SP = Set point + CV = Controlled variable sensor Process variable PROCESS Three “modes”: Three ways of using the time-varying behavior of the measured variable CHAPTER 8: THE PID CONTROLLER Closed-Loop Model: Before we learn about each calculation, we need to develop a general dynamic model for a closed-loop system - that is the process and the controller working as an integrated system. v1 TC v2 This is an example; how can we generalize? • What if we measured pressure, or flow, or …? • What if the process were different? • What if the valve were different? CHAPTER 8: THE PID CONTROLLER GENERAL CLOSED-LOOP MODEL BASED ON BLOCK DIAGRAM D(s) SP(s) + - E(s) Gd(s) MV(s) GC(s) Gv(s) CVm(s) GP(s) + + CV(s) GS(s) Transfer functions Variables GC(s) = controller Gv(s) = valve GP(s) = feedback process GS(s) = sensor Gd(s) = disturbance process CV(s) = controlled variable CVm(s) = measured value of CV(s) D(s) = disturbance E(s) = error MV(s) = manipulated variable SP(s) = set point CHAPTER 8: THE PID CONTROLLER D(s) SP(s) + - E(s) MV(s) GC(s) Gv(s) CVm(s) Let’s audit our understanding Gd(s) GP(s) + + CV(s) GS(s) • Where are the models for the transmission, and signal conversion? • What is the difference between CV(s) and CVm(s)? • What is the difference between GP(s) and Gd(s)? • How do we measure the variable whose line is indicated by the red circle? • Which variables are determined by a person, which by computer? CHAPTER 8: THE PID CONTROLLER D(s) SP(s) E(s) + Gd(s) CV(s) MV(s) GC(s) Gv(s) GP(s) + + CVm(s) GS(s) Set point response G p ( s )Gv ( s )Gc ( s ) CV ( s ) SP( s ) 1 G p ( s )Gv ( s )Gc ( s )GS ( s ) Disturbance Response Gd ( s ) CV ( s ) D( s ) 1 G p ( s )Gv ( s )Gc ( s )GS ( s ) • Which elements in the control system affect system stability? • Which elements affect dynamic response? Proportional CHAPTER 8: MV E SP - +CV Integral + Derivative THE PID CONTROLLER, Note: Error = E SP - CV The Proportional Mode PROCESS “correction proportional to error.” Time domain : MV (t ) K c E(t ) I p MV ( s ) Transfer function : GC ( s ) KC E( s ) KC = controller gain How does this differ from the process gain, Kp? Proportional MV CHAPTER 8: E SP - +CV Integral + Derivative THE PID CONTROLLER, Note: Error = E SP - CV The Proportional Mode “correction proportional to error.” PROCESS Time domain : MV (t ) K c E(t ) I p Kp depends upon the process (e.g., reactor volume, flows, temperatures, etc.) KC = controller gain How does this differ from the process gain, Kp? KC is a number we select; it is used in the computer each time the controller equation is calculated Proportional CHAPTER 8: THE PID CONTROLLER, MV + E SP - +CV Integral Derivative Note: Error = E SP - CV The Proportional Mode PROCESS Time domain : MV (t ) K c E(t ) I p Proportional CHAPTER 8: THE PID CONTROLLER, MV + E SP - +CV Integral Derivative Note: Error = E SP - CV The Proportional Mode PROCESS Time domain : MV (t ) K c E(t ) I p Physical Device: Raising and lowering the gate affects the flow in Location of the fulcrum determines the gate/level Float measures the liquid level Proportional CHAPTER 8: THE PID CONTROLLER, MV + E SP - +CV Integral Derivative Note: Error = E SP - CV The Proportional Mode PROCESS Key feature of closed-loop performance with P-only Final value Kd D K d D CV ' (t ) t lim s 0 after s 0 s 1 Kc K p 1 Kc K p disturbance: • We do not achieve zero offset; don’t return to set point! • How can we get very close by changing a controller parameter? • Any possible problems with suggestion? Proportional MV CHAPTER 8: + THE PID CONTROLLER, E SP - +CV Integral Derivative Note: Error = E SP - CV The Proportional Mode PROCESS Disturbance in concentration of A in the solvent CV = concentration of A in effluent MV = valve % open of pure A stream FS solvent FA CV pure A From person AC MV SP E (t ) SP (t ) CV (t ) MV (t ) K c E (t ) I THE PID CONTROLLER,The Proportional Mode 0.8 Controlled Variable Controlled Variable 0.8 0.6 No control 0.4 0.2 0.6 0.4 0 0 20 40 60 80 100 Time 120 140 160 180 0 200 0 0.5 valve 20 40 60 80 100 Time 120 140 160 180 200 0 Manipulated Variable Manipulated Variable 1 Kc = 0 0 -0.5 -1 0 20 40 60 80 100 Time 120 140 160 180 Kc =10 -2 -4 -6 200 0 Note change of scale! 20 40 20 40 60 80 100 Time 120 140 160 180 200 60 80 100 Time 120 140 160 180 200 80 100 Time 120 140 160 180 200 0.3 Controlled Variable 0.25 Controlled Variable Offset (bad) 0.2 0.2 0.15 Less Offset, better (but not good) 0.1 0.05 0.2 0.1 0 -0.1 0 0 0 20 40 60 80 100 Time 120 140 160 180 200 Unstable, very bad! 20 -5 Manipulated Variable valve Manipulated Variable 0 Kc = 100 -10 -15 -20 0 -20 -40 -60 -25 0 0 20 40 60 80 100 Time 120 140 160 180 200 Kc = 220 20 40 60 Proportional CHAPTER 8: MV + SP - +CV Integral Derivative THE PID CONTROLLER, E Note: Error = E SP - CV The Integral Mode PROCESS “The persistent mode” t Kc Time domain : MV (t ) E (t ' )dt ' I I TI 0 MV ( s ) KC 1 Transfer function : GC ( s ) E( s ) TI s TI = controller integral time (in denominator) Proportional MV CHAPTER 8: E SP - +CV Integral + Derivative THE PID CONTROLLER, Note: Error = E SP - CV The Integral Mode PROCESS t Kc Time domain : MV (t ) E (t ' )dt ' I I TI 0 MV(t) Slope = KC E/TI time Behavior when E(t) = constant Proportional MV CHAPTER 8: + THE PID CONTROLLER, E SP - +CV Integral Derivative Note: Error = E SP - CV The Integral Mode PROCESS Key feature of closed-loop performance with I mode Final value after disturbance: CV ' (t ) t Kd D lim s s 0 s 1 Kc K p 0 sTI • We achieve zero offset for a step disturbance; return to set point! • Are there other scenarios where we do not? Proportional CHAPTER 8: MV E SP - +CV Integral + Derivative THE PID CONTROLLER, Note: Error = E SP - CV The Derivative Mode PROCESS “The predictive mode” dE(t ) Time domain : MV (t ) K cTD ID dt MV ( s ) Transfer function : GC ( s ) K cTd s E( s ) TD = controller derivative time Proportional MV CHAPTER 8: + THE PID CONTROLLER, E SP - +CV Integral Derivative Note: Error = E SP - CV The Derivative Mode PROCESS Key features using closed-loop dynamic model Final value after disturbance: CV ' (t ) t Kd D lim s D K d s 0 s 1 K cTd s We do not achieve zero offset; do not return to set point! Proportional CHAPTER 8: THE PID CONTROLLER, MV + E SP - +CV Integral Derivative Note: Error = E SP - CV The Derivative Mode PROCESS dE(t ) Time domain : MV (t ) K cTD ID dt • What would be the behavior of the manipulated variable when we enter a step change to the set point? • How can we modify the algorithm to improve the performance? Proportional MV CHAPTER 8: + THE PID CONTROLLER, E SP - +CV Integral Derivative Note: Error = E SP - CV The Derivative Mode PROCESS dE(t ) Time domain : MV (t ) K cTD ID dt X We do not want to take the derivative of the set point; therefore, we use only the CV when calculating the derivative mode. d CV (t ) Time domain : MV (t ) K cTD ID dt Proportional MV CHAPTER 8: + SP - +CV Integral Derivative THE PID CONTROLLER E Note: Error = E SP - CV PROCESS Let’s combine the modes to formulate the PID Controller! E (t ) SP(t ) CV (t ) 1 MV (t ) K c E (t ) TI d CV 0 E (t ' )dt 'Td dt I t Please explain every term and symbol. Proportional MV CHAPTER 8: E SP - +CV Integral + Derivative THE PID CONTROLLER Note: Error = E SP - CV PROCESS Let’s combine the modes to formulate the PID Controller! E (t ) SP(t ) CV (t ) 1 MV (t ) K c E (t ) TI proportional Error from set point d CV 0 E (t ' )dt 'Td dt I t integral derivative Constant (bias) for bumpless transfer CHAPTER 8: THE PID CONTROLLER Let’s apply the controller to the three-tank mixer (no rxn). Notes: 1) tanks are well mixed 2) liquid volumes are constant 3) sensor and valve dynamics are negligible 4) FA = Kv (v), with v = % opening 5) FS >> FA CV = concentration of A in effluent MV = valve % open of pure A stream FS solvent FA CV pure A From person AC MV SP E (t ) SP(t ) CV (t ) t 1 d CV MV (t ) K c E (t ) E (t ' )dt 'Td I TI 0 dt CHAPTER 8: THE PID CONTROLLER S-LOOP plots deviation variables (IAE = 12.2869) Controlled Variable 1.5 1 0.5 0 0 20 40 60 Time 80 • Is this good performance? • How do we determine: 100 120 Kc, TI and Td? Manipulated Variable 40 30 20 10 Kc = 30, TI = 11, Td = 0.8 0 0 20 40 60 80 100 120 CHAPTER 8: THE PID CONTROLLER S-LOOP plots deviation variables (IAE = 20.5246) Controlled Variable 2 1.5 1 0.5 0 0 20 40 60 Time 80 • Is this good performance? • How do we determine: 100 120 Kc, TI and Td? Manipulated Variable 150 100 50 0 Kc = 120, TI = 11, Td = 0.8 -50 0 20 40 60 Time 80 100 120 CHAPTER 8: THE PID CONTROLLER Lookahead: We can apply many PID controllers when we have many variables to be controlled! E (t ) SP(t ) CV (t ) 1 MV (t ) K c E (t ) T I t E (t ' )dt 'T d 0 d CV I dt T6 C Vapor product P1 C E (t ) SP(t ) CV (t ) T1 1 MV (t ) K c E (t ) T I T5 T2 Feed t E (t ' )dt 'T d 0 d CV I dt E (t ) SP(t ) CV (t ) F1 T4 F2 Process fluid T3 L1 C 1 MV (t ) K c E (t ) TI F3 Steam A1 L. Key Liquid product t E (t ' )dt 'T d 0 d CV I dt CHAPTER 8: THE PID CONTROLLER HOW DO WE EVALUATE THE DYNAMIC RESPONSE OF THE CLOSED-LOOP SYSTEM? • In a few cases, we can do this analytically (See Example 8.5) • In most cases, we must solve the equations numerically. At each time step, we integrate - The differential equations for the process - The differential equation for the controller - Any associated algebraic equations • Many numerical methods are available • “S_LOOP” does this from menu-driven input CHAPTER 8: THE PID, WORKSHOP 1 • Model formulation: Develop the equations that describe the dynamic behavior of the three-tank mixer and PID controller. • Numerical solution: Develop the equations that are solved at each time step for the simulated control system (process and controller). FS solvent FA pure A AC CHAPTER 8: THE PID, WORKSHOP 2 • The PID controller is applied to the three-tank mixer. Prove that the PID controller with provide zero steady-state offset when the set point is changed in a step, SP. • The three-tank process is stable. If we add a controller, could the closed-loop system become unstable? FS solvent FA pure A AC CHAPTER 8: THE PID, WORKSHOP 3 • Determine the engineering units for the controller tuning parameters in the system below. • Explain how the initialization constant (I) is calculated. This is sometimes called the “bias”. FS solvent CV FA pure A From person SP AC MV E (t ) SP(t ) CV (t ) t 1 d CV MV (t ) K c E (t ) E (t ' )dt 'Td I TI 0 dt CHAPTER 8: THE PID, WORKSHOP 4 The PID controller must be displayed on a computer console for the plant operator. Design a console display and define values that • The operator needs to see to monitor the plant • The operator can change to “run” the plant • The engineer can change FS solvent FA pure A AC CHAPTER 8: THE PID CONTROLLER When I complete this chapter, I want to be able to do the following. • Understand the strengths and weaknesses of the three modes of the PID • Determine the model of a feedback system using block diagram algebra • Establish general properties of PID feedback from the closed-loop model Lot’s of improvement, but we need some more study! • Read the textbook • Review the notes, especially learning goals and workshop • Try out the self-study suggestions • Naturally, we’ll have an assignment! CHAPTER 8: LEARNING RESOURCES • SITE PC-EDUCATION WEB - Instrumentation Notes - Interactive Learning Module (Chapter 8) - Tutorials (Chapter 8) CHAPTER 8: SUGGESTIONS FOR SELF-STUDY 1. In your own words, explain each of the PID modes. Give at least one advantage and disadvantage for each. 2. Repeat the simulations for the three-tank mixer with PID control that are reported in these notes. You may use the MATLAB program “S_LOOP”. 3. Select one of the processes modelled in Chapters 3 or 4. Add a PID controller to the numerical solution of the dynamic response in the MATLAB m-file. 4. Derive the transfer function for the PID controller.