• No results found

The bilinear transform

In document Advanced Control using MATLAB (Page 60-64)

From differential to difference equations

2.5 Discretising with a sample and hold

2.5.2 The bilinear transform

(z - 1)

2.5.2 The bilinear transform

The analytical ‘one step back–one step forward’ procedure while strictly correct, is a little tedious, so a simpler, albeit approximate, way to transform between the Laplace domain and the z-domain is to use the bilinear transform method, sometimes known as Tustin’s method. By definition zdef= esT or z−1= e−sT, (from Eqn.2.10). If we substituted directly natural logs would appear in the rational polynomial in z,

s = ln(z)

T (2.23)

making the subsequent analysis difficult. For example the resulting expression could not be transformed into a difference equation which is what we desire.

We can avoid the troublesome logarithmic terms by using a Pad´e approximation for the expo-nential term as

This allows us to transform a continuous time transfer function G(s) to a discrete time transfer function G(z), Eqn.2.26is called the bilinear transform owing to the linear terms in both the numerator and denominator and it has the advantage that a stable continuous time filter will be stable in the dis-crete domain. The disadvantage is that the algebra required soon becomes unwieldy if attempted manually. Other transforms are possible and are discussed in §4-2 p308 of Ogata [148]. Always remember that this transformation is approximate, being equivalent to a trapezoidal integration.

Here we wish to approximately discretise the continuous plant

G(s) = 1

(s + 1)(s + 2)

at a sample time of T = 0.1 using the bilinear transform. The discrete approximate transfer function is obtained by substituting Eqn.2.25for s and simplifying.

G(z) = 1

Since this transformation is just an algebraic substitution, it is easy to execute it symbolically in MATLAB.

1 >> syms s T z

>> G = 1/(s+1)/(s+2);

>> Gd = simplify(subs(G,s,2/T*(1-1/z)/(1+1/z))) Gd =

1/2*Tˆ2*(z+1)ˆ2/(2*z-2+T*z+T)/(z-1+T*z+T)

6 >> pretty(Gd)

2 2

T (z + 1)

1/2 ---(2 z - 2 + T z + T) (z - 1 + T z + T)

Alternatively we could use MATLABto numerically verify our symbolic solution.

>> G = zpk([],[-1 -2],1) Zero/pole/gain:

1

---5 (s+1) (s+2)

>> T=0.1;

>> Gd = c2d(G,T,'tustin')

10 Zero/pole/gain:

0.0021645 (z+1)ˆ2 ---(z-0.9048) (z-0.8182)

15 Sampling time: 0.1

>> tf(Gd)

Transfer function:

0.002165 zˆ2 + 0.004329 z + 0.002165

20 ---zˆ2 - 1.723 z + 0.7403

Sampling time: 0.1

Thebilinearcommand in the SIGNALPROCESSINGtoolbox automatically performs this map-ping from s to z. This is used for example in the design of discrete versions of common analogue filters such as the Butterworth or Chebyshev filters. These are further described in §5.2.3.

Problem 2.3 1. Use Tustin’s method (approximatez-transform) to determine the discrete time response of

G(s) = 4

(s + 4)(s + 2)

to a unit step change in input by long division. The sample timeT = 1and solve for 7 time steps. Compare with the exact solution.

The frequency response characteristics of a hold element

The zeroth order hold element modifies the transfer function, so consequently influences the closed loop stability, and frequency characteristics of the discrete process. We can investigate this influence by plotting the discrete Bode and Nyquist plots for a sampled process with and without a zeroth order hold.

Suppose we have the continuous process

Gp(s) = 1.57

s(s + 1) (2.27)

which is sampled at a frequency of ω = 4 rad/s. (This corresponds to a sample time of T = π/2 seconds.) First we will ignore the zeroth order hold and transform Eqn2.27to the z domain by using tables such as say Table 2–1, p49 #8 in DCS.

Gp(z) = 1.57 (1− e−aT)z−1

(1− z−1)(1− e−aTz−1) (2.28)

= 1.243z

(z− 1)(z − 0.208) (2.29)

To get the discrete model with the zeroth order hold, we again use Eqn2.18, and the tables. Doing this, in a similar manner to what was done for Eqn2.21, we get

Gh0Gp(z) = 1.2215z + 0.7306

(z− 1)(z − 0.208) (2.30)

Now we can plot the discrete frequency responses using MATLABto duplicate the figure given in [110, p649] as shown in Fig.2.14.

In the listing below, I first construct the symbolic discrete transfer function, substitute the sam-pling time, then convert to a numeric rational polynomial. This rational polynomial is now in a suitable form to be fed to the control toolbox routines such asbode.

syms s T z

2 G = 1.57/(s*(s+1))

Gd = lap2ztran(G) % convert to a z-transform without ZOH Gd2 = subs(Gd,T,pi/2)

[num,den] = numden(Gd2) % extract top & bottom lines

7 B= sym2poly(num); A = sym2poly(den); % convert to polynomials Gd = tf(B,A,pi/2) % construct a transfer function

To generate the discretisation including the zeroth-order hold, we could use the symboliclap2ztranzoh routine given in Listing2.2, or we could use the built-inc2dfunction.

1 [num,den] = numden(G) % extract numerator & denominator Bc= sym2poly(num); Ac = sym2poly(den);

Gc = tf(Bc,Ac)

Gdzoh = c2d(Gc,pi/2,'zoh')

6

bode(Gc,Gd,Gdzoh)

legend('Continuous','No ZOH','with ZOH')

In this case I have used vanilla Bode function which will automatically recognise the difference between discrete and continuous transfer functions. Note that it also automatically selects both a reasonable frequency spacing, and inserts the Nyquist frequency at fN = 1/2T = 1/πHz or ωN = 2 rad/s.

These Bode plots shown in Fig.2.14, or the equivalent Nyquist plots, show that the zeroth order hold destabilises the system. The process with the hold has a larger peak resonance, and smaller gain and phase margins.

−100

−50 0 50 100

Magnitude (dB)

10−2 10−1 100 101 102

−225

−180

−135

−90

Phase (deg)

Bode Diagram

Frequency (rad/sec)

Continuous No ZOH with ZOH

Figure 2.14: The Bode dia-gram showing the difference between the continuous plant, a discretisation with and with-out the zeroth-order hold.

Of course we should compare the discrete Bode diagrams with that for the original continuous process. The MATLABbodefunction is in this instance the right tool for the job, but I will con-struct the plot manually just to demonstrate how trivial it is to substitute s = iω, and compute the magnitude and phase of G(iω) for all frequencies of interest.

num = 1.57; %Plant of interest G(s) = 1.57/(s2+ s + 0)

2 den = [1 1 0];

w = logspace(-2,1)'; %Select frequency range of interest 10−2< ω < 101rad/s.

iw = 1i*w; %s = jω

G = polyval(num,iw)./polyval(den,iw); %G(s = jω) loglog(w,abs(G)) %Plot magnitude|G(iω)|, see Fig.2.15.

7 semilogx(w,angle(G)*180/pi) %and phase φ(iω)

We can compare this frequency response of the continuous system with the discretised version in Fig.2.14.

Figure 2.15: A frequency response plot of G(s) where s = jω constructed manually without using thebodecommand.

10−2 10−1 100 101

10−5 100 105

AR

10−2 10−1 100 101

−200

−150

−100

−50

frequency ω [rad/s]

Phase lag φ [deg]

In document Advanced Control using MATLAB (Page 60-64)