LAB 11 - Design of Discrete-Time IIR Filters - I
LAB 11 - Design of Discrete-Time IIR Filters - I
LAB 11
Instructions:
• All tasks must be completed in this lab session for full credit.
• Students must show the output and MATLAB code for each task to the instructor
before proceeding to the next task.
References:
1
|𝐻(Ω)|2 = , (1)
Ω 2𝑁
1 + (Ω )
𝑐
where 𝑁 is the order of the filter and Ω𝑐 is the cutoff frequency, i.e., the frequency at which the magnitude-
squared response drops by 50% of its zero-frequency value, which is 1. The plot of the magnitude-squared
response of the Butterworth lowpass filter is shown in Figure 1, from which we observe that:
The system function is obtained by noting that 𝐻(−Ω) = 𝐻(Ω)∗ for real-valued impulse response ℎ(𝑡). Hence,
1
𝐻(𝑠)𝐻(−𝑠) = 𝑁 |𝑠=𝑗Ω = |𝐻(Ω)|2 . (2)
−𝑠 2
1 + ( 2)
Ω𝑐
The poles of the filter are now obtained from the roots of the denominator in (2) as
𝜋 𝜋
𝑝𝑘 = ±Ω𝑐 𝑒 𝑗 2 𝑒 𝑗(2𝑘+1)2𝑁 , 𝑘 = 0, 1, … , 𝑁 − 1. (3)
1. A Butterworth lowpass filter of order 𝑁 has 2𝑁 poles, which are uniformly distributed on a circle of
radius Ω𝑐 with an angular spacing of 𝜋/𝑁 radians.
2. All poles are symmetrically located with respect to the 𝑗Ω axis.
3. A pole never falls on the 𝑗Ω axis and falls on the real axis only if 𝑁 is odd.
We may associate poles in the left-half 𝑠-plane with 𝐻(𝑠) and those in the right-half 𝑠-plane others with 𝐻(−𝑠).
2
The expression in (2) can then be rewritten as
Ω𝑐 2𝑁 Ω𝑐 2𝑁
𝐻(𝑠)𝐻(−𝑠) = = , (4)
Ω𝑐 2𝑁 + (−𝑠 2 )𝑁 ∏𝑁−1
𝑘=0 (𝑠 − 𝑝𝑘 )(𝑠 + 𝑝𝑘 )
from which, we can write the system function of causal, stable and lowpass Butterworth filter as
Ω𝑐 𝑁
𝐻(𝑠) = 𝑁−1 , (5)
∏𝑘=0 (𝑠 − 𝑝𝑘 )
𝜋 𝜋
where 𝑝𝑘 = Ω𝑐 𝑒 𝑗 2 𝑒 𝑗(2𝑘+1)2𝑁 are the locations of the poles in the left half of the 𝑠-plane.
The analog lowpass filter is specified by the parameters Ω𝑝 , 𝑅𝑝 , Ω𝑠 , and 𝛿𝑠 2 . Therefore, the essence of the
design in the case of Butterworth filter is to obtain the order 𝑁 and the cutoff frequency Ω𝑐 , given these
specifications. The frequency Ω𝑝 is called the passband edge frequency at which the magnitude-squared
response has a value of passband ripple 𝑅𝑝 , i.e.,
1
𝑅𝑝 = −10 log10 . (6)
Ω𝑝 2𝑁
1 + (Ω )
( 𝑐 )
Furthermore, Ω𝑠 is the stopband edge frequency at which the magnitude-squared response has a value of
stopband ripple 𝛿𝑠 2 , i.e.,
1
𝛿𝑠 2 = −10 log10 ( ). (7)
Ω 2𝑁
1 + (Ω𝑠 )
𝑐
(10𝑅𝑝 /10 − 1)
log10 ( ⁄ 𝛿 2 /10 )
⌈ (10 𝑠 − 1) ⌉
𝑁=⌈ ⌉, (8)
Ω
⌈ 2 log10 ( 𝑝⁄Ω ) ⌉
𝑠
⌈ ⌉
where integer ceiling function is used to get integer value for 𝑁. Since the actual 𝑁 chosen is larger than
required, specifications can be either met or exceeded either at Ω𝑝 or at Ω𝑠 .
3
Ω𝑝
Ω𝑐 = , (9)
2𝑁 𝑅𝑝
√(10 10 − 1)
Ω𝑠
Ω𝑐 = . (10)
2𝑁 𝛿𝑠 2
√(10 10 − 1)
MATLAB provides a function called [z,p,k]=buttap (N) to design a normalized (i.e., Ω𝑐 = 1) analog
Butterworth lowpass prototype filter of order N, which returns zeros in z array, poles in p array, and the value of
gain in k. However, we need an unnormalized Butterworth filter with arbitrary Ω𝑐 . From (5), we observe that
there are no zeros and that the poles of the unnormalized filter are on a circle with radius Ω𝑐 instead of on a unit
circle. This means that we have to scale the array p of the normalized filter by Ω𝑐 and the gain k by Ω𝑐 𝑁 . In the
following function, called u_buttap (N, Omegac), we design the unnormalized Butterworth analog prototype
filter.
Task 1
1. Design a lowpass analog Butterworth filter with Ω𝑝 = 1000 KHz, Ω𝑠 = 2000 KHz, passband ripple
𝑅𝑝 = 5 dBs and a stopband ripple of 𝛿𝑠 2 = 40 dBs. Find the cutoff freqeuency so that the
specifications are met exactly at Ω𝑝 . Show your work in the space below.
2. Also complete the MATLAB function [N, Omegac] = butterap_design (Omegap, Omegas, Rp, dS_sq)
to design the filter with above mentioned specifications.
3. Write a MATLAB script to plot the poles, obtained from the function above. Also, plot a circle of radius
Ω𝑐 on the same figure to verify that the poles indeed lie on this circle.
4
4. Complete the MATLAB function Hsq = butterap_msr (N, Omegac) given below to compute the
magnitude-squared response of the lowpass Butterworth filter. Then, write a separate script file to call
the function for the specifications mentioned above.
Task 2
A method to display the frequency-domain plots of analog filter is provided by the function freqs_m, given
below, which is a modified version of a function freqs provided by MATLAB. This function computes the
magnitude response in absolute as well as in relative dB scale and the phase response.
5
function [db, mag, pha, w] = freqs_m(b, a, wmax)
% Computation of s-domain frequency response: Modified version
% ------------------------------------------------------------
% [db, mag, pha, w] = freqs_m(b, a, wmax)
% db = Relative magnitude in db over the interval [0 to wmax]
% mag = Absolute magnitude over the interval [0 to wmax]
% pha = Phase response in radians over the interval [0 to wmax]
% w = Array of 500 frequency samples between 0 and wmax
% b = Numerator polynomial coefficents of H(s)
% a = Denominator polynomial coefficents of H(s)
% wmax = Maximum frequency in rad/sec over which response is
desired
%
w = (0:1:500)*wmax/500;
H = freqs(b, a, w);
mag = abs(H);
db = 10*log10((mag+eps)/max(mag));
pha = angle(H);
• Call the above function in a script file to plot the absolute and dB magnitude response along with the
phase response of the lowpass Butterworth filter designed in Task 1.
Discrete-time IIR filters are obtained by mapping the system function of the analog filter, i.e., 𝐻(𝑠), to the
system function of the discrete-time filter, 𝐻(𝑧), by mapping the points in the 𝑠-plane to the 𝑧-plane. Different
transformation methods exist in this regard, namely
1. Approximation of derivatives
2. Impulse Invariance
3. Bilinear Transformation
4. Matched 𝑧-Transformation
However, we will discuss bilinear transformation only.
Bilinear transformation maps the points in the 𝑠-plane to the 𝑧-plane via
2 1 − 𝑧 −1
𝑠= , (11)
𝑇 1 + 𝑧 −1
6
1 + 𝑠𝑇⁄2
𝑧= , (12)
1 − 𝑠𝑇⁄2
where the sampling time 𝑇 is an arbitrary parameter. Using 𝑠 = 𝜎 + 𝑗𝛺, and 𝑧 = 𝑟𝑒 𝑗𝜔 , we can write
2 𝑧 − 1 2 𝑟𝑒 𝑗𝜔 − 1 2 𝑟2 − 1 2𝑟 sin 𝜔
𝑠= = 𝑗𝜔
= ( 2
+𝑗 )
𝑇 𝑧 + 1 𝑇 𝑟𝑒 + 1 𝑇 1 + 𝑟 + 2𝑟 cos 𝜔 1 + 𝑟 2 + 2𝑟 cos 𝜔
2 𝑟2 − 1 2 2𝑟 sin 𝜔
𝜎= , 𝛺= . (13)
𝑇 1 + 𝑟 2 + 2𝑟 cos 𝜔 𝑇 1 + 𝑟 2 + 2𝑟 cos 𝜔
We note that if 𝑟 < 1, 𝑟 = 0 or 𝑟 > 1, then 𝜎 < 0, 𝜎 = 0 and 𝜎 > 0 respectively. Consequently, the left half of
𝑠-plane is mapped to inside the unit circle in the 𝑧-plane, the imaginary 𝑗𝛺 axis is mapped onto the unit circle
and the right half of 𝑠-plane is mapped outside the unit circle in the 𝑧-plane. Hence, causal and stable analog
filter is transformed into a causal and stable discrete-time filter.
2 sin 𝜔 2 𝜔
𝛺= = tan . (14)
𝑇 1 + cos 𝜔 𝑇 2
This shows that although there is a unique mapping from 𝛺 to 𝜔, which eliminates aliasing, 𝛺 is nonlinearly
related to 𝜔. This phenomenon is termed as frequency compression or frequency warping, because high analog
frequencies are mapped to a very small range of discrete high frequencies.
2 1 − 𝑧 −1
𝐻(𝑧) = 𝐻 ( ) (15)
𝑇 1 + 𝑧 −1
7
2.1.2 MATLAB IMPLEMENTATION
MATLAB provides a function called [b_d, a_d] = bilinear (b, a, Fs) to implement this mapping. b and a are the
direct-form coefficients of 𝐻(𝑠), Fs=1/T, and b_d, a_d are the direct-form coefficients of 𝐻(𝑧). The function
takes other several forms for different input-output quantities.
Task 3
Design, by hand, a discrete-time Butterworth filter with the following specifications:
𝜔𝑝 = 0.3𝜋, 𝜔𝑠 = 0.5𝜋, 𝑅𝑝 = 1 dB and 𝛿𝑠 2 = 20 dBs.
Show your working in the space below.
1. Following the design procedure listed in Section 2.1.1, and using the MATLAB functions
butterap_design, u_buttap and bilinear, design the discrete-time lowpass Butterworth filter, for
specifications given in Task 3, in MATLAB, i.e., compute its direct-form coefficients.
2. Use the function freqs_m to plot the absolute and dB magnitude responses along with the phase
response of the filter.