Methods for analysis and of Lecture 6: to digital O. Sename 1 1 Gipsa-lab, CNRS-INPG, FRANCE Olivier.Sename@gipsa-lab.inpg.fr www.lag.ensieg.inpg.fr/sename 6th May 2009
Outline
Some interesting books: K.J. Astrom and B. Wittenmark, Computer-Controlled Systems, Information and sciences series. Prentice Hall, New Jersey, 3rd edition, 1997. R.C. Dorf and R.H. Bishop, Modern Control Systems, Prentice Hall, USA, 2005. G.C. Goodwin, S.F. Graebe, and M.E. Salgado, Control System Design, Prentice Hall, New Jersey, 2001. G. Franklin, J. Powell, A. Emami-Naeini, Feedback Dynamic Systems, Prentice Hall, 2005
Toward digital Digital Usually lers are implemented in a digital computer as: This requires the use of the discrete theory. (Sampling theory + )
Definitions Mathematical definition Because the output of the ideal sampler, x (t), is a series of impulses with values x(kt e ), we have: x (t) = k=0 by using the Laplace transform, L [x (t)] = x(kt e )δ(t kt e ) k=0 x(kt e )e kst e Noting z = e st e, we can derive the so called X(z) = Z [x(k)] = k=0 x(k)z k
Properties Definition Properties X(z) = Z [x(k)] = k=0 x(k)z k Z [αx(k) + βy(k)] = αx(z) + βy (z) Z [x(k n)] = z n Z [x(k)] Z [kx(k)] = z d dz Z [x(k)] Z [x(k) y(k)] = X(z).Y (z) lim x(k) = lim (z 1)X(z) k 1 z 1 The z 1 can be interpreted as a pure delay operator.
Exercise Determine the of the step function (1) and of the ramp function (2) x step (k) = 1 if k 0 x ramp (k) = k if k 0 = 0 if k < 0 = 0 if k < 0
Exercise Determine the of the step function (1) and of the ramp function (2) x step (k) = 1 if k 0 x ramp (k) = k if k 0 = 0 if k < 0 = 0 if k < 0 Solution 1) Step X step (z) = 1 + z 1 + z 2 + = 2) Ramp (note that x ramp (k) = kx step (k)) 1 1 z 1 = z z 1 X ramp (z) = z d ( z ) dz z 1 z = (z 1) 2
Zero order holder Sampler and Zero order holder A sampler is a switch that close every T e seconds. A Zero order holder holds the signal x for T e seconds to get h as: h(t + kt e ) = x(kt e ), 0 t < T e
Zero order holder (cont d) Model of the Zero order holder The transfer function of the zero-order holder is given by: G BOZ (s) = 1 s e st e s = 1 e st e s Influence of the D/A and A/D Note that the precision is also limited by the available precision of the converters (either A/D or D/A). This error is also called the amplitude quantization error.
Representation of the discrete linear The discrete output of a system can be expressed as: y(k) = n=0 h(k n)u(n) hence, applying the Z-transform leads to Y (z) = Z [h(k)]u(z) = H(z)U(z) H(z) = b 0 + b 1 z + + b m z m a 0 + a 1 z + + a n z n where n ( m) is the order of the system Corresponding difference equation: = Y U y(k) = 1 a n [ b0 u(k n) + b 1 u(k n + 1) + + b m u(k n + m) a 0 y(k n) a 2 y(k n + 1) a n 1 y(k 1) ]
Some useful transformations x(t) X(s) X(z) δ(t) 1 1 δ(t kt e ) e kst e z k u(t) 1 s z 1 t s 2 e at s+a 1 1 e at 1 sin(ωt) cos(ωt) z 1 zt e (z 1) 2 z z e at e z(1 e at e ) s(s+a) (z 1)(z e at e ) ω zsin(ωt e ) s 2 +ω 2 z 2 2zcos(ωT e )+1 s z(z cos(ωt e )) s 2 +ω 2 z 2 2zcos(ωT e )+1 Exercise Discretize (sampling time T e ) the system described by the Laplace function (using a Zero order holder): H(s) = Y (s) U(s) = 1 s(s + 1)
Exercise Discretize the system described by the Laplace function (using a Zero order holder): H(s) = Y (s) U(s) = 1 s(s + 1) Adding the Zero order holder leads to: hence G BOZ (s)h(s) = 1 e st e s = 1 e st e s 2 (s + 1) 1 s(s + 1) = (1 e st e ) ( 1 s 2 1 s + 1 s + 1 Z [G BOZ (s)h(s)] = (1 z 1 )Z [ 1 s 2 1 s + 1 ] s + 1 )
Exercise (cont d) Z [G BOZ (s)h(s)] = (1 z 1 )Z [ 1 s 2 1 s + 1 ] s + 1 = (1 z 1 ) [ zt e (z 1) 2 z z 1 + z ] z e T e if T e = 1, we have = (ze T e z + zt e ) + (1 e T e T e e T e ) (z 1)(z e T e ) Z [G BOZ (s)h(s)] = (ze T e z + zt e ) + (1 e T e T e e T e ) (z 1)(z e T e ) = ze 1 + 1 2e 1 (z 1)(z e 1 ) b 1 z + b 0 = z 2 + a 1 z + a 0
Exercise (cont d) Let us return back to sampled-time domain Y (z) U(z) = Y (z) = b 1 z+b 0 z 2 +a 1 z+a 0 b 1 z+b 0 z 2 +a 1 z+a 0 U(z) Y (z)(z 2 + a 1 z + a 0 ) = (b 1 z + b 0 )U(z) y(n + 2) + a 1 y(n + 1) + a 0 y(n) = b 1 u(n + 1) + b 0 u(n) With an unit feedback, the closed loop function is given by: F cl (z) = G(z) 1 + G(z)
Equivalence {s} {z} {s} {z} The equivalence between the Laplace domain and the Z domain is obtained by the following transformation: z = e st e Two poles with a imaginary part witch differs of 2π/T e give the same pole in Z. domain
Approximations Forward difference (Rectangle inferior) s = z 1 T e Backward difference (Rectangle superior) s = z 1 zt e
Approximations (cont d) Trapezoidal difference (Tustin) s = 2 T e z 1 z + 1
Systems definition A state space system is as follows: { x((k + 1)h) = Ad x(kh) + B d u(kh), x(0) = x 0 y(kh) = C d x(kh) + D d u(kh) where h is the sampling period. Matlab : ss(a d,b d,c d,d d,h) creates a SS object SYS representing a state-space model (1)
Relation with transfer function For, { x((k + 1)h) = Ad x(kh) + B d u(kh), x(0) = x 0 y(kh) = C d x(kh) + D d u(kh) the discrete transfer function is given by (2) G(z) = C d (zi n A d ) 1 B d + D d (3) where z is the shift operator, i.e. zx(kh) = x((k + 1)h)
Recall Laplace & Z-transform From Transfer Function to State Space H(s) to state space X U = den(s) Y X = num(s) Ẋ = AX + BU Y = CX + DU H(z) to state space X U = den(z) Y X = num(z) X k+1 = FX k + GU k Y k = CX k + DU k Y (s) = [ C[sI A] 1 B + D ] U(s) Y (z) = [ C[zI F] 1 G + D ] U(z) }{{}}{{} H(s) H(z)
About sampling period and time response Influence of the sampling period on the time response Impose a maximal time response to a discrete system is equivalent to place the poles inside a circle defined by the upper bound of the bound given by this time response. The more the poles are close to zero, the more the system is fast.
Frequency analysis As in the continuous time, the Bode diagram can also be used. Example with sampling Time T e = 1s w e = 2π): Note that, in our case, the Bode is cut at the pulse w = π. see SYSD = c2d(sysc,ts,method) in MATLAB.
Frequency analysis As in the continuous time, the Bode diagram can also be used. Example with sampling Time T e = 1s w e = 2π): Note that, in our case, the Bode is cut at the pulse w = π. see SYSD = c2d(sysc,ts,method) in MATLAB. Sampling Limitations Recall the Shannon theorem that impose the sampling frequency at least 2 times higher that the system maximum frequency. Related to the anti-aliasing filter...
About sampling period and robustness Influence of the sampling period on the poles In theory, smaller the sampling period T e is, closer the discrete system is from the continuous one. But reducing the sampling time modify poles location... Poles and zeros become closer to the limit of the unit circle can introduce instability (decrease robustness). Sampling influences stability and robustness Over sampling increase noise sensitivity
Zeros Influence of the sampling period on the poles A discrete system with one or few zeros at the origin is faster than one with no origin zeros. In the time domain a zero at the origin induces a sample advance.
Recall A linear continuous feedback system is stable if all poles of the closed-loop transfer function T (s) lie in the left half s-plane. The Z-plane is related to the S-plane by z = e st e = e (σ+jω)t e. Hence z = e σt e and z = ωt e
(cont d) Jury criteria The denominator polynomial (den(z) = a 0 z n + a 1 z n 1 + + a n = 0) has all its roots inside the unit circle if all the first coefficients of the odd row are positive. a n b 1 a 0 a 1 a 2... a n k... a 0 = a 0 a n n a 0 2 a n a n 1 a n 2... a k... a 0 a n b 3 b 0 b 1 b 2... b 1 = a 1 a n 1 n 1 2 b n 1 b n 2 b n 3... b 0.. 2n + 1 s 0 b k = a k a n k a n a 0 a 0 c k = b k b n 1 k b n 1 b 0
Example Find the stability region of D(z) = z 2 + a 1 z + a 2
Example Find the stability region of D(z) = z 2 + a 1 z + a 2 Solution 1 1 > 0 a 1 a 2 2 a 2 a 1 1 3 1 a2 2 > 0? a 1 a 1 a 2 4 a 1 a 1 a 2 1 a2 2 > 0? 5 (1 a2 2 )2 (a 2 1 (1 a 2) 2 ) 1 a 2 2 hence, 1 a 2 2 > 0 (1 + a 2 ) 2 > a 2 1
How to get a discrete ler First way Obtain a plant model (by discretization) Design a ler Derive the difference equation Second way Design a continuous-time ler Converse the continuous-time ler to discrete time (c2d) Derive the difference equation Now the question is how to implement the computed ler on a real-time (embedded) system, and what are the precautions to take before?
Anti-aliasing & Sampling Anti-aliasing Practically it is smart to use a constant high sampling frequency with an analog filter matching this frequency. Then, after the A/D converter, the signal is down-sampled to the frequency used by the ler. Remember that the pre-filter introduce phase shift. Sampling frequency choice The sampling time for are based on the desired speed of the closed loop system. A rule of thumb is that one should sample 4 10 times per rise time T r of the closed loop system. N sample = T r T e 4 10 where T e is the sampling period, and N sample the number of samples.
Delay Problematic Sampled theory assume presence of clock that synchronizes all measurements and signal. Hence in a computer based there always is delays ( delay, computational delay, I/O latency). Origins There are several reasons for delay apparition Execution time (code) Preemption from higher order process Interrupt Communication delay Data dependencies Hence the delay is not constant. The delay introduce a phase shift Instability!
Delay (cont d) Admissible delay (Bode) Measure the phase margin: PM = 180 + ϕ w0 [], where ϕ w0 is the phase at the crossover frequency w 0, i.e. G(jw 0 ) = 1 Then the delay margin is DM = PMπ 180w 0 [s]
: some key issues Analysis of allows to account for implementation constraints (network-induced delays, CPU resource availability, coding,...) Digital vs Continuous : how to choose the ad hoc method? Design method can be systematic whatever the framework is.