Discret Ization
Discret Ization
Discret Ization
These notes are taken from F.L. Lewis, Applied Optimal Control and Estimation: Digital Design and Implementation, renti!e"#all, $ew %ersey, T& 'eries, Fe(. )**2. DISCRETIZATION OF CONTINUOUS SYSTEMS In this section we shall discuss converting a continuous-time system into a discrete-time system. We shall explicitly include the ZOH required to convert the discrete control samples u k into the plant control input u(t). Sampling The Plant In this subsection we shall show how to convert a continuoustime state-variable description of a plant into a discrete-time state-variable description. Suppose a continuous time-invariant plant is given by . x= Ax + Bu y= Cx + Du ( (
with x(t) Rn, measured output y(t) Rp, and control input u(t) Rm. For digital control purposes it is desired to define a discrete time index k such that t= kT ( input u k by the hold the This may figure..
with T the sampling period. Then, the discrete control is to be switched at times kT, k= 0,1,...,N-1 microprocessor. The usual procedure for controlling the plant is to control input u(t) constant between control switchings. be achieved by adding a ZOH before the plant. See the
Then, the continuous plant input u(t) is given in terms of the discrete control uk by u(t)= uk , kT t< (k+1)T. at the times kT so ( that it is
uk
ZOH hold
u(t)
x(t)
y(t)
yk
sample
u(t)
uk T
t= kT 7 8
0 1
2 3
4 5 6
Sample y(t)
Hold uk
Also shown in the figure is a sampler with period T added to the output channel of the plant. This A/D device generates the samples yk= y(kT) of the output. xk= x(kT) of the state vector. Let us also define the samples ( (
It is now required to determine a dynamical relation between uk and xk such that xk+1= Asxk + Bsuk. (
That is, we need to determine the sampled equivalents As, Bs of A and B. To achieve this, first write the solution of (, which is t x(t)= eA(t-t0)x(t0) + eA(t-)Bu() d. t0 Setting t0= kT and t= (k+1)T yields (k+1)T x((k+1)T)= eATx(kT) + eA[(k+1)T-]Bu() d. kT Since u(t) has the constant value of u k over the sample period due to the ZOH, we may extract it from the integrand. Then, changing variables to = -kT yields T xk+1= eATxk + eA[T-]B d uk. 0 Changing variables again to = T- yields finally T xk+1= eATxk + eAB d uk. 0 By comparison with ( we may now identify the discretized plant matrices as As= eAT + (
Bs=
T eAB d. 0
It is important to notice that the discretized plant matrix A s is always nonsingular. Since the output equation is a nondynamical relation, we may simply write yk= Cxk + Duk. (
That is, the C and D matrices are unchanged on discretization. The design of digital controls proceeds as follows. First, a continuous-time state-variable model of the plant is derived. Then, As and Bs are determined using the above equations. Finally, the techniques to be presented are used to design a discrete control sequence uk. During the implementation phase when the control is actually applied to the plant, u(t) is manufactured by passing uk through a ZOH. Commercial digital signal processors (DSPs) will usually have a ZOH built in. It is important to clearly realize that this approach to digital controls design explicitly includes the effects of the ZOH, since u(t) was assumed constant over the sample period in deriving Bs. Thus, the resulting controller takes into account the properties of the hold and sampling processes, guaranteeing exact behavior at the sample instants. In order to evaluate As, Bs we may use As= eAT= I + AT + 1 A2T2 + 1 A3T3 + ... 2! 3! (
and, by integrating this term-by-term and multiplying by B, Bs= BT + 1 ABT2 + 1 A2BT3 + ... 2! 3! . (
Based on these equations, it is easy to write a computer program to discretize a continuous plant (A,B). The series may be
terminated when the terms become smaller than some desired threshold. For large n, this technique could suffer numerical problems due to the raising of matrix A to large powers. Eulers Approximation The state derivative approximation may be approximated by Eulers forward
so that xk +) = - I + AT . xk + BTuk
xk + ) xk = Axk + Buk T
This is known as the discretized system using Eulers approximation. Note that it can also be obtained using ZOH sampling 2 2 A = e AT = I + AT + ) 2 A T +L and retaining only the first two terms. Also BT is the first term of the exact sampled B matrix above. Eulers method requires the sampling period T to be small, while exact sampling holds for any value of T. Eulers method is not generally accurate enough for controls design purposes. Sampling The Poles The poles of the continuous system are the eigenvalues of A. The poles of the discretized system are the eigenvalues of As= eAT. However, if si are the eigenvalues of A, then for any polynomial function f(.), the eigenvalues of f(A) are given by f(si) [Kailath 1980]. Therefore, if si are the poles of the continuous system ( then the poles zi of the discretized system ( are given by
zi= eRe(si)TejIm(si)T = eRe(si)T(cos[(Im(si)T] + jsin[Im(si)T]), where the second factor has magnitude of one. Therefore, if the continuous system is stable (i.e. has all poles with Re(s i)< 0), then the discretized system has all poles inside the unit circle. That is, stability is preserved by discretization. In fact, the j axis in the s-plane is mapped into the unit circle in the zplane by (, with the left-half plane mapping into the interior of the unit circle. Using Eulers approximation, the continuous-time poles si map into the discrete z-plane according to zi = ) + siT Therefore, stability guaranteed. Computer Simulation If u(t) is given by the ZOH output, then the samples x k= x(kT) are given as above. To determine the values of x(t) between the sample points we could use t x(t)= eA(t-kT)xk + eA(t-)B d uk , kT kT t< (k+1)T. ( of the sampled system cannot always be
However, for our purposes we shall generally design the control sequence uk and then, to verify its performance, carry out a digital simulation, where uk is applied to the continuous plant using a Runge-Kutta integrator. Thus, the intersample values of x(t) will be obtained automatically.
Higher-Order Holds For some applications it may not be desirable for the control input u(t) to switch between discrete values. However, if the plant contains any low-pass characteristics, as is the usual situation, then it will smooth out the jumps in the control. If additional smoothing is required, a low-pass filter may be placed in the plant input channel, and the resulting series configuration can then be sampled. An alternative is to use higher-order hold circuits that convert the discrete control uk into continuous plant input functions u(t). Exercise 7.1-4 gives the discretized system when a first-order hold is used instead of the ZOH. Although it is possible to use D/A devices other than the ZOH for converting the discrete control sequence uk into the continuous plant control u(t), it is usually not worth the trouble. The zero-order hold sampling technique just presented provides an exact discretized equivalent of the continuous-time plant for which discrete controls can be designed. By using the technique of ZOH sampling we are at least guaranteed that the samples of x(t) behave like the discrete state xk, which has desirable behavior because of our selection of uk. The intersample behavior depends on the choice of the sampling period T, which we shall soon discuss. An additional argument against using higher-order hold devices is that most commercial DSPs contain a ZOH. Let us examine ZOH discretization in some examples that frequently appear. Example 7.1-1: Discretization of Scalar System Consider the scalar continuous-time system . x= ax + bu. According to ( and (, the discretized system is given by (1)
T eaTb d uk 0
(eaT - 1) b uk . a
(2)
The pole is at eaT, which is inside the unit circle if a< 0. Example 7.1-2: Discretization of Newton's System A particle obeying Newton's law satisfies . x= 0 0 1x + 0u = Ax + Bu, 0 1
(1)
with state x= [s v]T, where s= position and v= velocity, and u(t) an acceleration input. See Example 2.1-4. Since A is nilpotent (i.e. Aj= 0 for some j), in particular A2= 0, it is extremely convenient to use ( and ( to discretize the system. Indeed, 1 T 0 1 Bs= BT + 1 ABT2 = T2/2 . 2! T As= I + AT = The poles of the discretized system are at the roots of 0= s(z) zI - As = z-1 0 -T = (z-1)2. z-1 This agrees with (. (4)
(2)
(3)
Example 7.1-3: Discretization of Damped Harmonic Oscillator A damped harmonic oscillator is described by . x= 0 -2 1x + 0u, -2 1
(1)
with the natural frequency and the real part of the poles. See Example 2.1-5. Defining the imaginary part of the poles as , we have 2= 2 + 2, and the characteristic polynomial is (s)= s2 + 2s + 2= (s+)2 + 2. The poles are at s= - j. The resolvent matrix is 1 (sI-A)-1= (s+)2 + 2 s+2 1 -2 s , (2)
(3)
whence the inverse Laplace transform delivers cosT + sinT 1 sinT As= eAT= e-T . -2 sinT cosT - sinT Evaluating ( yields 1 1 - e-T(cosT + sinT) 2 . 1 e-TsinT
(4)
Bs=
(5)
The poles of the discretized system are located at the roots of the discrete characteristic polynomial s(z)= zI - As, which is s(z)= z2 - 2e-TcosTz + e-2T = (z - e-TcosT)2 + e-2Tsin2T. (6) (7)
agreeing with (. Note that, if the continuous system is stable so that > 0, then the sampled poles have magnitude less than one.
Sampling the Transfer Function It is a straightforward matter to determine the relation between the transfer functions of the plant and its discretized version including the ZOH. If there is an output y= Cx then, by sampling both sides we obtain yk= Cxk. The continuous and respectively by H(s)= C(sI-A)-1B Hs(z)= C(zI-As)-1Bs, discretized transfer functions ( are defined (
( (
where argument s is the Laplace variable and z the Z-transform variable. The impulse response of the ZOH is L(ZOH)= (1-e-sT) , s (
with L(.) the Laplace transform. Recall that the delay e-sT is represented in terms of Z-transforms as z-1. Therefore, with some abuse in notation we can say L(ZOH)= (1-e-sT) = (1-z-1) . s s (
)0
Let us consider Fig. Error: Reference source not found. transfer function from uk to yk including the ZOH is given by Hs(z)= (1-z-1) ZH(s), s
The
with Z(.) the Z-transform. This equation says that Hs(z)/(1-z-1)= Z(H(s)/s). Since the Z-transform of the discrete unit step is 1/(1-z-1), this means that the discrete step response should equal the samples of the continuous step response. Thus, ZOH sampling is also called discretization by step invariance. The key to finding the discretized transfer function Hs(z) is determining the Z-transform of H(s)/s. This may be achieved using the partial fraction expansion. If the n+1 poles of H(s)/s are distinct, then its PFE is n+1 H(s) = s i=1
Ki s-si
with Ki the residue of the pole at s= si. A term-by-term Ztransform of this is easy to perform, for recall that each term has an inverse Laplace transform of Kiesit. However, this is equal to Ki(esiT)k= Kizik, which has a Z-transform of Ki/(1-ziz-1). Therefore, the sampled transfer function is given by n+1 Hs(z)= (1-z-1) i=1 where zi= esiT. ( Ki 1 - esiTz-1 = (1-z-1) n+1 Ki ,( i=1 1-ziz-1
Evaluation of Hs(z) by using this formula, or by discretization of (A,B) and then application of (, will yield the same result.
))
If H(s)/s has repeated poles the partial-fraction expansion will contain terms like K/(s-si)j. If some of the poles of H(s)/s are complex, then the associated residues Ki in ( will be complex. In this case it is better to keep the complex pole pair in a single term. In either case we should refer to Table 7.1-1 to obtain the Z-transforms of the terms in the partial-fraction expansion of H(s)/s. The relative degree of a scalar transfer function is the degree of the denominator minus the degree of the numerator. It is equivalent to the number of zeros at infinity. It is an interesting fact that, no matter what the relative degree of the continuous-time transfer function, the relative degree of the discretized equivalent Hs(z) is always equal to one, except at some isolated values of the sampling period T. This may be seen by examining (, for on combining the sum over a common denominator, the constant term in the numerator vanishes because H(s)/s has relative degree of two. The numerator term in z -1 is the highest-order term, and its coefficient is a transcendental equation in T. That is, it vanishes only for isolated values of T.
)2
TABLE 7.1-1 Table of Z-Transforms Time Function Laplace Transform Z-Transform u-1(t) t t2 2! e-at te-aT (1-at)e-aT e-Tsint e-Tcost 1 s 1 s2 1 s3 1 s+a 1 (s+a)2 s (s+a)2 (s+)2 + 2 s+ (s+)2 + 2 z z-1 Tz (z-1)2 T2z(z+1) 2(z-1)3 z z-e-aT Tze-aT (z-e-aT)2 z(z - e-aT(1+aT)) (z-e-aT)2 ze-TsinT z - 2e-TcosTz + e-2T
2
)+
Example 7.1-6: Discretization of a Transfer Function Suppose a continuous-time system has the transfer function H(s)= -6(s-1) . (s+2)(s+3) (1)
so that ( yields the sampled transfer function -9 8 1 Hs(z)= (1-z-1) + + . 1 - e-2Tz-1 1 - e-3Tz-1 1 - z-1 Combining over a common factor results in Hs(z)= z-1(1 - 9e-2T + 8e-3T) + z-2(8e-2T - 9e-3T + e-5T) (1 - e-2Tz-1)(1 - e-3Tz-1) (4)
(3)
Several things are worthy of note. First, there is no constant numerator term for precisely the reason that H(s)/s has relative degree of 2. Second, since the Z-transform equivalent of 1/s is 1/(1-z-1), the multiplier (1-z-1) cancels. The reader should convince himself of these facts by working through the example in detail. Multiplying (4) by z2 yields z(1 - 9e-2T + 8e-3T) + (8e-2T - 9e-3T + e-5T) . (5) (z - e-2T)(z - e-3T)
Hs(z)=
This has relative degree of one unless the coefficient of z vanishes. Note that the zero is inside the unit circle and the discretized system is minimum phase.
),
)/
Nonminimum-Phase Zeros Let us discuss an issue that can cause problems in digital control if it is not understood. The poles of the system are well-behaved under discretization, mapping according to zi= esiT. (
This formula shows that if the continuous-time system has poles in the left-half s-plane, then the discretized system has poles inside the unit circle in the z-plane. However, the situation is not so simple for the system zeros. Let us examine the formula for discretization of the transfer function above. The residues Ki depend on the poles and zeros of the continuous-time system. The zeros of H s(z) in turn depend on the residues Ki and the discrete poles esiT. Thus, the zeros of the discretized system depend on the poles and zeros of the continous system as well as the sampling period T. It can be shown that, if the continuous system has a finite zero at s= p i, then the discretized system has a zero at approximately qi epiT. (
Nonminimum-phase systems (i.e. those with unstable zeros) have some fundamental limitations in how well they may be controlled in closed-loop. Unfortunately, even if a continuoustime system has minimum phase, its discretized equivalent can have nonminimum-phase zeros, as we now see. If the continuous system is stable, then the poles of the discretized system are stable. According to (, the stable zeros of H(s) should also be mapped into stable zeros of Hs(z). This should be checked in each case however, since ( is only approximate. The problem enters when the continuous system H(s) has a relative degree r greater than one, and hence more than one system zero at infinity. Since the discretized system H s(z) generally has a relative degree of 1, it follows that some of the infinite zeros in the s-plane will become finite zeros in the z-plane on
)0
sampling. Indeed, r-1 extra zeros will map into the finite plane. It is the locations of these zeros that can be a cause for concern. Due to the relation z= esT, there is a correspondence between small values of the sampling period T and large frequencies s. If H(s) has r infinite zeros, then for large s, we have H(s) b/sr, with b the coefficient of the highest power of s in the numerator of H(s). Thus, according to (, Hs(z) tends to Hs(z)= (1-z-1) Z b . sr+1
Using the formula for conversion of the Laplace transform to the Laplace transform to the Z-transform, there results [Clarke 1981] Hs(z)= b (1-z-1) Dr 1 , r! 1-z-1 where the operator D is defined by D= -Tz d . dz (
The numerators for the first few values of r are tabulated in Table 7.3-1. For r=1 no extra finite zeros are introduced by sampling. If r= 2 and T is small, however, there is a zero at approximately z= -1. If the relative degree of H(s) is r= 3 and T is small, there are zeros at approximately z= -3.73, -1/3.73. The point is that for r greater than 2 there are always unstable zeros in the z-plane for small sampling periods. This should clearly demonstrate the fallacy of believing the all problems in digital control may be solved by decreasing the sampling period. Indeed, when r=3, the zeros of H s(z) are stable for large values of the sampling period T, with one zero moving towards z= -3.73 as T is decreased. In [Fu and Dumont 1989] a Nyquist approach is given for selecting T to ensure minimum-phase behavior in the sampled )1
system. It is shown that if the continuous system has minimum phase and T is larger than a certain value, the sampled system will be of minimum phase. TABLE 7.3-1 Numerators of Hs(z) For Small T Vs. Relative Degree r 1 2 3 4 5 numerator of Hs(z) 1 z + 1 z2 + 4z + 1 z3 + 11z2 + 11z + 1 z4 + 26z3 + 66z2 + 26z + 1
)8