Transcript Chapter 5
Chapter 5 On-Line Computer Control – The z Transform Analysis of Discrete-Time Systems 1. The sampling process 2. z-transform 3. Properties of z-transforms 4. Analysis of open-loop and closed-loop discrete time systems 5. Design of discrete-time controllers y Continuous signal Disontinuous y* signal y* y 9 1 3 5 7 9 11 1 t (sec) 3 6 t (sec) T = 1 sec y* (a) (b) 9 6 3 12 t (sec) T = 3 sec y* (c) Continuous signal and its discrete-time representation with different sampling rates y* Dt t = nT (a) t Dt t = nT y* t (b) Impulse area nT t = nT 12 t (c) From the response of a real sampler to the response of an ideal impulse sample The Sampling Process Impulse Sampler y (t) y* y* t y(0) (t) y(T) (t - T) .... y(nT) (t - nT) ... y(nT) (t - nT) n 0 1. 2. At sampling times, strength of impulse is equal to value of input signal. Between sampling times, it is zero. Laplacing y (s) y(nT) L[ (t - nT)] * n 0 or y (s) y(nT) e -nTs * n 0 The Hold Process : From Discrete to Continuous Time discrete impulses m* (t) Zero – Order Hold : m(t) m* (t) m (t) Hold Device Continuous output for nT t (n 1)T Transfer Function : Response of an impulse input : (t) 1 t m* (t) m (t) t -Ts 1 e 1 H(s) 1 - e -Ts s s s T First Order Hold m(nT) - m[(n - 1)T] (t - nT) T nT t (n 1)T n 2,3,4....etc m(t) m(nT) Response to an impulse input 2 1 T 2T 1 -1 Transfer function: 1 sT 1 - e -sT H(S) T s 2 First Order versus Zero Order Hold m* (nT) m (t) m (t) 0 1T 3T 5T 7T t 0 1T 3T 5T (a) 7T t (b) 0 1T 3T 5T 7T t (c) Comparison of reconstruction with zero-order and first-order holds, for slowly varying signals. m* (nT) m (t) m (t) 0 2T 4T 6T 8T 10T t 0 2T 4T 6T 8T (a) (b) 0 2T 4T 6T 8T 10T t (c) Comparison of reconstruction with zero-order and first-order holds, for rapidly changing signals. 10T t Z-Transforms Sample y(t) yz(t) y ( s ) y (n )e nTs z n 0 Let z eTs y ( s ) y ( n ) z n z n 0 y( z ) Ζ y (t ) y(z) z y(n )z -n n 0 Remarks 1. z-transform depends only on the discrete values y(0), y()ז,y()ז..etc. If two continuous functions have the same sampled values , then z-transform will be the same. 2. It is assumed that the summation exists and is finit. 3. We can also view t in the form Z[ y (s) ] = ŷ(z) Z-Transforms of Basic Functions 1. Unit Step Function Z[u(t)] 1 1 z 1 1 z 2 1 z 3 ...... 1 z 1 z 1 z-1 2. Exponential Function e Ze -at anT z n 0 n λ n , λ e -aT z 1 n 0 1 1 λ 1 -aT 1 1-e z z z-e -aT e -aT z 1 1 for convergence Z-Transforms of Basic Functions Continued 3. Ramp Function Z at S 0 aT(z 1 ) 2(aT)z 2 3(aT)z 3 ... z 1S 1 aTz 2 2(aT)z 3 1 (1 z ) S 0 aT(z ) (aT)z 2 aTz 1 (aT)z ... 1 z 1 4. Trigonometric Functions zsinwT Zsinwt 2 z 2zcoswT 1 z 2 zcoswT Zcoswt 2 z 2zcoswT 1 3 Z-Transforms of Basic Functions Continued 5. Translation Z f(t - kT) Z e kTs f ( s ) f (z)z k Z f(t - kT) f(nT kT)z n let n 0 n - k,assume f( τ) 0 for f( τ)z k n k f( τ)z - z k 0 f (z) z k 0 Z-transform for Numerical Derivative z f(t - T) f (z)z 1 z-1 is like a back shift operator dy ynt yn 1 dt T 1 y n y n 1 1 z Z y(z) T T Properties of z-Transforms 1. Linearity Z a f a f a f (z) a f (z) 1 1 2 2 1 2 1 2 2. Final Value Theorem lim y(t) lim (1-z )yˆ (z) t z 1 -1 Proof: (1-z )fˆ y(z)(1 z ) y(nT ) z n y(nT ) z n y(nT ) z n 1 n0 n0 n0 -1 -1 lim y( 0 )-y( 0 )z -1 y(T )-y(T)z-1 z1 y( 2T)-y( 2T)z -1 z 2.... y(nT) n As z1 lim (1 z1 )yˆ (z) lim y nT lim y(t) z 1 n t Numerical Integration in z-transform t nT y(t) f t dt 0 nT y nT y (n-1 )T f(t)dt (n-1 )T Using Trapezoidal Rule f(nT ) f n-1T T y (n 1 )T 2 yˆ (z) yˆ (z) z 1 T fˆ(z) z 1 fˆ(z) 2 or solving yˆ z T 1 z fˆ z 2 1 z 1 1 Inversion of z-transforms 1.Partial fraction expansion cn Q( z 1 ) c1 c2 yˆ ( z ) ... P( z 1 ) 1 ( z 1 ) 2 ( z 1 ) n ( z 1 ) λ1, λ2,… λn are low-order polynomials in z-1 compute c1,c2,…cn. Invert each part separately, we able z z 1 yˆ ( z ) 2 z 4 z 3 1 4 z 1 3 z 2 z 1 c1 c2 (1 z 1 )(1 3 z 1 ) 1 z 1 1 3 z 1 z 1 c1 1 3 z 1 z 1 1 1 2 z 1 1 c1 1 1 z 1 z 1 3 2 1 2 12 yˆ ( z ) 1 z 1 1 3 z 1 From Tables of z-transforms y(nT) = -1/2 + 1/2 e11n y:0,1,4,13,0,… z 1 yˆ ( z ) 1 4 z 1 3z 2 2.Inversion by Long-Division 1-4z-1+3z-2 y(0) = 0 y(T) = 1 y(2T) = 4 y(3T) = 13 1z-1+4z-2+13z-3 z-1 z-1-4z-2+3z-3 4z-2+3z-3 4z-2-16z-3+12z-4 13z-3-12z-4 z-transforms of various functions Function in time domain unit impluse Lalpace transform 1 unit step 1/s ramp: f(t) = at a/s2 f(t) = tn n!/sn+1 f(t) = e-at 1/s+a f(t) =te-at 1/(s+a)2 z-transform 1 1 1 z 1 aTz 1 (1 z 1 ) 2 n 1 (1) lim a n 1 e aT z 1 a 0 1 1 e aT z 1 e aT z 1 (1 e aT z 1 ) 2 n z-transforms of various functions Function in time domain f(t) = sinωt f(t) = cosωt f(t) = 1-e-at f(t) = e-at sinωt f(t) = e-at cosωt Lalpace transform s2 2 s s2 2 a s(s a) (s a)2 2 sa (s a)2 2 z-transform z 1 sin T 1 2 z 1 cos T z 2 1 z cos T 1 2 z 1 cos T z 2 (1 e aT ) z (1 z 1 )(1 e aT z ) z e aT sin T 1 2 z 1e aT cos T e 2 aT z 2 1 z 1e aT cos T 1 2 z 1e aT cos T e 2 aT z 2 Discrete-Time Response of systems In computer control: measurements are taken periodically and control actions implemented periodically, This results in a discrete input/discrete output dynamic system. cn en Discrete System Example of Discrete Systems Let dc ken c dt a discrete time approximation is T cn cn 1 ken cn T cn (1 T T cn 1 kcn cn ) cn T cn 1 ken Taking z-transform (1 ) cˆ( z ) z 1 cˆ( z ) keˆ( z ) T T cˆ( z ) k or e( z ) (1 ) z 1 T T Z-transform for a given continuous system with transfer function G(s) and a ZOH 1 e Ts Z H ( s )G ( s ) Z G (s) s G s Ts G s Z Z e s s G s 1 G s Z z Z s s G s 1 z Z s 1 Example: Pure Integrator with Hold c*(s) 1 e ST s Kp s 1 e Ts K p HG p ( s ) s s Kp K p e Ts 1 e Ts K p Z HG ( s ) Z [ . ] Z[ 2 ] Z[ 2 ] s s s s 1 Kp K pTz K pT z 1 -1 1 [1 - z ] Z [ 2 ] [1 z ] s (1 z 1 ) 2 (1 z 1 ) Step response Hence of c( s ) 1 s cˆ( z ) 1 1 z 1 K p z 1 yˆ ( z ) K p z 1 1 (1 z 1 ) (1 z 1 ) (1 z 1 ) 2 which impulse a ramp response y*(s) Example:First order lag system 1 e ST K p H ( s )G p ( s ) ps 1 s Kp 1 e ST ] Z [ HG ( s )] Z [ s ( p s 1) s Kp 1 [1 z ]Z [ s ( p s 1) ] 1 1 ] K p [1 z 1 ]Z [ s s 1 p K p [1 z 1 ][ T 1 1 ] T p 1 1 1 z z 1 e (1 e p ) z 1 Kp T 1 e p z 1 Step Response for 1st order lag system From tables, for c( s ) yˆ (z) 1 s cˆ( z ) K p (1 e p 1 1 z 1 ) z 1 (1 z 1 )(1 e p z 1 ) Kp Kp 1 (1 z ) (1 e p z 1 ) y (nT ) K p [1 e nT p y (t ) K p to t y(t) * * * * * * * * * * ] * * time Note: Compare with discrete approximation to First-order system Generalization cn a 0en a1en 1 ... aken k b1cn 1 b 2cn 2 ... bmcn m cˆ( z ) a 0eˆ( z ) a1 z 1eˆ( z ) ... ak eˆ( z ) z k b1cˆ( z ) z 1 b2 cˆ( z ) z 2 ... bm cˆ( z ) z m or cˆ( z ) a0 a1 z 1 a2 z 2 ... ak z k D( z ) 1 2 m eˆ( z ) 1 b1 z b2 z ... bm z D (z)=Transfer function relating e and c Analogous to Laplace transfer Discrete time input/output model Remark: Note that D(z) is the z-transform of the response of the system to an impulse input eˆ( z ) 1 Z-transform of a continuous process with Sample and Hold Hold H (s) discrete input Process Gp (s) c*(s) y (s) continuous variables y*(s) discrete output we seek a relationship (Z-transfer function) between c and y. Consider a impulse input Then y ( s ) H ( s )Gp ( s )c ( s ) c*(z)=1 c*(s)=1 H ( s )Gp ( s ) yˆ ( z ) Z y s Z [ H s Gp ( s )] HGP ( z ) HGp(z) called the pulse transfer function (since it represents the z-transform of the pulse response of Gp (s) ) Properties of pulse Transfer Function 1. Z G1 (s)G2 (s) Z G1 (s) Z G2 (s) 2.An impulse input is converted into a pulse input by the first order hold element . Hence HG(z) is the pulse response of G(s) sampled at z internals of T. 3.The pulse transfer function of two systems in series can be combined if there is a sample and hold in between. c2 c1 T c3 ( z ) G3 ( z ) c1 ( z ) G1(z) G2(z) c2 ( z ) G1 ( z ) c1 ( z ) c3 c3 ( z ) G2 ( z ) c 2( z ) Closed-Loop System disturbance T set point eˆ ( z ) + D (z) ysp (z) - ˆ ( z) y Hold T Process H (s) Gp (s) m (s) ˆ( z ) c y2 ( s ) y(2) y1(s) sampled output yˆ ( z ) Z y ( s ) Z y1 ( s ) y2 ( s ) Z y1 ( s ) Z y2 ( s ) HG p ( z )eˆ( z ) yˆ 2 ( z ) HG p ( z ) D ( z )eˆ( z ) yˆ 2 ( z ) HG p ( z ) D ( z ) y sp ( z ) yˆ ( z ) yˆ 2 ( z ) or yˆ ( z ) HG p ( z ) D ( z ) y sp ( z ) 1 HG p ( z ) D( z ) yˆ 2 ( z ) 1 HG p ( z ) D ( z ) 1. Roots of the Characteristic equation 1+HGp(z)D(z)=0 Determine stability of the closed-loop system 2. Note similarity to continuous system. Example: closed-loop response of a first-order system G p (s) kp pS 1 HG p ( z ) k p (1 e T / p ) z 1 1 e T / p z 1 For proportional control D( z ) kc T / p (1 e ) z 1 ˆ sp ( z ) kp kc y T / p 1 1 e z ˆ ( z) y T / p (1 e ) z 1 1 k p kc T / p 1 1 e z k p k c (1 b) z 1 ˆ sp ( z ) y 1 1 k p k c b 1 k p k c z where be T / p For a unit step change in set point and yˆ ( z ) k p k c (1 b) z 1 1 [ k p k c b(1 k p k c )] z y ( nT ) p ˆ sp ( z ) y k p kc 1 k p kc p 1 k p kc 1 e nT / p 1 1 z 1 1 1 (1 z 1 ) The response is very similar to continuous control. The steady state value of y(t) is y Kc K p 1 K p Kc Hence the offset is Kc K p 1 offset 1 1 Kc K p 1 K p Kc Stability of Discrete Systems A system is consider to be stable if output remains bounded for bounded Inputs. Consider a discrete system with transfer function a0 a1 z 1 am z m D(z) 1 n 1 b z b z 1 n e (z) cn c1 c2 1 1 1 P1 z 1 P2 z 1 Pn z 1 c (z) Where P1,P2,…,Pn are n roots of: 1 b1 z -1 b2 z -2 ..... bn z -n 0 For an impulse imput e(z) 1 and C(z) D(z) consider t he k th term Ck f K (z) 1 1 - PK z f k (nT) C K e nlnPK Let PK α jβ | PK | e jw ln Pk ln(P K ) jw e lnPK e ln(PK ) e jw e nlnPK e nln(PK ) e njw The second term is always bounded between(-1 and 1) IF | PK | 1 then ln | PK | 0 and e nln|PK | 0 as n | PK | 1 then ln | PK | 0 and e nln|PK | 1 | PK | 1 then ln | PK | 0 and e nlnPK as n Hence : if PK lies within th e unit - circle on the complex plane, PK will remain bounded. " A discrete system is stable if all its poles lies inside or on the unit circle in the complex plane" Im Unstable roots real STABLE REGION Unit circle Location of poles Consider t he impule response of a system with 1 D(z) 1 - P1 z 1 1 2 -2 -1 y(z) 1 P z P .... 1 1 z 1 1 - P1 z y(1) P1 y(nT) P1 if na | P1 | 1, y(t) as t 0 Pi 1 then y(t) 0 : exponentia l decay - 1 P1 0 then y(t) 0 : oscillator y Example: Stability of closed-loop Proporhona l control of First - order Process characteri stic equation 1 [K P K C - b(1 K P K C )]z -1 0 P1 (1 K P K C )b - K P K C (1 K P K C )e e -T τP -T τP K P K C [e -T τP - KPKC 1] Example: Stability of closedloop - Continued p1 will cross the unti circle where -T τP -T τP 1 e - K P K C [1 - e ] -T τP -T τP or( 1 - e ) - K P K C [1 - e ] or since e -T τP 1 K P K C -1 or K P K C 1 e -T τP -T τP 1- e note that instabity may be caused by high values of K C or high values of T Digital Feedback - Control 1.Digital Apperoximation of classical controllers Displacement form t 1 de C(t) K C [e(t) e(t)dt τ 0 ] Cs τt 0 dt τ T (e k ) D (e n -e n-1 )] Cs T k 0 τ I n C n K C [e n Alternative form : Velocity form n 1 τ T e k D (e n-1 -e n-2 )] Cs T k 0 τ I C n-1 K C [e n-1 ΔC n K C [1 2τ τ T τD ]e n -K C [1 D ]e n-1 K C D e n-2 τI T T T D(z) Δ τ(z) e (z) K C [(1 2τ τ T τD )-(1 D )z -1 D z -2 ] τI T T T 1. 2. 3. No initialization is necessary. [ Cs is not needed ] Bumpless transfer from manual / automatic Automatic ‘reset-windup’ protection. Protection in case of computer failure Disadvantages: 1. 2. Advantages of velocity Form Since different modes are indistinguishable, on-line tuning methods will not work. Difficult to put constraints on integral and / or derivative term. Tuning Digital Controllers: 1. 2. 3. Ziegler – Nichols Cohen – Coon settings Time - integral performance criteria 2.Deadbeat or Minimal Prototype controller This control - law is designed such that the output(sam pled values) no error at the frist sampling following a set point change : we have HG(z)D(z) y sp (z) y(z) 1 HG(z)D(z) 1 step - change y sp Let -1 1- z we want z -1 y( z ) 1 - z -1 solving for D(z) : z -1 Y(t) 1 D(z) HG(z) 1 - z -1 Possible responses : ex.y(t) goes to 1 after one sampling actual ideal time Derivation of Deadbeat Controller- Continued HG(z)D(z) y (z) ysp (z) 1 HG(z)D(z) 1 z 1 ysp z ; yˆ z 1 1 z 1 z 1 yˆ ( z ) z 1 HG(z)D(z) ysp z 1 1 HG(z)D(z) z -1 HG(z)D(z) -1 1-z 1 z -1 1 D z -1 1-z HG(z) Deadbeat Deadbeat 0~10 sec Deadbeat control for (1/(s+1)3) DZ 1 Z 1 Z 3 0.406Z 2 0.05495Z 0.002479 Z 1 HG ( Z ) 1 Z 1 0.3233Z 2 0.3073Z 0.01584 1 Z 1 1 0.406Z 1 0.05495Z 2 0.002479Z 3 0.3233 0.016Z 1 0.2915Z 2 0.01584Z 3 Sampling time: 2 Ringing and Pole-placement Ringing refers to excessive value movement caused by a widely oscillating controller output. Caused by negative poles in D(z). Hence avoid poles near -1. Change controller design such that poles are on the side or near zero on negative side SYS = TF(1,[1 3 3 1]) Transfer function: 1 --------------------s^3 + 3 s^2 + 3 s + 1 >> sysd=c2d(SYS,2) Transfer function: 0.3233 z^2 + 0.3073 z + 0.01584 -------------------------------------z^3 - 0.406 z^2 + 0.05495 z - 0.002479 Sampling time: 2 0.3233 0.6306 0.3231 >> p1=[1 -1];p2=[0.3233 0.3073 0.01584] p2 = 0.3233 0.3073 >> c=conv(p1,p2) c= 0.0158 0.0158 0.3233 -0.0160 -0.2915 -0.0158 Canceling the ringing pole at z=-0.8958 ans = 1.0000 -0.8958 -0.0547 >> p1=[1 0];p2=[1 -0.99];p3=[1 0.0547]; >> c=conv(p1,p2) c= 1.0000 -0.9900 >> c=conv(c,p3) c= 0 1.0000 -0.9353 -0.0542 0 Warning: Using a default value of 1 for maximum step size. The simulation step size will be limited to be less than this value. >> Smoothing the Control Action p=[0.3233 -0.016 -0.2915 -0.01584]; r=roots(p) r= 1.0001 -0.8959 -0.0547 Delete the unstable pole z=-0.8959 p1=[1 -0.99]; p2=[1 0.0547]; c=conv(p1,p2) c= 1.0000 -0.9353 -0.0542 Reconstruct the Control Loop Scope1 Step Subtract num(z) 1 den(z) den(s) Discrete Transfer Fcn Zero-Order Hold Transfer Fcn Scope 1.4 1.2 1 0.8 0.6 0.4 0.2 0 0 5 10 15 20 25 30 35 40 45 50 The treatment of unstable poles sysd=c2d(SYS,1) Transfer function: 0.0803 z^2 + 0.1544 z + 0.01788 ----------------------------------z^3 - 1.104 z^2 + 0.406 z - 0.04979 >> p2=[ 0.0803 0.1544 0.01788] p2 = 0.0803 0.1544 >> p1=[1 -1] p1 = 1 -1 >> c=conv(p1,p2) c= 0.0179 0.0803 0.0741 -0.1365 -0.0179 The treatment of unstable poles >> roots(c) ans = -1.7990 1.0000 -0.1238 1 0.9 0.8 0.7 >> p1=[1 0];p2=[1 -0.99];p3=[1 0.1238]; >> c=conv(p1,p2) c= 0.6 0.5 0.4 0.3 1.0000 -0.9900 0 0.2 0.1 >> c=conv(c,p3) 0 c= 1.0000 -0.8662 -0.1226 0 0 5 10 15 20 25 30 35 40 45 50 3.Dahlin’s Method Require that the closed–loop system behave like a first-order system with dead-time. e- S 1 y(S) S 1 S we want for Solving for D (step response) -T/ -1 (1 e )z ŷ(z) z -k (1 - z -1 )(1 - e-T/ z -1 ) 1 ŷ sp (z) 1 - z -1 1 (1 - e-T/ )z -k -1 D(z) HG(z) 1 - e-T/ z -1 - (1 - e-T/ )z -k -1 1. Choose , such that D(z) is realizable 2. Lot of algebra Dahlin’s Method Dahlin’s Method 0~10sec 0~50 sec Dahlin’s Method for for (1/(s+1)3) 1 DZ HG ( Z ) (1 e 1 e T ) Z k 1 T Z 1 (1 e T ) Z k 1 Z 3 0.406Z 2 0.05495Z 0.002479 0.3233Z 2 0.3073Z 0.01584 0.6321Z 1 0.2566Z 2 0.03474Z 3 0.001567 Z 4 0.3233 0.1884Z 1 0.3016Z 2 0.2001Z 3 0.01001Z 4 Sampling time: 2 (1 e 1 e T ) Z k 1 T Z 1 (1 e T ) Z k 1 Regulatory Control Consider a process described by yn = a1yn-1 + a2yn-2 + … + b1mn-1 + … + bk mn-k In regulatory control, we want to keep y close to zero in presence of disturbances. Ideally choose mn such that yn ≡ ysp ysp = a1yn + a2yn-2 + … + bkyn-k+1 + b1 mn + b2mn-1 + bkmn-k+1 Or mn = -1/b1 [ ysp – a1yn – a yn-1 - akyn-k+1 – b2mn-1 + … - bkmn-k+1 ] Remark 1. Problems can arise in practice if model parameters are not known 2. The above choice is equivalent to minimizing 3. If dead-time is present control will be unrealizable 1 N P (y n - y sp ) 2 N n 0