Вы находитесь на странице: 1из 22

Practical Signal Processing Concepts and Algorithms using MATLAB

IIR Filter Design

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-1

IIR Filter Design

Section Outline

Filter specifications Analog prototyping Filter design functions Introduction to the Filter Design and Analysis Tool (FDATool)

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-2

IIR Filter Design

Filter Design

Design specifications
Remove noise above Less specific a cutoff frequency Set passband ripple, stopband attenuation, or transition width Minimize filter order More specific Arbitrary response
2010 Trity Technologies Sdn Bhd. All Rights Reserved

IIR design methods


Butterworth filter Butterworth, Chebyshev Types I and II, elliptic filters Order selection functions Direct IIR methods
5-3

IIR Filter Design

Filter Configurations
Lowpass filter Highpass filter

Bandpass filter

Bandstop filter

Normalization convention: 0 f 1 = Nyquist frequency


2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-4

IIR Filter Design

Filter Specifications
0 Magnitude (dB) 0

Rp

Rs

Passband

Transition band Wp Ws Normalized frequency

Stopband

0
2010 Trity Technologies Sdn Bhd. All Rights Reserved

1
5-5

IIR Filter Design

IIR Filter Design


Advantage: lower order than FIR designs Disdvantage: nonlinear phase but see filtfilt

Classic IIR filters types


Butterworth Chebyshev Types I and II Elliptic Bessel Supported in both the analog and digital domains (except Bessel analog only), and in lowpass, highpass, bandpass, and bandstop configurations.

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-6

IIR Filter Design

IIR Filter Types

Butterworth

Chebyshev Type I

Chebyshev Type II

Elliptic
2010 Trity Technologies Sdn Bhd. All Rights Reserved

Bessel
5-7

IIR Filter Design

Analog Prototyping
1. Find an analog lowpass filter with cutoff frequency of 1 and
translate this prototype filter to the desired band configuration

2. Transform the filter to the digital domain 3. Discretize the filter


Design Task Analog lowpass prototype Frequency transformation Discretization Available Low-level Functions

buttap, cheb1ap, besselap, ellipap, cheb2ap lp2lp, lp2hp, lp2bp, lp2bs bilinear, impinvar

Alternatively: The butter, cheby1, cheby2, ellip, and besself functions perform all steps of the filter design The buttord, cheb1ord, cheb2ord, and ellipord functions perform minimum order computations for IIR filters. 2010 Trity Technologies Sdn Bhd. All Rights Reserved 5-8

IIR Filter Design

Example: Bandpass Filter


Order n 10, sampling frequency fs = 10,000 Hz

Rp Rs
20 dB

0.5 dB

Ws(1)
2010 Trity Technologies Sdn Bhd. All Rights Reserved

0.02

Wp(1)
0.03

Middle C 0.0525

Wp(2)
0.07

Ws(2)
5-9
0.08

IIR Filter Design

Butterworth Method: Analog Prototype


>> protobutter

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-10

IIR Filter Design

Butterworth Method: Discretization


Impulse invariance

-20 dB

Bilinear transformation

-20 dB
2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-11

IIR Filter Design

Chebyshev Type I Method


>> chebyband

Order 10

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-12

IIR Filter Design

Elliptic Method
>> ellipband

Order 8

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-13

IIR Filter Design

Direct IIR Design


>> [b,a] = yulewalk(n,f,m) Specifications in the discrete domain Fit arbitrary frequency response data Not constrained to standard lowpass, highpass, bandpass, or bandstop configurations Multiband frequency response is possible Does not accept phase information No statements are made about the optimality of the resulting filter
2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-14

IIR Filter Design

Example: Arbitrary Response IIR Filter


Design a 12th-order bandstop filter fitting the following data: >> f = [0 0.3 0.3 0.4 0.4 0.5 0.5 0.6 0.6 1]; >> m = [1 1 0.5 0.5 0 0 0.5 0.5 1 1];

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-15

IIR Filter Design

Complete Classical IIR Filter Filter Type Design Function Design


Bessel (analog only) [b,a] = besself(n,Wn,options) [z,p,k] = besself(n,Wn,options) [A,B,C,D] = besself(n,Wn,options) [b,a] = butter(n,Wn,options) [z,p,k] = butter(n,Wn,options) [A,B,C,D] = butter(n,Wn,options) [b,a] = cheby1(n,Rp,Wn,options) [z,p,k] = cheby1(n,Rp,Wn,options) [A,B,C,D] = cheby1(n,Rp,Wn,options) [b,a] = cheby2(n,Rs,Wn,options) [z,p,k] = cheby2(n,Rs,Wn,options) [A,B,C,D] = cheby2(n,Rs,Wn,options) [b,a] = ellip(n,Rp,Rs,Wn,options) [z,p,k] = ellip(n,Rp,Rs,Wn,options) [A,B,C,D] = ellip(n,Rp,Rs,Wn,options) 5-16

Butterworth

Chebyshev Type I

Chebyshev Type II

Elliptic
2010 Trity Technologies Sdn Bhd. All Rights Reserved

IIR Filter Design

Example 1:

For data sampled at 1000 Hz, design a 9th-order highpass Butterworth IIR filter with cutoff frequency of 300 Hz,

Solution:

[b,a] = butter(9,300/500,'high'); freqz(b,a,128,1000)

Example 2:

For data sampled at 1000 Hz, design a 9th-order lowpass Chebyshev Type I filter with 0.5 dB of ripple in the passband and a cutoff frequency of 300 Hz, which corresponds to a normalized value of 0.6:

Solution
[b,a] = cheby1(9,0.5,300/500); freqz(b,a,512,1000)%The frequency response of the filter
2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-17

IIR Filter Design

Filter Design with SPTool


>> sptool

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-18

IIR Filter Design

Filter Design with FDATool

>> fdatool

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-19

IIR Filter Design

Filter Analysis with FDATool

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-20

IIR Filter Design

Importing Existing Filters

Select Import Mode


2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-21

IIR Filter Design

Exporting from FDATool


Filters designed in the FDATool can be exported to The MATLAB workspace (filter coefficients can be vectors or objects) The SPTool (for capabilities not available in FDATool, such as spectral analysis) MAT-files Text files C header files

2010 Trity Technologies Sdn Bhd. All Rights Reserved

5-22