Design of Butterworth Low-Pass Discrete Filters

Một phần của tài liệu Signals and systems using matlab (Trang 675 - 683)

CHAPTER 11 Introduction to the Design of Discrete Filters

11.4.2 Design of Butterworth Low-Pass Discrete Filters

Our aim in this section is to show how to design discrete low-pass filters based on the analog Butterworth low-pass filter design using the bilinear transformation as a frequency transformation.

Applying the warping relation between the continuous and the discrete frequencies

=Ktan(ω/2) (11.25)

to the magnitude-squared function of the Butterworth low-pass analog filter

HN(0)

2= 1

1+(0)2N 0= 

hp gives the magnitude-squared function for the Butterworth low-pass discrete filter:

|HN(ejω)|2= 1 1+

h tan(0.5ω) tan(0.5ωhp)

i2N (11.26)

As a frequency transformation (no change to the loss specifications) we directly obtain the minimal orderN and the half-power frequency bounds by replacing

s

p = tan(ωs/2)

tan(ωp/2) (11.27)

in the corresponding formulas forNandhpof the analog filter, giving

N≥log10[(100.1αmin−1)/(100.1αmax−1)]

2 log10htan(ω

s/2) tan(ωp/2) i

2 tan−1

tan(ωp/2) (100.1αmax−1)1/2N

≤ωhp≤2 tan−1

tan(ωs/2) (100.1αmin−1)1/2N

(11.28)

The normalized half-power frequency0hp=1in the continuous domain is mapped into the discrete half- power frequencyωhp, giving the constant in the bilinear transformation

Kb= 0 tan(0.5ω)

0=1,ω=ωhp = 1

tan(0.5ωhp) (11.29)

The bilinear transformation s=Kb(1−z−1)/(1+z−1) is then used to convert the analog filter HN(s), satisfying the transformed specifications, into the desired discrete filter,

HN(z)=HN(s)

s=Kb(1−z−1)/(1+z−1)

The basic idea of this design is to convert an analog frequency-normalized Butterworth magnitude- squared function into a discrete function using the relationship in Equation (11.25). To understand

11.4 IIR Filter Design 659

why this is an efficient approach consider the following issues that derive from the application of the bilinear transformation to the Butterworth design:

n Since the discrete magnitude specifications are not changed by the bilinear transformation, we only need to change the analog frequency term in the formulas obtained before for the Butterworth low-pass analog filter.

n It is important to recognize that when finding the minimal orderNand the half-power relation the value ofKis not used. This constant is only important in the final step where the analog filter is transformed into the discrete filter using the bilinear transformation.

n When considering that K=2/Ts depends on Ts, one might think that a small value for Ts improves the design, but that is not the case. Given that the analog frequency is related to the discrete frequency as

= 2 Tstanω

2

(11.30)

for a given value ofω if we choose a small value of Ts the specified analog frequency would increase, and if we choose a large value ofTs the analog frequency would decrease. In fact, in the above equation we can only choose eitherorTs. To avoid this ambiguity, we ignore the connection ofKwithTsand concentrate onK.

n An appropriate value forK for the Butterworth design is obtained by connecting the normalized half-power frequency0hp=1 in the analog domain with the corresponding frequencyωhp in the discrete-domain. This allows us to go from the discrete-domain specificationsdirectlyto the analog normalized frequency specifications. Thus, we map the normalized half-power frequency

0hp=1 into the discrete half-power frequencyωhp, by means ofKb.

n Once the analog filter HN(s) is obtained, using the bilinear transformation with the Kb we transformHN(s)into a discrete filter

HN(z)=HN(s) s=Kbz−1z+1

n The filter parameters(Nhp)can also be obtained directly from the discrete loss function α(ejω)=10 logh

1+(tan(0.5ω)/tan(0.5ωhp))2Ni

(11.31) and the loss specifications

0≤α(ejω)≤αmax 0≤ω≤ωp

α(ejω)≥αmin ω≥ωst

just as we did in the continuous case. The results coincide with those where we replace the warping frequency relation.

nExample 11.6

The analog signal

x(t)=cos(40πt)+cos(500πt)

is sampled using the Nyquist frequency and processed with a discrete filterH(z)that is obtained from a second-order, high-pass analog filter

H(s)= s2 s2+√

2s+1

The discrete-time outputy[n] is then converted into analog. Apply MATLAB’sbilinearfunction to obtain the discrete filter with half-power frequencies ωhp=π/2. Use MATLAB to plot the poles and the zeros of the discrete filter in the z-plane and the corresponding magnitude and phase responses. Use the functionplotto plot the sampled input and the filter output and consider these approximations to the analog signals. Change the frequency scale of the discrete filter intof in hertz and indicate what is the corresponding half-power frequency in hertz.

Solution

The coefficients of the numerator and denominator of the discrete filter are found fromH(s)using the MATLAB functionbilinear. The input Fs in this function equalsKb/2 whereKb corresponds to the transformation of the discrete half-power frequencyωhpinto the normalized analog half-power frequencyhp=1. The following script is used.

%%%%%%%%%%%%%%%

% Example 11.6

%%%%%%%%%%%%%%%

b = [1 0 0]; a = [1 sqrt(2) 1]; % coefficients of analog filter whp = 0.5∗pi; % desired half-power frequency of discrete filter

Kb = 1/tan(whp/2); Fs = Kb/2; [num, den]=bilinear(b,a,Fs); % bilinear transformation Ts = 1/500; % sampling period

n = 0:499; x1 = cos(2∗pi∗20∗n∗Ts)+cos(2∗pi∗250∗n∗Ts); % sampled signal zplane(num, den) % poles/zeros of discrete filter

[H,w] = freqz(num,den); % frequency response of discrete filter phi = unwrap(angle(H)); % unwrapped phase of discrete filter y = filter(num,den,x1); % output of discrete filter with input x1

We find the transfer function of the discrete filter to be H(z)= 0.2929(1−z−1)2

1+0.1715z−2

The poles and the zeros ofH(z)can be found with the MATLAB functionrootsand plotted with zplane. The frequency response is obtained usingfreqz. To have the frequency scale in hertz we consider thatω=Ts, letting=2πf, then

f = ω

Ts =ω π

fs 2

11.4 IIR Filter Design 661

−1 0 1

2

Real part Imaginary part

−5 0 5

−2

−1 0 1 2

t

x(t)

−1

−0.5 0 0.5 1

t

y(t)

0 0.02 0.04 0.06 0.08 0.1

0 0.02 0.04 0.06 0.08 0.1

(b) 0

0.5 1

|H(f)|

0 50 100 150 200 250

0 50 100 150 200 250

0 2 4

<H(f)

f[Hz]

(a) FIGURE 11.12

Bilinear transformation of a high-pass analog filter into a discrete filter with half-power frequenciesωhp=π/2or fhp=125 Hz. (a) Poles and zeros and magnitude and phase responses of the discrete filter. (b) The analog input and output obtained using the MATLAB functionplotto interpolate the sampled signalx(nTs)and the output of the discrete filtery(nTs)intox(t)andy(t).

so we multiply the normalized discrete frequency ω/π by fs/2=250, resulting in a maximum frequency of 250 Hz. The half-power frequency in hertz is thus 125 Hz. The magnitude and the phase responses ofH(z)are shown in Figure 11.12. Notice that phase is approximately linear in the passband, despite the fact that no phase specifications are considered.

Since the maximum frequency ofx(t)is 250 Hz we chooseTs=1/500. As a high-pass filter, when we inputx(nTs)intoH(z)its low-frequency component cos(40πnTs)is attenuated. The input and

corresponding output of the filter are shown in Figure 11.12. n

Remarks

n The design is simplified by giving a desired half-power frequencyωhp, as we then only need to calculate the order of the filter by using the stopband constraint. In this case, by settingαmax=3dB andωphp

one could also use the lower equation in Equation (11.28) to find N.

n A very important consequence of using the bilinear transformation is that the resulting transfer function HN(z)is guaranteed to be BIBO stable. This transformation maps the poles of a stable filter HN(s)in the left-hand s-plane into poles inside the unit circle corresponding to HN(z), making the discrete filter stable.

n The bilinear transformation creates a pole and a zero in the z-plane for each pole in the s-plane. Analytic calculation of the poles of HN(z)is not as important as in the analog case. The MATLAB functionzplane can be used to plot its poles and zeros, and the functionroots can be used to find the values of the poles and zeros.

n Applying the bilinear transformation by hand to filters of order higher than 2 is cumbersome. When doing so, HN(s) should be expressed as a product or sum of first- and second-order transfer functions before applying the bilinear transformation to each. That is, we express HN(s)as

HN(s)=Y

i

HNi(s) or

=X

`

HN`(s)

where HNi(s)or HN`(s)are first- or second-order functions with real coefficients. Applying the bilinear transformation to each of the HNi(s)or HN`(s)components to obtain HNi(z)and HN`(z), the discrete filter becomes

HN(z)=Y

i

HNi(z) or

=X

`

HN`(z)

n Since the resulting filter has normalized magnitude, a specified dc gain can be attained by multiplying HN(z)by a constant value G so that|GH(ej0)|equals the desired dc gain.

nExample 11.7

The specifications of a low-pass discrete filter are:

ωp=0.47π (rad) αmax=2 dB ωst=0.6π (rad) αmin=9 dB α(ej0)=0 dB

Use MATLAB to design a discrete low-pass Butterwoth filter by means of the bilinear transformation.

Solution

Since the frequency specifications are in radians, we use these values directly in the MATLAB func- tionbuttord, which for inputsαmax,αmin,ωp/π, andωst/π, provides the minimal orderNand the half-power frequencyωhp/πof the filter. Notice that the input and the output frequencies are nor- malized (i.e., divided byπ). With the outputs ofbuttordas inputs of the functionbutterwe obtain the coefficients of the numerator and the denominator of the designed filter H(z)=B(z)/A(z).

The function rootsis used to find the poles and the zeros ofH(z), whilezplaneplots them. The magnitude and the phase responses are found usingfreqzaided by the functionsabs, angle, and unwrap. Notice thatbutterobtains the normalized analog filter and transforms it using the bilinear transformation. The script used is as follows.

11.4 IIR Filter Design 663

%%%%%%%%%%%%%%%%

% Example 11.7

%%%%%%%%%%%%%%%%

% LP Butterworth

alphamax = 2; alphamin = 9; % loss specifications

wp = 0.47;ws = 0.6; % passband and stopband frequencies

[N,wh] = buttord(wp,ws,alphamax,alphamin) % minimal order, half-power frequency [b,a] = butter(N,wh); % coefficients of designed filter

[H,w] = freqz(b,a);w = w/pi;N = length(H); % frequency response

spec1 = alphamax∗ones(1,N); spec2 = alphamin∗ones(1,N); % specification lines hpf = 3.01∗ones(1,N); % half-power frequency line

disp(‘poles’) % display poles roots(a)

disp(‘zeros’) % display zeros roots(b)

alpha = -20∗log10(abs(H)); % loss in dB

The results of the design are shown in Figure 11.13. The order of the designed filter isN=3 and the half-power frequency isωhp=0.499π. The poles are along the imaginary axis of thez-plane (Kb=1)and there are three zeros atz= −1. The transfer function of the designed filter is

H(z)= 0.166+0.497z−1+0.497z−2+0.166z−3 1−0.006z−1+0.333z−2−0.001z−3

Finally, to verify that the specifications are satisfied we plot the loss functionα(ejω)along with three horizontal lines corresponding toαmax=2 dB, 3 dB for the half-power frequency, andαmin=9 dB.

−5 0 5

−1 0 1

3

Real part Imaginary part

0.1

0 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0

2 4 6 8 10 12

α(ω)dB

ω/π (b) 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

0 0.5 1

|H(ejω)|

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

−6

−4

−2 0

<H(ejω)

ω/π (a) FIGURE 11.13

Design of low-pass Butterworth filter using MATLAB: (a) poles and zeros and magnitude and phase responses, and (b) verification of specifications using loss functionα(ω).

The crossings of these lines with the filter loss function indicate that at the normalized frequency of 0.6 the loss is 9 as desired, and that at the normalized frequency 0.47 the loss is less than 2 dB,

so that the normalized half-power frequency is about 0.5. n

nExample 11.8

In this example we consider designing a Butterworth low-pass discrete filter for processing an analog signal. The filter specifications are:

fp=2250 Hz passband frequency fst =2700 Hz stopband frequency fs=9000 Hz sampling frequency α1= −18 dB dc loss

α2= −15 dB loss in passband α3= −9 dB loss in stopband

Solution

The specifications are not normalized (see Figure 11.14). Normalizing them, we have that:

α(ej0)= −18 dB αmax=α2−α1=3 dB αmin =α3−α1=9 dB and

ωp= 2πfhp

fs =0.5π ωst= 2πfst

fs =0.6π

Note thatωphpsince the difference in the losses at dc and atωpis 3 dB.

FIGURE 11.14

Loss specifications for a discrete low-pass

filter for processing an analog signal. −18

−15

−9

f(KHz) 2.25 2.7 4.5

α(f) dB

11.4 IIR Filter Design 665

Since the sample period is

Ts=1/fs=(1/9)×10−3 sec/sample ⇒ Kb=cot(πfhpTs)=1

Given that the half-power frequency is known, only the minimal order of the filter is needed. The loss function for the Butterworth filter is then

α(ejω)=10 log10 1+

tan(0.5ω) tan(0.5ωhp)

2N!

=10 log10(1+(tan(0.5ω))2N) since 0.5ωhp=π/4. Forω=ωst, lettingα(ejωst)=αmin, solving forNwe get

N=log10(100.1αmin−1) 2 log10(tan(0.5ωst))

Replacingαminandωstwe obtain that the minimal order isN=4. The MATLAB script used in the design is as follows.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Example 11.8---filtering of analog signal

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

wh = 0.5∗pi; ws = 0.6∗pi; alphamin = 9; Fs = 9000; % filter specifications N = log10((10ˆ(0.1∗alphamin)-1))/(2∗log10(tan(ws/2)/tan(wh/2)));N = ceil(N) [b,a] = butter(N,wh/pi);

[H,w] = freqz(b,a);w = w/pi;N = length(H);f = w∗Fs/2;

alpha0 = -18;

G = 10ˆ(-alpha0/20);H = H∗G;

spec2 = alpha0 + alphamin∗ones(1,N);

hpf = alpha0 + 3.01∗ones(1,N);

disp(‘poles’); p = roots(a) disp(‘zeros’); z = roots(b) alpha = -20∗log10(abs(H));

The transfer function of the discrete filter is found as H(z)=H1(z)H2(z)

where eachH4i(z), i=1, 2 is the result of applying the bilinear transformation toHi(s), i=1, 2 formed by pairs of complex-conjugate poles of the analog low-pass Butterworth. To ensure that the loss is−18 dB atω=0, we included a gainGin the numerator so that

H0(z)=GH(z)= G(z+1)4

10.61(z2+0.45)(z2+0.04)

satisfies the loss specifications. Notice that whenKb=1, the poles are imaginary. The dc gainGof the filter is found from the dc lossα(ej0)= −18= −20 log10GasG=7.94.

−1 −0.5 0 0.5 1

−1

−0.5 0 0.5 1

4

Real part

Imaginary part

0 1000 2000 3000 4000

0 2 4 6 8

|H(f)|

f(Hz)

0 1000 2000 3000 4000

−6

−4

−2 0

<H(f)

f(Hz)

0 1000 2000 3000 4000

−20

−15

−10

−5 0

α(f) dB

f(Hz) FIGURE 11.15

Low-pass filter for filtering of an analog signal.

Since this filter is used to filter an analog signal the frequency scale of the magnitude and the phase responses of the filter is given in hertz (see Figure 11.15). To verify that the specifications are satisfied the loss function is plotted and compared with the losses corresponding tofhpandfst. The loss at fhp=2250 Hz coincides with the dc loss plus 3 dB, and the loss atfst =2700 Hz is

above the specified value. n

Một phần của tài liệu Signals and systems using matlab (Trang 675 - 683)

Tải bản đầy đủ (PDF)

(769 trang)