You are on page 1of 8

Lab10: IIR Filter Design using Analog Prototypes

Objectives The objective is to design digital filters with an infinite impulse response (IIR). IIR filters can be designed either directly, by means of a clever placement of poles and zeros in the z-plane, or indirectly by first designing a corresponding analog filter, which is then transformed to the digital domain. In this lab we will only consider the later design procedure. Note that the described principle of using analog prototypes for IIR filter design originally stems from the idea to use digital filters as a substitute for analog systems. This allows us to use the well constructed theory of analog filter design and simply transform it to the digital domain. Familiarization with IIR filter design procedure. Familiarization with frequency transformation. Bilinear frequency transformation Impulse invariance frequency transformation

Lab Instructions
This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva session. The lab report shall be uploaded on LMS three days before next scheduled lab. The Pre-lab tasks should be completed before coming to the lab and hard copy of Pre-lab session should be deposited with teacher/lab engineer at start of the lab for necessary evaluation. Alternatively, the reports can be submitted in PDF format on LMS. The students should perform and demonstrate each lab task separately for step-wise evaluation (please ensure that course instructor/lab engineer has signed each step after ascertaining its functional verification) Only those tasks that completed during the allocated lab time will be credited to the students. Students are however encouraged to practice on their own in spare time for enhancing their skills.

Lab Report Instructions


All questions should be answered precisely to get maximum credit. Lab report must ensure following items: Lab objectives MATLAB/C codes Results (graphs/tables) duly commented and discussed Conclusion

CSE-304 Digital Signal Processing

Page 1

1 IIR Filter Design using Analog Prototypes 1.1 Introduction


In the last practical we have had a closer look at the class of non-recursive digital filters, with a finite impulse response (FIR). We have presented techniques for designing FIR filters to meet certain filter specifications. Also, we have seen some typical applications of digital filtering.Now we will focus on digital filters with an infinite impulse response (IIR).These can be designed either directly, by means of a clever placement of poles and zeros in the z-plane, or indirectly by first designing a corresponding analog filter, which is then transformed to the digital domain. Within this practical we will only consider the latter design procedure. Note that the described principle of using analog prototypes for IIR filter design originally stems from the idea to use digital filters as a substitute for analog systems.This allows us to use the well constructed theory of analog filter design and simply transfer it to the digital domain.

1.2 Pre lab:


1.2.1 IIR filter design problem
Ideally, we are interested in a digital filter H(ej) that simulates a continuous time system Hc(j), i.e. the following identity is fullfilled

Here denotes the dimensionless discrete-time frequency in radians per sample, and the analog frequency in radians per second. Td is a design parameter for the analog to digital conversion, and does not need to be the same as T = 1/fs, where fs is the sampling frequency.

1.2.2

Design procedure

Given a digital filter specifications, the design of digital IIR filters can be summarized by a three-step procedure: 1. Translate the discrete-time filter specifications to the analog design domain,so that after the continuous to discrete-time transform is applied, they will be proper. 2. Select an analog prototype (Butterworth, Chebyshev, etc.) and design your analog filter Hc(s) using the translated specifications. Analog filter design it treated in Section 2. 3. Apply the continuous to discrete-time transform, and convert the analog transfer function Hc(s) into a discrete-time transfer function H(z). Details on the continuous to discrete-time conversion are given in Section 3. So before designing an appropriate analog filter, we have to translate the discrete-time filter specifications, which may be given either in real frequency f in Hz or normalized frequency = 2f/fs in radians per sample, to analog design frequency . The translation depends on which continuous to discrete time conversion scheme is used. An overview for the frequency translation is depicted in Figure 1. The digital IIR filter design steps, described above can be done automatically in the MATLAB design programs. However, to understand the procedure we will go through the individual steps in one of the experiments.

CSE-304 Digital Signal Processing

Page 2

1.2.3

Analog filter design

We briefly describe methods for analog lowpass filter design and then show how to easily obtain highpass, bandpass or bandstop from analog lowpass prototypes by using frequency transformations. (1) Bilinear transformation (2) Impulse invariance method.

Figure 1: Translation of filter specifications (f or ) to analog frequency .

1.2.3.1

Analog lowpass filter design

There are four established techniques for the design of analog filters, including Butterworth, Chebyshev Type I and II, and Elliptic analog prototypes. They represent four different combinations of two error approximation measures. One is based on Taylor series, and results in a maximally flat frequency response. The other approximation minimizes the maximum difference between the desired and actual response, and results in an equiripple frequency response. The four lowpass prototypes are: 1. The analog Butterworth filter is based on a Taylor series with expansions at = 0 and = , with desired values 1 and 0 respectively, and first up to (N-1)-th derivative equal to zero. This results in a smooth transition between at = 0 and = . The squared magnitude of the normalized frequency response is given by

where N is the filter order and c is 3 dB cutoff frequency. It can be seen that |Hc(j)|2 = 0.5 at = c. 2. The analog Chebyshev Type I filter has a rippled passband with equally sized ripples and a smooth behavior in the stopband, as can be seen in Figure 2. The squared magnitude of the normalized frequency response

CSE-304 Digital Signal Processing

Page 3

Figure 2: Magnitude specification for a Chebyshev Type I lowpass filter of a Chebyshev Type I filter is given by

where parameter determines the passband ripple amplitude, given by Chebyshev polynomial of order N, defined recursively as

, and VN (x) is the

3. The analog Chebyshev Type II is the reverse counterpart of the Type I, i.e. it has a smooth passband and a rippled stopband. Here the design parameter specifies the stopband ripple amplitude. 4. The analog Elliptic filter uses a Chebyshev approximation in both the passband and the stopband. Two design parameters are used to specify the passband and stopband ripple mplitude. Corresponding MATLAB functions for analog prototype lowpass filter design are buttap, cheb1ap, cheb2ap and ellipap. They provide a zeropole representation, which can be easily converted to differential coefficient parameters by zp2tf.

1.2.3.2 Frequency transformation


Sometimes it is simpler to calculate filter coefficients of an analog lowpass prototype only once, or to use tables. This prototype is then converted by means of frequency transforms, according to the desired characteristics. In the following, let Hc(s) be an analog lowpass prototype of order N with normalized bandedge c = 1. For instance, a lowpass with an arbitrary bandedge c can be obtained from the analog prototype Hc(s) by simply replacing Using this principle, we can also convert Hc(s) to a highpass filter with bandedge c, by changing this essentially replaces = 0 and = . A bandpass filter with lower and upper bandedge 1 and 2, can be obtained from the lowpass prototype Hc(s) by changing

Where BP is the geometric mean of the two bandedges.This mapping doubles the order of the filter and is a one-to-one mapping of the frequency domain.In MATLAB you can use the functions lp2lp, lp2hp, lp2bp and lp2bs for the analog frequency transformations. For more detail we refer to the corresponding help files.

1.2.4

Continuous to discrete-time conversion

Two methods for discrete-time conversion are considered: the impulse invariance and the bilinear transformation.

1.2.4.1

Impulse invariance method

The impulse invariance method is based on an intuitive concept. We directly transfer the discrete specifications into the analog domain, using = /Td, and design a corresponding continuous-time filter Hc(j). We then determine the impulse response of Hc(j), denoted hc(t) and obtain the impulse response of our discrete-time filter by sampling hc(t), i.e.

CSE-304 Digital Signal Processing

Page 4

Here Td is the design sampling interval. Due to the fact that the FT of hc(nTd) is a periodic extension of Hc(j), which is not perfectly bandlimited in practice, aliasing may occur so that (1) does not hold exactly. The continuous to discrete-time conversion by means of the impulse invariance can be done in MATLAB using the function impinvar.

1.2.4.2

The bilinear transformation

The bilinear transformation is a one-to-one mapping of the entire analog frequency domain 1 < < 1 onto the discrete-time frequency interval < < . Using complex Laplace and Z-transform variables s and z, the mapping is given by

In the discrete-time domain we are interested in z variables on the unit circle whereas in the continuous-time domain, s variables on the imaginary axis s = j are of importance. By evaluating (3) at and s = j, we obtain the relation between analog and digital frequency =

We notice that = 0 implies = 0 and for increasing the continuous frequency also increases and we obtain . Hence, positive continuous-time frequencies are mapped to the upper half of the unit circle and negative frequencies to the lower half. Two important properties are: The bilinear transform preserves stability. A stable continuous -time system Hc(s) with poles on the left half of the s-plane, is mapped to a stable discrete-time system H(z) with poles inside the unit circle. Identity (1) holds exactly at = 2/Tdtan(/2) when using the bilinear transform. Finally, we can perform the bilinear transformation and convert Hc(s) to H(z) using the relation

In MATLAB, the corresponding function bilinear does this job.

1.3 Warmup:
1. Use equation (2) at s = j to obtain a formula for the poles of the squared magnitude of a Butterworth filter |Hc(s)|2 and locate them on the s-plane. Hint: The M-th complex roots of are given by

2. We can rewrite the squared magnitude |Hc(s)|2 by assigning the stable poles on the left half s-plane to Hc(s), and the remaining to Hc(s). Thus, we can get Based on this, calculate the analog filter coefficients of a Butterworth filter Hc(s) with N = 2 and c = 1. 3. Briefly describe, how you can modify the analog Butterworth lowpass from above, to obtain a bandpass with bandedges 1, 2 and order N = 4. 4. A second-order digital Butterworth lowpass filter with cutoff frequency c = 0.3 is to be designed using the bilinear transformation with Td = 2. The normalized (c = 1) analog filter is given by

CSE-304 Digital Signal Processing

Page 5

Calculate the translated analog cutoff frequency c. Modify Hc(s) such that the bandedge is changed to c. Apply the bilinear transformation and determine the discrete-time filter coefficients.

1.4 Lab Tasks


1.4.1 Lab Task 1
1.4.1.1 Bilinear transformation and impulse invariance
The N-th order analog Butterworth lowpass filter with cutoff frequency c is given by

1. Design a Butterworth filter with N = 4, c = 0.3 and Td = 2 using the impulse invariance method. Proceed as follows: (a) Determine c and use (5) to calculate the analog filtering coefficients (use poly to convert between root and polynomial representation). (b) In the analog domain, plot hc(t) and |Hc(j)|. For the analog domain plots in MATLAB use the commands tf, impulse and freqs. (c) Transform your filter coefficients from the analog to the discretetime domain. (d) In the discrete-time domain, plot h(n) and |H(ej)| . Compare your results with (b). 2. Repeat 1. but with the bilinear transformation. 3. Vary the design parameter Td. What is its influence? Further, compare both methods: what are their strengths and weaknesses?

CSE-304 Digital Signal Processing

Page 6

10

Magnitude

10

10

-2

10

-4

10

-1

10 Frequency (rad/s)

10

150

Phase (degrees)

100 50 0 -50 -1 10
0 1

10 Frequency (rad/s)

10

1.4.2 Lab Task 2:


1.4.2.1 Characteristics of IIR filters

For simplicity, we now use MATLAB functions which automatically perform all digital IIR filter design steps, mentioned in the introduction. The commands are e.g. butter, cheby1 or ellip. Use the help command for more details. Say the filtering specifications for a particular job are: Sampling frequency 200 Hz Passband ripple _ 1 dB Passband edge 32 Hz Stopband edge 38 Hz Stopband attenuation > 25 dB 1. Determine the order of a Butterworth, Chebyshev Type I and Elliptic filters that meet these specifications? Use the buttord, cheb1ord and ellipord commands. 2. Use butter, cheby1 and ellip to design the specified filters. For each, plot the magnitude of the frequency response, the pole-zero location diagram and the significant part of the impulse response. 3. For comparison, design an optimum FIR filter using firpm that meets the specifications. Determine the order using firpmord. Discuss your results.

CSE-304 Digital Signal Processing

Page 7

1.4.3 Lab Task 3:


1.4.3.1 IIR filtering of sinusoids
1. The digital sequence x(n) arises from sampling an analog signal, x(t) = 5 sin(200t) + 2 cos(300t), at a sample rate fs = 1000 Hz. (a) Design a minimum-order IIR digital filter that will pass the 150 Hz component with attenuation of less than 1 dB and suppress the 100 Hz component to at least 40 dB. The filter should have a monotone passband and an equiripple stopband. (b) Generate 300 samples of the above sequence x(n) and process it through the designed filter to obtain the output sequence. Plot the input and the output sequences and comment on your results. 2. Use an elliptic bandstop filter with N = 10 to remove the digital frequency = 0.44 with a bandwidth of = 0.08. (a) Choose a reasonable value for the passband ripple and the stopband attenuation. Design the bandstop filter using ellip. Plot the magnitude response of your filter. (b) Generate samples of the sequence x(n) = sin(0.44n) for n = 0, 1, . . . , 200 and process through the bandstop filter. Comment on your results.

CSE-304 Digital Signal Processing

Page 8