Three-term controller Ziegler-Nichols tuning rules Summary

Basics of and Control I

Lecture 13: PID controllers

Paweł Malczyk

Division of Theory of Machines and Robots Institute of Aeronautics and Applied Mechanics Faculty of Power and Aeronautical Engineering Warsaw University of Technology

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 1 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Outline

1 Three-term controller

2 Ziegler-Nichols tuning rules

3 Summary

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 2 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Three-term controller

1 Three-term controller Introduction Basic control functions P controller PI controller PD controller PID controller

2 Ziegler-Nichols tuning rules

3 Summary

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 3 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Introduction

Fig. 1: Block diagram of a process with feedback controller

1 The three-term controller, i.e. proportional-integral-derivative (PID) controller, is a control loop feedback mechanism widely used in many industrial control systems. 2 PID controllers appear in many different forms: as stand-alone controllers, as part of hierarchical, distributed control systems and built into embedded components. 3 By tuning the three parameters in the PID controller algorithm, the controller can provide control action designed for specific process requirements (benign process dynamics, moderate performance).

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 4 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Basic control functions

Fig. 2: Block diagram of feedback with ideal PID controller The input/output relation for an ideal PID controller*: [ ∫ ] 1 t de(t) u(t) = k e(t) + e(τ)dτ + T = p T d dt ∫i 0 (1) t de(t) = kpe(t) + ki e(τ)dτ + kd 0 dt e(t) = r(t) − y(t) – error signal, u(t) – control signal,

kp – proportional gain, Ti – integral time, Td – derivative time, k = kp – integral gain, k = k T – derivative gain. i Ti d p d * Modified versions of the PID controller are used in practical applications.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 5 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Basic control functions Ideal PID controller: [ ∫ ] t 1 de(t) u(t) = kp e(t) + e(τ)dτ + T T d dt i 0 ( ) (2) ( ) → U s 1 C(s) = = kp 1 + + Tds E(s) Tis

Fig. 3: Block diagram of ideal PID controller • P controller (Ti = ∞, Td = 0) C(s) = kp (3)

• PI controller (Td = 0)( ) 1 C(s) = kp 1 + (4) Tis

• PD controller (Ti = ∞) C(s) = kp(1 + Tds) (5) Fig. 4: PID interpretation → Gentle introduction to PID controllers: https://www.youtube.com/watch?v=4Y7zG48uHRo. © Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 6 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Mechanical system

Ns N Fig. 5: Układ mechaniczny. Stałe fizyczne: m = 1 kg, b = 2 m , k = 5 m Goal: choose a control force f(t) (in N) such that the mass will stop at the desired position (say 1 m from equilibrium). Y(s) 1 Plant tranfer function G(s) = F(s) = ms2+bs+k . Reference signal (desired position): r(t) = yd · 1(t) (yd = 1 m). In steady-state the force f(t) need to balance the spring force, i.e.: f = k · yd · 1(t), then 1 yss = lim y(t) = lim sY(s) = lim sG(s)F(s) = lim sG(s)kyd = G(0)kyd = yd t→∞ s→0 s→0 s→0 s

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 7 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Mechanical system with disturbance

Fig. 6: Mechanical system. Physical constants: m = 1 kg, b = 2 Ns , k = 5 N , and g = 10 m m m s2 Y(s) 1 Plant transfer function G(s) = F(s) = ms2+bs+k . Disturbance – gravity force: d(t) = −mg · 1(t).

Reference signal (desired position): r(t) = yd · 1(t) (yd = 1 m). In steady-state the force f(t) need to balance the sum of spring force and the gravity force, i.e.: u = (k · yd + mg) · 1(t). Assumption: perfect knowledge of parameters and disturbance...

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 8 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Mechanical system with parametric uncertainty

True values: m, b, k. Estimated params: m, b, k. Real parameters and disturbance signals are

usually unknown. Fig. 7: Mechanical system with parametric uncertainty

Control signal: u = (k · yd + mg) · 1(t). Input signal: f = (kyd + (m − m)g) · 1(t). Steady-state response: − 1 1 − yss = lim y(t) = lim sY(s) = lim sG(s)(kyd+(m m)g) = (kyd+(m m)g) t→∞ s→0 s→0 s k Error signal: 1 1 e = y − y = y − (ky + (m − m)g) = ((k − k)y + (m − m)g) ss ss ss d k d k d The greater the uncertainty is, the greater the steady-state error is. Transient-response is not controlled. Open-loop control is sensitive to parametric uncertainty.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 9 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Proportional control

Fig. 8: Feedback control system

Assumption: u(t) = kp(r(t) − y(t)) – force proportional to the error. Open-loop transfer function: L(s) = C(s)G(s).

Y(s) L(s) kp Closed-loop transfer function: T(s) = = = 2 . R(s) 1+L(s) ms +bs+k+kp

kp – virtual spring coefficient. Let us calculate the response y(t) and steady-state error e(t).

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 10 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Proportional control

Fig. 9: Feedback control system The response: Y(s) = T(s)R(s) + G(s)S(s)D(s). Sensitivity function: 1 ms2 + bs + k ( ) = = S s 2 1 + L(s) ms + bs + k + kp Load disturbance sensitivity function: 1 ( ) = ( ) ( ) = W s G s S s 2 ms + bs + k + kp · → yd Reference signal: r(t) = yd 1(t) R(s) = s − · → − mg Disturbance: d(t) = mg 1(t) D(s) = s .

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 11 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Proportional control

Fig. 10: Feedback control system Steady-state response:

yd mg yss = lim y(t) = lim sY(s) = lim s(T(s) + W(s)(− )) = t→∞ s→0 s→0 s s − kp − 1 = ydT(0) mgW(0) = yd mg k + kp k + kp

If k → ∞, then kp → 1 and 1 → 0. In consequence: y = y . p k+kp k+kp ss d Conclusion: → disturbance rejection (even unknown) and trajectory tracking.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 12 / 35 Three-term controller Ziegler-Nichols tuning rules Summary P controller

Fig. 11: P controller, C(s) = kp Effects of P controller Proportional term, P, causes a corrective control actuation proportional to the error. The system with P controller will usually have nonzero steady-state errors. As kp increases, then the static position error decreases.

As kp increases, the stability margins decrease and the system may become unstable. As kp increases, the BW (as well as overshoot and settling time) increases. It is difficult to ensure both good transient response accuracy and steady- state performance.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 13 / 35 Three-term controller Ziegler-Nichols tuning rules Summary P controller

kp=30 40 1.4 30 1.2 20 10 1 r(t) 0 0.8 -10 -20 y(t) 0.6 kp=30 kp=25 -30 0.4 kp=20

Magnitude (dB) Magnitude -40 0.2 kp=15 -50 -60 0 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t kp=30 0 30 25 -30 20 -60 15 10 -90 G C u(t) 5 kp=15 -120 L 0 kp=20 Phase (deg) Phase S -5 kp=25 -150 T -10 kp=30 -180 -15 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t

Fig. 12: P controller characteristics  Comment 1 If kp ↗, then Mp ↗, tp ↘, ts ↗, ess ↘, stability issues.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 14 / 35 Three-term controller Ziegler-Nichols tuning rules Summary P controller

kp=30 40 1.4 30 1.2 20 10 1 r(t) 0 0.8

-10 y(t) 0.6 -20 kp=30 kp=25 Magnitude (dB) Magnitude G -30 0.4 kp=20 C -40 L kp=15 S 0.2 -50 T -60 0 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t Fig. 13: P controller characteristics

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 15 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PI controller

( ) 1 Fig. 14: PI controller, C(s) = kp 1 + Tis Effects of PI controller The integral term, I, gives a correction proportional to the integral of the error. PI largely reduces the steady-state errors (compared to P controller). It may cause the closed loop system less stable (or even unstable). PI may slow down the transient response. Filtering out high-frequency noise. Windup - interaction of integral action and saturations.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 16 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PI controller

kp=30, Ti=1 kp=30 80 1.6 60 1.4 1.2 40 1 20 0.8 0.6 0 y(t) 0.4 Ti=1 -20 0.2 Ti=5 0 -40 Ti=10 Magnitude (dB) Magnitude -0.2 G C L S T -60 -0.4 Ti=100 -80 -0.6 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t kp=30, Ti=1 kp=30 0 30 25 -30 20 -60 15 10 -90 G 5 C u(t) 0 Ti=1 -120 L -5 Ti=5 Phase (deg) Phase S Ti=10 -150 -10 T -15 Ti=100 -180 -20 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t

Fig. 15: PI controller characteristics  Comment 2 If Ti ↘, then Mp ↗, ts ↗, ↘, ess ↘.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 17 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PI controller

kp=30, Ti=1 kp=30 80 1.6 G 1.4 60 C L 1.2 40 S 1 T 20 0.8 0.6 0 y(t) 0.4

-20 0.2 Magnitude (dB) Magnitude -40 0 Ti=1 -0.2 Ti=5 -60 Ti=10 -0.4 Ti=100 -80 -0.6 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t Fig. 16: PI controller characteristics

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 18 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PD controller

Fig. 17: PD controller, C(s) = kp(1 + Tds) Effects of PD controller The derivative term, D, gives a predictive capability yielding a control action proportional to the rate of change of the error. Derivative action tends to have a stabilizing effect. PD controller adds damping and reduces maximum overshoot. It improves the transient response (decreases rise and settling time). PD controller improves relative stability (increases gain and phase margins). Possibly accentuating noise at higher frequencies. Filtered version of the PD (or PID) controller is used due to derivative kick, ( ) = ( + 1 ) then, C s kp 1 Tds Td . Typical values of N are 8 to 20. N s+1

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 19 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PD controller

kp=30, Td=0.1 kp=30 80 1.4 1.2 60 G C L S T 1 40 0.8 20 0.6 0.4 0 y(t) 0.2 Td=0 -20 0 Td=0.01 Td=0.05 Magnitude (dB) Magnitude -0.2 -40 -0.4 Td=0.1 -60 -0.6 10-2 10-1 100 101 102 103 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t kp=30, Td=0.1 kp=30 120 30 90 25 60 20 30 15 0 10 -30 G u(t) 5 -60 C Td=0

-90 L 0 Td=0.01 Phase (deg) Phase -120 S -5 Td=0.05 -150 T -10 Td=0.1 -180 -15 10-2 10-1 100 101 102 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t

Fig. 18: PD controller characteristics  Comment 3 If Td ↗, then Mp ↘, tp ∼↗, ts ↘.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 20 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PD controller

kp=30, Td=0.1 kp=30 80 1.4 G 1.2 60 C L 1 S 40 T 0.8 0.6 20

0.4 y(t) 0

0.2 Magnitude (dB) Magnitude -20 0 Td=0 -0.2 Td=0.01 -40 Td=0.05 -0.4 Td=0.1 -60 -0.6 10-2 10-1 100 101 102 103 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t Fig. 19: PD controller characteristics

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 21 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PID controller

( ) 1 Fig. 20: PID controller, C(s) = kp 1 + + Tds Tis Effects of PID controller The features of each of the PI and PD controllers are utilized. Improves both steady-state errors as well as transient response specifications. The PID controller algorithm involves three separate constant parameters that need to be tuned.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 22 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PID controller

kp=30, Td=0.1, Ti=1 kp=30, Td=0.1, Ti=1 80 1.4 60 1.2 40 1 20 0.8 0 y(t) 0.6 -20 0.4

-40 y(t) Magnitude (dB) Magnitude -60 G C L S T 0.2 r(t) -80 0 10-3 10-2 10-1 100 101 102 103 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t kp=30, Td=0.1, Ti=1 kp=30, Td=0.1, Ti=1 120 50 90 60 40 30 30 0 -30 20 -60 u(t)

-90 10 Phase (deg) Phase -120 0 -150 G C L S T u(t) -180 -10 10-3 10-2 10-1 100 101 102 103 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t

Fig. 21: PID controller characteristics

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 23 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PID controller

kp=30, Td=0.1, Ti=1 kp=30, Td=0.1, Ti=1 80 1.4

60 1.2

40 1 20 0.8

0 y(t) 0.6

-20 Magnitude (dB) Magnitude 0.4 -40

-60 0.2 y(t) G C L S T r(t) -80 0 10-3 10-2 10-1 100 101 102 103 0 1 2 3 4 5 6 7 8 9 10 Frequency (rad/sec) t Fig. 22: PID controller characteristics

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 24 / 35 Three-term controller Ziegler-Nichols tuning rules Summary PID controllers

Fig. 23: Ideal P, PI, PD and PID controllers 1 PID controllers are applicable to many control problems, and often perform satisfactorily. 2 Ideal PID are linear controllers with constant coefficients. 3 There are many variations of PID controllers associated with practical control applications (e.g. preventing from integrator windup).

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 25 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Ziegler-Nichols tuning rules

1 Three-term controller

2 Ziegler-Nichols tuning rules Introduction First method Second method Comments Example

3 Summary

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 26 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Introduction

Fig. 24: Ideal PID controller and plant If a mathematical model of the plant is known, then it is possible to design the PID controller that will meet the transient and steady-state specifications of the closed-loop system. If the mathematical model cannot be easily obtained, one should select the controller parameters experimentally, which known as a process of controller tuning. Experimental Ziegler and Nichols tuning rules for PID controllers as a starting point for fine tuning.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 27 / 35 Three-term controller Ziegler-Nichols tuning rules Summary First method

Experimental response of the plant due to Y(s) a unit-step input. The transfer function U(s) may be approximated by Y(s) Ke−τs G(s) = = (6) U(s) Ts + 1 T – time constant, τ – delay, K – gain.  Comment 4 The controller parameters are designed to result in 25% amplitude decay ratio in one Fig. 25: S-shaped response of a closed-loop system due to a unit-step input. The plant period. involves neither integrators nor dominant complex conjugate closed-loop poles Ziegler-Nichols tuning rule based on a step response of a plant

Type kp Ti Td T ∞ P Kτ 0 T τ PI 0.9 Kτ 0.3 0 T PID 1.2 Kτ 2τ 0.5τ

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 28 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Second method

Fig. 26: Closed-loop system with P controller and sustained oscillation with period Tcr Ziegler-Nichols tuning rule based 1. Set Ti = ∞, Td = 0 and increase kp on a critical period Tcr from 0 to a critical value kcr, where the output exhibits sustained oscillations. Type kp Ti Td

2. Find the critical period Tcr. P 0.5kcr ∞ 0 1 3. Select the parameters kp, Ti and Td PI 0.45kcr 1.2 Tcr 0 according to the table. PID 0.6kcr 0.5Tcr 0.125Tcr  Comment 5 The controller parameters are designed to result in 25% amplitude decay ratio in one period.  Comment 6 One can use Nyquist plot to find kcr, and Tcr.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 29 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Comments

1 Ziegler-Nichols tuning rules (and other tuning rules) have been widely used in systems. 2 The plant dynamics may be known or may be not precisely known. 3 Experience has shown that the Z-N rules provide acceptable closed-loop response for many systems. 4 The empirical PID tuning strategies are only starting points in the process to obtain the right controller. 5 Tuning method (by Astrom & Hagglund) based on relay feedback is available.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 30 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Example

 Example 1 Consider the control system shown in the Fig. 27. The process Y(s) 1 has transfer function G(s) = U(s) = (Ts+1)2 . Apply the Ziegler-Nichols tuning rule to determine the constants of the P, PI, and PID controller.

Fig. 27: Liquid-level control system

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 31 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Example

− Ke τs Process model G(s) = Ts+1 . K = 1 τ = t = 12.72sec 1 T = t3 − t1 = 122.737sec Type k T T p i d T ∞ P Kτ 0 PI 0.9 T τ 0 Kτ 0.3 T PID 1.2 Kτ 2τ 0.5τ Type k T T p i d − . ∞ − P 9 6491 0 PI 8.6842 42.3576 0 PID 11.579 25.44 6.36 Fig. 28: Process reaction curve ( ) 1 CP(s) = 9.6491, CPI(s) = 8.6842 1 + , ( ) 42.3576s 1 CPID(s) = 11.579 1 + + 6.36s 25.44s

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 32 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Example

− − −

Fig. 29: Closed loop system responses for various controllers

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 33 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Review questions

1 What is the main objective of introducing proportional control, integral control or derivative control? 2 What is a P, PI, PD, PID controller? Write the input-output relation, unit-step response and Bode plots. 3 Give the effects of P,PI, PD and PID controllers on the feedback control system performance. 4 Formulate and comment on the two Ziegler-Nichols tuning rules for a PID controller. Discuss the range of applicability of both methods.

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 34 / 35 Three-term controller Ziegler-Nichols tuning rules Summary Summary

1 Three-term controller

2 Ziegler-Nichols tuning rules

3 Summary

© Paweł Malczyk. Basics of Automation and Control I Lecture 13: PID controllers 35 / 35