EE324 Lab 10 - Allison Thongvanh

 Allison
Thongvanh
Section
B
Thursday
12:10 - 3PM
Spring EE324 Lab 10
13 Lab 10
Thongvanh 1 Purpose
In this lab we learn how to design digital infinite-impulse-response (IIR) filters by digital
conversion of analog filters. In order to design, we start by plotting the analog filter using the
frequency characteristics. Then we discretize the filter and change the parameters to accommodate
for frequency warping.
Lab Assignment
In order to plot the analog filter we the data given, as shown in Table 1.
Sampling Frequency
Nyquist Frequency
Passband Frequency
Stopband Frequency
Table 1 Frequency Characteristics
Hz
300
Passband Ripple
150
Attenuation
[80 120]
[60 140]
dB
2
60
Using the MatLab (code provided in A1) we can plot the filter. The frequency response is shown
in Figure 1.
Fig. 1 Filter without Pre-Warp
Using the cheby1 function, we can find the transfer function for this filter. The transfer
function in the Laplace form is shown below.
1294078913137958 s^7
H(s) = ---------------------------------------------------------------------(s^2+6.972s+2.54e05)(s^2+20.46s+2.747e05)(s^2+32.03s+3.168e05)
(s^2+39.04s+3.79e05)(s^2+38.32s+4.533e05)(s^2+28.22s+5.228e05)
(s^2+10.4s+5.655e05)
Lab 10
Thongvanh 2 Now, using the c2d function, we obtain the transfer function for the discrete filter shown below.
2.4343e-07 (z-1)^7 (z+1)^7
H(z) = ---------------------------------------------------------------------(z^2+0.3619z+0.9624)(z^2+0.2232z+0.945)(z^2+0.04982z+0.9386)
(z^2+0.441z+0.9866)(z^2-0.124z+0.9448)(z^2-0.2635z+0.9621)
(z^2-0.3429z+0.9865)
For the next part of the lab we add pre-warping to the filter, so it is closer to the desired
specifications. To do so we change the passband and stopband frequencies so that the center

2f
f 
frequency is fC′ = N tan π ⋅ C  , or 165.40 Hz. The changes are reflected in Table 2.
π
 2 fN 
Table 2 Manual Pre-Warping Characteristics
Hz
165.4
New Center Frequency
€
[145.40 185.40]
Passband Frequency
[125.40 205.40]
Stopband Frequency
The frequency response of the discrete filter with manual pre-warping is shown in Figure 2.
Fig. 2 Filter with Manual Pre-Warping
Now we design a digital filter. This means that MatLab will account for frequency warping
automatically. To do so, we normalize the bandpass and stopband frequencies with the Nyquist
frequency.
Lab 10
Sampling Frequency
Nyquist Frequency
Passband Frequency
Stopband Frequency
Thongvanh 3 Table 3 Nyquist Normalized Filter Characteristics
Hz
300
Passband Ripple
150
Attenuation
[0.08 0.13]
[0.06 0.15]
dB
2
60
The digital discrete filter (with MatLab pre-warping) is shown in Figure 3.
Fig. 3 Filter with MatLab Pre-Warping
Conclusion
The purpose of this lab was to learn how to design digital infinite-impulse-response (IIR) filters by
digital conversion of analog filters. In order to design, we started by plotting the analog filter using
the frequency characteristics. Then we discretized the filter and changed the parameters to
accommodate for frequency warping by using the Nyquist Frequency.
Lab 10
Thongvanh 4 Appendix
fS=300; %Sampling frequency
fN=fS/2; %Nyquist frequency
fC=100; %Central frequency
Wp=[160*pi 240*pi]; %Passband frequencies, rad/s
Ws=[120*pi 280*pi]; %Stopband freuquencies, rad/s
Rp=2; %Passband ripple
Rs=60; %Attenuation
[n,Wp]=cheb1ord(Wp,Ws,Rp,Rs,'s'); %returns order n = 7 and Wp =
[502.65,753.98]
[num,den]=cheby1(n,Rp,Wp,'s'); %returns coefficents of continuous tf
[Z,P,K]=cheby1(n,Rp,Wp,'s'); %Continuous tf H(s)
noPW=zpk(Z,P,K); %Zero-pole-gain form
noPW=c2d(noPW,1/fS,'tustin'); %Discrete tf H(z)
[noPWNUM,noPWDEN]=tfdata(noPW,'v');
%%Part 2: Manual Pre-Warping---------------------------------------fCpw=(fS/pi)*tan(pi*fC/fS); %Prewarped central frequency = 165.4 Hz
Wppw=[(fCpw-20)*2*pi (fCpw+20)*2*pi]; %Prewarped passband frequency
Wspw=[(fCpw-40)*2*pi (fCpw+40)*2*pi]; %Prewarped stopband frequency
[npw,Wppw]=cheb1ord(Wppw,Wspw,Rp,Rs,'s'); %returns order n = 7 and
Wppw = [913.56 1164.89]
[num1,den1]=cheby1(npw,Rp,Wppw,'s'); %returns coefficents of
continuous tf
[Z1,P1,K1]=cheby1(npw,Rp,Wppw,'s'); %Continuous tf H(s)
PW=zpk(Z1,P1,K1); %Zero-pole-gain form
PW=c2d(PW,1/fS,'tustin'); %Discrete tf H(z)
[PWNUM,PWDEN]=tfdata(PW,'v');
%%Part 3: MatLab Pre-Warping---------------------------------------WpN=[80*2*pi 120*2*pi]/(fN*2*pi);
WsN=[60*2*pi 140*2*pi]/(fN*2*pi);
Lab 10
Thongvanh 5 [nN,WpN]=cheb1ord(WpN,WsN,Rp,Rs); %returns order n = 6 and WpN =
[502.65,753.98]
[numN,denN]=cheby1(nN,Rp,WpN); %returns coefficents of continuous
tf
[Z2,P2,K2]=cheby1(nN,Rp,WpN); %Continuous tf H(s)
autoPW=zpk(Z2,P2,K2); %Zero-pole-gain form
[autoNUM,autoDEN]=tfdata(autoPW,'v');
%%Plots---------------------------------------------------------figure;
freqz(noPWNUM,noPWDEN);
title('No Pre-Warp');
figure(2);
freqz(PWNUM,PWDEN);
title('Manual Pre-Warp');
figure(3);
freqz(autoNUM,autoDEN);
title('MatLab Pre-Warp');