## Description

In this lab, you will design IIR digital filters for obtaining Butterworth,

Chebyshev Type I, and Elliptic filter responses.

You will also examine the

effect of quantization of filter coefficients on the frequency response. You will

again need the last three non-zero digits of your UIC ID # (UIN), say i, j, k.

You will use the number NID = ijk = 100 ∗ i + 10 ∗ j + k in this lab exercise.

You will design filters to meet the following lowpass filter specifications:

passband deviation δp = 0.01

stopband deviation δs = 0.01

passband edge frequency = fp = 0.375 − NID ∗ 10−4

.

stopband edge frequency = fs = 0.475 + NID ∗ 10−4

.

sampling frequency = 2.0

Sample code is provided for a different set of specifications given below.

The specifications (“specs”) should be modified according to your NID as

shown in the blue text. You should label axes in plots, put title, etc.

## 1 FIR filter design for comaprison of filter order with IIR filters

In this part you will design a reference FIR filter for the specs given in blue

and not what’s shown in the sample code below.

close all

dp=0.01;

ds=0.01;

fp=0.45; % modify as specified

fs=0.55; % modify as specified

Fsampl=2;

[nfir_ord,fr_edge,des_mag,wt] =

firpmord( [fp fs], [1 0], [dp ds], Fsampl);

1

hfir= firpm(nfir_ord,fr_edge,des_mag,wt);

[Hfir,w]=freqz(hfir,1,201);

plot(w/pi,abs(Hfir));

nfir_ord

%label axes in plot, put title, etc.

Q5.1 Plot the FIR filter magnitude response you obtain. Give the value

of the estimated filter order. Find the maximum magnitude deviation in the

passband and the stopband obtained in the design.

## 2 Butterworth lowpass filter Design

In this part you will design a Butterworth IIR digital filter for the specs given

in blue. Sample code is given below.

[nbut_ord, wn] = buttord(2*fp/Fsampl, 2*fs/Fsampl,

-20*log10(1-dp), -20*log10(ds));% Filter order & parameter wn are computed.

[b_but,a_but] = butter(nbut_ord, wn);% Filter coefficients are computed.

[Hbut,w]=freqz(b_but,a_but,501);% Frequency response is computed.

figure

plot(w/pi,abs(Hbut));% Magnitude response vs. omega/pi

%label axes in plot, put title, etc.

Q5.2 Plot the Butterworth lowpass filter magnitude response. What is

the estimate of the Butterworth filter order? Find the maximum magnitude

deviation in the passband and the stopband obtained in the design.

## 3 Chebyshev Type I lowpass filter Design

In this part you will design a Chebyshev Type I IIR digital filter for the specs

given in blue.

3.1 Chebyshev Type I lowpass filter design with unquantized coefficients

You will first plot the magnitude response using the unquantized filter coefficients. Sample code is given below.

[nch1_ord, wn] = cheb1ord(2*fp/Fsampl, 2*fs/Fsampl,

-20*log10(1-dp), -20*log10(ds));% Filter order & parameter wn are computed.

2

[b_ch1,a_ch1] = cheby1(nch1_ord, -20*log10(1-dp), wn);% Filter coefficients[Hch1,w]=freqz(b_ch1,a_ch1,501);% Frequency response is computed.

figure

plot(w/pi,abs(Hch1));

nch1_ord

%label axes in plot, put title, etc.

Q5.3 Plot the Chebyshev Type I filter magnitude response. What is the

estimate of the Chebyshev Type I filter order? Find the maximum magnitude

deviation in the passband and the stopband obtained in the design.

## 4 Elliptic lowpass filter Design

In this part you will design an Elliptic lowpass IIR digital filter for the specs

given in blue.

4.1 Elliptic filter lowpass design with unquantized coefficients

You will first plot the magnitude response of the filter with unquantized filter

coefficients. Sample code is given below.

[nell_ord, wn] = ellipord(2*fp/Fsampl, 2*fs/Fsampl,

-20*log10(1-dp), -20*log10(ds));% Filter order & parameter wn are computed.

[b_ell,a_ell] = ellip(nell_ord, -20*log10(1-dp), -20*log10(ds), wn);% Filter[Hell,w]=freqz(b_ell,a_ell,501);% Frequency response is computed.

figure

plot(w/pi,abs(Hell));

nell_ord

%label axes in plot, put title, etc.

Q5.4 Plot the filter magnitude response. Find the maximum magnitude

deviation in the passband and the stopband.

Q5.5 Compare the order required for the four filters (FIR, Butterworth,

Chebyshev Type I, and Elliptic) to meet the same specs.

4.2 Elliptic lowpass filter Design with quantized coefficients

You will now plot the passband response detail using the quantized filter

coefficients. Sample code is given below.

3

bq_ell=quant(b_ell, 1/64);

aq_ell=quant(a_ell, 1/64);

Hqell=freqz(bq_ell,aq_ell,501);

figure

plot(abs(Hell))

nell_ord

figure

plot(abs(Hell(1:201)))

figure

plot(abs(Hqell(1:201)))

%label axes in plot, put title, etc.

Q5.6 Plot the magnitude response and the passband magnitude detail of

the filter with quantized coefficients. Use 6-bit quantization as in in the

sample code. beyond the decimal. Note the change in passband magnitude

deviation. Are the specs met?

Q5.7 Increase the number of bits used for coefficient representation to 10

(use 1/1024 in “quant”), and comment on the changes in passband magnitude

deviation.

Q5.8 The poles of the filter transfer function should all be inside the unit

circle. Using the command “roots(a ell)” determine the largest radius rmax

of the poles of the filter with unquantized coefficients.

Determine its “peak

contribution” 1/(1 − rmax) to the magnitude response. Using the command

“roots(aq ell)” determine the largest radius rqmax of the poles of the filter

with quantized coefficients.

Determine its “peak contribution” 1/(1 − rqmax)

to the magnitude response. Comment on the change in the contribution

due to quantization. Explain how this is manifested in the change in the

magnitude response after quantization.

Submit a hardcopy of your code along with the report.