Control Systems 2 Lecture 13: Digital controller design Roy Smith 2016-5-24 13.1 Digital control system design Sampled-data closed-loop y(k) y(t) T G(s) u(t) ZOH u(k) Kd (z) + − Kd (z) + r(k) GZOH (z) equivalence GZOH (z) y(k) T G(s) ZOH r(k) − 2016-5-24 13.2 Zero-order hold equivalence — transfer function y(k) y(t) G(s) T | Input: u(k) = Output: ( 1 0 u(t) {z } GZOH (z) k = 0, , k 6= 0 u(k) ZOH u(t) = step(t) − step(t − T ). G(s) . y(s) = 1 − e−T s s We now sample this, and take the Z-transform, −T s G(s) GZOH (z) = Z 1−e s G(s) −1 = (1 − z )Z . s 2016-5-24 13.3 Zero-order hold equivalence — state space y(k) y(t) G(s) T | u(t) u(k) ZOH {z } GZOH (z) Integrating Φ(t) over a single sample period (kT to kT + T ): Z kT +T AT x(kT + T ) = e x(kT ) + eA(kT +T −τ ) Bu(τ ) dτ, kT 2016-5-24 A C B D ZOH-equivalence =⇒ AT e C Z T Aη e 0 D B dη 13.4 Zero-order hold equivalence — frequency domain Example: G(s) = (2 − s) , (2s + 1)(s + 2) T = 0.6 0.1 π/T 1 10 1 log ω (rad/sec) GZOH (ejω ) 0.1 G(jω) G(jω)e−jωT /2 Magnitude 0.01 π/T 1 10 0 log ω (rad/sec) −90 G(jω) −180 GZOH (ejω ) G(jω)e−jωT /2 Phase (deg.) 2016-5-24 13.5 Digital control system design Sampled-data closed-loop y(k) y(t) T G(s) u(t) ZOH u(k) Kd (z) + − r(k) K(s) approximation ≈ K(s) y(k) T G(s) ZOH Kd (z) + r(k) − 2016-5-24 13.6 Design approaches G(s) Continuous-time design K(s) Approximation of K(s) with Kd (z) ZOH-equivalence of G(s) and sample/hold GZOH (z) Discrete-time design Kd (z) 2016-5-24 13.7 Design approaches G(s) Continuous-time design K(s) Sampled-data design Approximation of K(s) with Kd (z) ZOH-equivalence of G(s) and sample/hold GZOH (z) 2016-5-24 Discrete-time design Kd (z) 13.8 Design by approximation 1. Design a continuous-time controller, K(s) I Verify stability, performance and bandwidth I Verify margins and robustness 2. Select a sample-rate, T 3. Find Kd (z) approximating K(s) 4. Calculate the ZOH-equivalent GZOH (z) 5. Check the stability of the GZOH (z), Kd (z) loop 6. Simulate Kd (z) with G(s) (including sample/hold). I Verify simulated performance I Examine intersample behaviour 2016-5-24 13.9 Controller approximation Approach: approximating the integrators y(t) x(t) 1/s y(k) ≈ If F (z) ≈ 1/s, then, s ≈ F −1 (z), y(s) 2016-5-24 F (z) x(s) A C B D x(k) =⇒ Kd (z) = K(s) |s=F −1 (z) 1 I s sx(s) F (z) u(s) zx(z) y(z) x(z) A C B D u(z) 13.10 Integration x(t) y(t) x(t) 1/s y(t) = y(0) + Z x(kT +T ) t x(τ ) dτ, 0 x(kT ) y(kT +T ) − y(kT ) kT kT +T Time [sec.] The signal, y(t), over a single T second sample period is, Z kT +T y(kT + T ) = y(kT ) + x(τ ) dτ. kT 2016-5-24 13.11 Trapezoidal approximation ŷ(kT + T ) = ŷ(kT ) + T x(kT ) + (x(kT + T ) − x(kT ))T /2. Taking z-transforms, z ŷ(z) = ŷ(z) + T x(z) + Approximation: ŷ(z) T z+1 = F (z) = . x(z) 2 z−1 T (z − 1)x(z), 2 x(t) x(kT +T ) So the substitution is, s ←− 2 z−1 . T z+1 x(kT ) ŷ(kT +T ) − ŷ(kT ) kT kT +T Time [sec.] This is known as a bilinear (or Tustin) transform. 2016-5-24 13.12 Frequency mapping Pole locations under bilinear transform: { s | real(s) < 0 } K(s) stable bilinear −→ ⇐⇒ { z | |z| < 1 } Kd (z) stable. imag imag 1 2π/T π/T s= 2 (z−1) T (z+1) −→ real real −1 1 −π/T −1 −2π/T 2016-5-24 13.13 Bilinear frequency distortion Ω : discrete-frequencies: ejΩT , Ω ∈ (−π, π]. Frequency mapping: Continuous frequencies, ω to discrete frequencies, Ω. Substitute s = jω and z = ejΩT into s = 2 z−1 : T z+1 −jΩT 2 j sin(ΩT /2) 2 2 1−e jω = = = j tan(ΩT /2). −jΩT T (1 + e ) T cos(ΩT /2) T Frequency distortion: Ω= 2016-5-24 2 tan−1 (ωT /2) T 13.14 Bilinear frequency distortion Ω= 2 tan−1 (ωT /2) T Tustin/bilinear transform π Discrete frequency (Ω): [rad/sec] Continuous frequency (ω): [rad/sec] −3π/T 0 −π/T −2π/T π/T 2π/T 3π/T −π Ω = ωT The Ω = ωT line is the sampling mapping. 2016-5-24 13.15 Prewarping s= α(z − 1) , α ∈ (0, π/T ), maps {real{s} < 0} to {|z| < 1}. (z + 1) Modifying the frequency distortion Select a frequency ωpw . Solve for α such that K(jωpw ) = Kd ejωpw T . The “prewarped” transform makes K(jω) = Kd (ejωT ) at ω = 0 and ω = ωpw . jω0 = α(ejωpw T − 1) (ejωpw T + 1) which implies that: 2016-5-24 α= = jα tan(ωpw T /2), ωpw . tan(ωpw T /2) 13.16 Prewarping Frequency distortion (bilinear:) Ω = 2 tan−1 (ωT /2). T Frequency distortion (with prewarping): Ω = 2 tan−1 (ω/α) T Prewarping distortion Discrete frequency: [rad/sec] 50 Bilinear distortion Prewarping frequency -150 -100 0 -50 50 100 150 Continuous frequency: [rad/sec] -50 Ω = ωT 2016-5-24 13.17 Controller approximations Bilinear approximation: Kbl (ejω ), Prewarped Tustin approximation: Kpw (ejω ) 10 Magnitude 10 Kbl (ejω ) ωpw K(jω) log ω (rad/sec) 1 Kpw (ejω ) 0.1 0.01 90 10 0 Kbl (ejω ) log ω (rad/sec) ωpw Kpw (ejω ) −90 −180 2016-5-24 K(jω) Phase (deg.) 13.18 Choosing a prewarping frequency The prewarping frequency must be in the range: 0 < ωpw < π/T . I α = 2/T (standard bilinear) corresponds to ωpw = 0. Possible options for ωpw depend on the problem: I The cross-over frequency (helps preserve the phase margin); I The frequency of a critical notch; I The frequency of a critical oscillatory mode. The best choice depends on the most important features in your control design. Remember: K(s) stable implies Kd (z) stable. But you must check that (1 + GZOH (z)Kd (z))−1 is stable! 2016-5-24 13.19 Example Plant model: G(s) = 2 5(1 − s/zrhp ) (s2 + 2ζηωm s + η 2 ωm ) 1 2 2 (1 + τ s) (s + 2ζωm s + ωm ) η 2 where τ = 0.5, zrhp = 70, ωm = 20, ζ = 0.05, and η = 1.2. IMC desgn Tideal (s) = 3rd order Butterworth filter with bandwidth: 25 [rad./sec.] Q(s) = Tideal (s)G−1 mp (s) K(s) = (I − Q(s)G(s))−1 Q(s). 2016-5-24 13.20 Loopshapes 100 Magnitude L(jω) 10 G(jω) 1 10 K(jω) 100 1 10 100 log ω (rad/sec) 1 0.1 0.01 0.001 90 log ω (rad/sec) 0 K(jω) −90 L(jω) G(jω) −180 −270 Phase (deg.) 2016-5-24 13.21 Sensitivity and complementary sensitivity 10 Magnitude 2 S(jω) 10 100 1 log ω (rad/sec) T (jω) 0.1 2016-5-24 13.22 Step response Output 1.4 Amplitude 1.2 1.0 0.8 0.6 0.4 y(t) 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.23 Step response Actuation 1.4 Amplitude 1.2 u(t) 1.0 0.8 0.6 0.4 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.24 Bilinear/Trapezoidal/Tustin transform Bilinear transform Nyquist frequency: Kbl (z) = K(s) 100 radians/second =⇒ T = π . 100 2 z−1 s= T z+1 Discrete-time analysis GZOH (z) y(k) G(s) T Kd (z) ZOH + r(k) − 2016-5-24 13.25 Loopshapes: bilinearly transformed controller 100 Magnitude 10 1 1 10 100 Kd (ejω ) 0.1 log ω (rad/sec) G(jω) GZOH (ejω ) 0.01 Ld (ejω ) K(jω) 0.001 L(jω) 90 1 10 100 log ω (rad/sec) 0 −90 G(jω) −180 −270 2016-5-24 Phase (deg.) K(jω) GZOH (ejω ) Ld (ejω ) L(jω) Kd (ejω ) 13.26 Sensitivity and complementary sensitivity: bilinearly transformed controller Magnitude 10 2 S(jω) 1 10 Sd (ejω ) Td (ejω ) 100 log ω (rad/sec) T (jω) 0.1 2016-5-24 13.27 Step response: bilinearly transformed controller Output 1.4 Amplitude y(k) 1.2 1.0 0.8 0.6 y(t) 0.4 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.28 Step response: bilinearly transformed controller Actuation 1.4 Amplitude 1.2 u(t) 1.0 0.8 u(k) 0.6 0.4 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.29 Prewarped Tustin transform Prewarped Tustin transform Nyquist frequency: 100 radians/second =⇒ T = π . 100 Select the prewarping frequency at ωpw = ωm (20 radians/sec.). Kpw (z) = K(s) z−1 s=α z+1 where, α= 2016-5-24 ωpw . tan(ωpw T /2) 13.30 Loopshapes: prewarped Tustin controller 100 Magnitude 10 1 1 10 100 log ω (rad/sec) Kd (ejω ) 0.1 G(jω) GZOH (ejω ) Ld (ejω ) 0.01 K(jω) 0.001 L(jω) 90 1 10 100 log ω (rad/sec) 0 −90 G(jω) −180 −270 Phase (deg.) K(jω) GZOH (ejω ) Ld (ejω ) L(jω) Kd (ejω ) 2016-5-24 13.31 Sensitivity and complementary sensitivity: prewarped Tustin controller 10 Magnitude 2 S(jω) log ω (rad/sec) 1 10 Sd (ejω ) 100 Td (ejω ) T (jω) 0.1 2016-5-24 13.32 Step response: prewarped Tustin controller Output 1.4 Amplitude y(k) 1.2 1.0 0.8 0.6 y(t) 0.4 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.33 Step response: prewarped Tustin controller Actuation 1.4 Amplitude 1.2 u(t) 1.0 0.8 u(k) 0.6 0.4 0.2 time (sec) 0 0.5 1.0 1.5 2.0 −0.2 2016-5-24 13.34 Sample rate selection Sample rate selection is critical to digital control design. Main considerations I Sampling/ZOH will (approximately) introduce a delay of T /2 seconds. I Anti-aliasing filters will need to be designed and these will also introduce phase lag. I The system runs “open-loop” between samples. I Very fast sampling can introduce additional noise. I Very fast sampling makes all of the poles appear close to 1. The controller design can become numerically sensitive. 2016-5-24 13.35 Designing for digital implementation Sampled-data implementation d(t) Gd (s) u(t) y(t) n(t) + G(s) ZOH ym (t) + Fa (s) u(k) r(k) Kd (z) ỹm (t) ỹm (k) T Continuous-time design d(t) Gd (s) n(t) 2016-5-24 r(t) u(t) y(t) + + G(s) ym (t) e−sT /2 Fa (s) K(s) ỹm (t) 13.36 Sensitivity function We want a similar discrete sensitivity function up to the frequency where |S(jω)| returns to 1. 5 Magnitude 1 10 + 1 log ω (rad/sec) ωB − 0.1 S(jω) 0.01 S(s) = (I + Fa (s)G(s)e−sT /2 K(s))−1 2016-5-24 13.37 Sensitivity function In this example, for ω > 20 rad./sec., |1 − S(jω)| 1 5 =⇒ π/T = 20 is about the minimum. Magnitude 10 + 1 − S(jω) 20 ω (rad/sec) ωB 0.1 0.01 S(s) = (I + Fa (s)G(s)e−sT /2 K(s))−1 2016-5-24 13.38 Loop-shaping interpretation For ω up to where |Fa (jω)G(jω)K(jω)| < and remains very small, jωT −jωT /2 jωT . we want Fa (jω)G(jω)K(jω)e ≈ ĜZOH e Kd e (ĜZOH (z) is the ZOH-equivalent of Fa (s)G(s)) imag j |S(jω)| > 1 −1 1 real |1 + L(jω)| L(jω) −j 2016-5-24 13.39 Fast sampling Fast sampling period: Tf . Control appropriate (slower) sampling period: Ts (typically Ts = M Tf for integer M > 1). ỹs (k) Ts Fas (z) Digital Digital downsampling filter 2016-5-24 ỹ(t) Tf Fast sampler Faf (s) y(t) Anti-aliasing filter 13.40