Lecture 6 Modeling in Digital Form PID Controllers Proportional Controller Proportional Controller Proportional Controller Integral Controller Derivative Controller PID Controllers Proportional Controller E(s) Integral Controller Derivative Controller P(s) = E(s) *[Kc + 1/TI s + TDs] or P(s) = E(s) *[Kc (1 + 1/TI's + TD's)] or P(s) = E(s) * Kc (TI'TD's2 + TI's +1) TI's There are some textbooks that consider placing these three modes in series: Putting PI controller in series will give Integral control with a gain of Kc/TI Putting PD controller in series will give Derivative control with a gain of KcTD Putting ID controller in series will give Proportional control with a gain of TD/TI Putting PID controller in series will give Proportional control with a gain of KcTD/TI PID Controllers – Series Configuration Proportional Controller Proportional Controller E(s) P(s) Integral Controller Derivative Controller Putting PI and PD in series results in essentially the same control equation as PID - only the b term in the quadratic is different { TI' >>>> (TI' + TD')/ TI' } P, PI, and PID Controllers Analog Equations Proportional Integral Derivative Analog vs. Digital • Previous equations for controllers are analog • The initial value p0 is needed to use these equations in a continuous process unless deviation variables are used • Digital form is required for use on a computer • Digital form use with deviation variables is important so that you understand the need for deviation variables in each control mode Proportional-Integral-Derivative Control • This subtle change in form allows the equation to be used for real-time digital application in a computer subroutine tied to a process, a final control element, and a measurement block. • Take care to account for the change in error, since by including only the current error value, you will be implementing Integral control when you may intend to use Proportional control. Proportional Control Analog form: p(t) = Kcε(t) + p0 The initial value cannot be established, so we must consider the differences between the current and previous input and output values: change in output = Kc * change in error p(t) – p(t-1) = Kc*[ε(t) – ε(t-1)] P Control – comparison of step change Assume Kc = 25 and p0 = 325 Introduce a step change ε(t) = A where A = 1.0 t t-1 ε(t) ε(t-1) p(t) (analog) p(t) (digital) -1 -2 0 0 325 325 0 -1 1 0 350 350 1 0 1 1 350 350 2 1 1 1 350 350 3 2 1 1 350 350 4 3 1 1 350 350 5 4 1 1 350 350 P Control – comparison of a ramp change Assume Kc = 25 and p0 = 325 Introduce a ramp change ε(t) = A*t where A = 1.0 t t-1 ε(t) ε(t-1) p(t) (analog) p(t) (digital) -1 -2 0 0 325 325 0 -1 0 0 325 325 1 0 1 0 350 350 2 1 2 1 375 375 3 2 3 2 400 400 4 3 4 3 425 425 5 4 5 4 450 450 P Control – graphical comparison Assume Kc = 25 and p0 = 325 and A = 1.0 Integral Control Analog form: The initial value cannot be established, so we must establish the area numerically: change in output = [1 /TI]* ε-t curve area change p(t) – p(t-1) = [1 /TI]*[ε(t) + ε(t-1)]*Δt/2 I Control – comparison of step change Assume TI = 0.04, p0 = 325 and Δt = 1 Introduce a step change ε(t) = A where A = 1.0 t t-1 ε(t) ε(t-1) p(t) (analog) p(t) (digital) -1 -2 0 0 325 325 0 -1 1 0 325 337.5 1 0 1 1 350 362.5 2 1 1 1 375 387.5 3 2 1 1 400 412.5 4 3 1 1 425 437.5 5 4 1 1 450 462.5 I Control – comparison of a ramp change Assume TI = 0.04, p0 = 325 and Δt = 1 Introduce a ramp change ε(t) = A*t where A = 1.0 t t-1 ε(t) ε(t-1) p(t) (analog) p(t) (digital) -1 -2 0 0 325 325 0 -1 0 0 325 325 1 0 1 0 350 350 2 1 2 1 425 425 3 2 3 2 550 550 4 3 4 3 725 725 5 4 5 4 950 950 I Control – graphical comparison Assume TI = 0.04, p0 = 325, and Δt = 1 and A = 1.0 Derivative Control Analog form: The initial value cannot be established, so we must consider establishing the area numerically: change in output = TD * ε-t curve slope change p(t) – p(t-1) = TD*[(ε(t) – ε(t-1)) – (ε(t-1) – ε(t-2))]/Δt p(t) – p(t-1) = TD*[ε(t) – 2*ε(t-1) + ε(t-2)]/Δt D Control – comparison of step change Assume TD = 25, p0 = 325 and Δt = 1 Introduce a step change ε(t) = A where A = 1.0 t t-1 ε(t) ε(t-1) ε(t-2) p(t) (analog) p(t) (digital) -1 -2 0 0 0 325 325 0 -1 1 0 0 350 ∞ 1 0 1 1 0 325 325 2 1 1 1 1 325 325 3 2 1 1 1 325 325 4 3 1 1 1 325 325 5 4 1 1 1 325 325 D Control – comparison of a ramp change Assume TD = 25, p0 = 325 and Δt = 1 Introduce a ramp change ε(t) = A*t where A = 1.0 t t-1 ε(t) ε(t-1) ε(t-2) p(t) (analog) p(t) (digital) -1 -2 0 0 0 325 325 0 -1 0 0 0 350 325 1 0 1 0 0 350 350 2 1 2 1 0 350 350 3 2 3 2 1 350 350 4 3 4 3 2 350 350 5 4 5 4 3 350 350 D Control – graphical comparison Assume TD = 25, p0 = 325, and Δt = 1 and A = 1 D Control – graphical comparison Assume TD = 25, p0 = 325, and Δt = 1 and A = 1 • Note that response of a digital Derivative controller is slower than that of an analog Derivative controller by the value of Δt • As well, step change response is not an impulse, but instead a square wave occurs of amplitude equal to TD/Δt; the smaller is Δt, the closer to infinity • Similarly, response to a sine wave of frequency ω does not lead by 90° as it is supposed to, but rather by a value decreased by Δt·ω converted to degrees. The Digital Equation for PID Control Instead of using Kc , TI , and TD parameters with the error signal, it can be more convenient to express the equation as a time-series with the current, previous, and past-previous errors: p(t) = p(t–1) + K1*ε(t) + K2*ε(t–1) + K3*ε(t–2) where K1 = + Kc + Δt/2TI + TD /Δt K2 = –Kc + Δt/2TI – 2TD /Δt K3 = + TD /Δt PID Tuning – Continuous Oscillation This is a Closed-Loop study developed by ZieglerNichols in the late 1940s for stable processes: 1. 2. 3. 4. 5. Set the system to P control with a low gain Increase the gain until continuous oscillations occur Record this value as the critical controller gain Kc(c) Record the period of oscillation, P(c) Controller parameters are shown on the next slide PID Tuning – Continuous Oscillation Control Mode P PI PID Kc 0.5Kc(c) 0.45Kc(c) 0.6Kc(c) TI 0.833P(c) 0.500P(c) TD 0.125P(c) These settings were designed to achieve an under-damped response to a step change for processes that can be modelled by the following Laplace Transform: - This is a First Order process with a pure time delay (dead time) PID Tuning – Continuous Oscillation Results of the Ziegler-Nichols Continuous Oscillation method for a First Order process with delay time. (R = Td/Tp) R = 0.1 R = 0.5 R = 2.0 PID Tuning - Reaction Curve Method A process model can be obtained from an Open-Loop test: 1. Operate the process in open loop (i.e., no control) 2. Allow it to run at a typical operating point y(t) = yo with input held constant at u(t) = uo. (steady-state conditions) 3. At time to=0, apply a step change to the process input, from uo to u∞ (use a range of 5 to 20% of full scale) 4. Record output until it reaches a new steady state value 5. The curve will resemble an S-shape curve known as the Process Reaction Curve PID Tuning - Reaction Curve Method Typical open-loop process response to a stepchange in the input variable: The model is considered a First Order process with a pure time delay. The key parameters are Kp , Tp , and Td and the transform equation is u(t) y(t) PID Tuning - Reaction Curve Method Compute the model parameters as follows: Kp = (y∞ – y0) / (u∞ – u0) Tp = t32 – t1 y(t) = 0.632*(y∞ – y0) Td = t1 – t0 t3 u(t) y(t) A Better Diagram http://blog.opticontrols.com/wp-content/uploads/2011/06/measuring-td-and-tau.png Ziegler-Nichols Tuning Rules Design objective: achieve a damping in response to a step change of 4:1 for first and second peaks in the response curve (quarter decay ratios). Quarter Amplitude Damping. Each successive peak is 1/4 of the amplitude of the previous peak. Ziegler-Nichols Tuning Rules Design objective: achieve a damping in response to a step change of 4:1 for first and second peaks in the response curve (quarter decay ratios). Control Mode P PI PID Kc 1.0/KpR 0.9/KpR 1.2/KpR TI 3.0Td 2.0Td TD 0.5Td where R = Td / Tp and Kp is the process gain Caution with Quarter-Amplitude Damping Tuning based on quarter-amplitude damping does provide fast response to a new steady-state regime. It is oscillatory and may interact poorly with other similarly-tuned loops. This type of tuning leaves the system in a position of possible instability if the process gain or delay ("dead") time doubles . To "fix" both problems, take half the value of the controller gain. So, if the rule recommends using a controller gain of 1.6, use only 0.8. This will prevent severe oscillation about the set point and provide an acceptable margin of stability. Response time, of course, will suffer. Cohen and Coon Tuning Rules Similar design objective but provides better tuning for R values (Td /Tp) above 0.2 Control Mode Kc TI TD P 1.0/KpR - - PI 0.9/KpR 3.0Td - PID 1.2/KpR 2.0Td 0.5Td Cohen and Coon Tuning Rules Similar design objective but provides better tuning for R values (Td /Tp) above 0.2 Control Mode Kc TI TD P (3 + R) 3KpR - - PI (10.8 + R) 12KpR Td (30 + 3R) (9 + 20R) - PID (16 + 3R) 12KpR Td (32 + 6R) (13 + 8R) 4Td (11 + 2R) Comparison of Tuning Rules R R R R R R R = 5.0 Pure Delay vs. Process Time Lag The Digital Equation for PID Control p(t) = p(t–1) + K1*ε(t) + K2*ε(t–1) + K3*ε(t–2) where K1 = + Kc + Δt/2TI + TD /Δt K2 = –Kc + Δt/2TI – 2TD /Δt K3 = + TD /Δt To achieve quarter decay ratios: K1 = (+A + Δt/BTd + CKpTd /Δt)/Kp K2 = (–A + Δt/BTd – 2CKpTd /Δt)/Kp K3 = + CTd /Δt where A , B , and C are derived from Ziegler-Nichols or Cohen-Coon rules as follows: The Digital Equation for PID Control For Ziegler-Nichols rules (R = Td/Tp): A = 1.2/R B = 4.0 C = 0.5 For Cohen-Coon rules (R = Td/Tp): A = (16 + 3R)/12R B = 2(32 + 6R)/(13 + 8R) C = 4 /(11 + 2R) "Optimum" PID values from Open-Loop Tuning Rules Method CohenCoon ZeiglerNichols Coefficient R = Td/Tp 0.0 0.1 0.2 0.4 0.6 0.8 1.0 1.2 A (max) 13.6 6.9 3.6 2.5 1.9 1.6 1.4 B 4.9 4.7 4.5 4.2 4.0 3.8 3.6 3.5 C 0.36 0.36 0.35 0.34 0.33 0.32 0.31 0.30 A (max) 12.0 6.0 3.0 2.0 1.5 1.2 1.0 B 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 C 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 Cohen & Coon use a higher Proportional control effect compared to Zeigler-Nichols for all sensible values of R. Cohen & Coon use a slightly lower Integral control effect compared to Zeigler-Nichols for values of R < 0.6 and a slightly higher Integral control effect for R > 0.6. Cohen & Coon use a lower Derivative control compared to Z-N for all sensible R values. The Influence of Sampling Time In many cases, the feedback loop generates a measurement sample every "x" minutes. With on-stream analysers, a sample multiplexer is used to present multiple streams one at a time to the X-ray scintillator. Each sample is read for a period of 20-30 seconds and the total count is recorded, passed through a calibration equation, and the stream assay output from the unit. The delay between consecutive samples of the same stream is typically 7–12 minutes and can be as high as 15 minutes. The effect of this time delay on control is considerable. The Influence of Sampling Time Effect of sampling time on the control system response of a first order process with a pure time lag (dead time). Time units are arbitrary, but the Δt value is expressed in the same units as the process time constant. Aliasing • Time delays from sampling intervals can introduce aliasing into the time series analysis Aliasing • Basically, high frequencies in a signals are lost and may appear as lower frequency signals: Anti-Aliasing • Generally anti-aliasing filters are reserved for audio and video signals to filter out noise • Not strictly a problem in mineral processing, but it must be recognized that frequency of measurement should be higher than the maximum frequency of the variable changes. Sampling Rate Sampling rate (or frequency) defines the number of samples per unit time (seconds or minutes) taken from a continuous signal to make a discrete signal. The sampling rate unit is Hertz (1/s, s−1) The reciprocal of the sampling frequency is sampling period (or interval), i.e., time between samples. Nyquist–Shannon sampling theory states that perfect reconstruction of a signal is possible when sampling frequency is greater than 2 times the maximum frequency of the signal, or equivalently, when the Nyquist frequency (0.5 x sampling rate) exceeds the highest frequency of the signal being sampled. From experience, a sampling interval of approximately 10% of the dominant time constant works well in practice.