230 likes | 744 Views
Practical Signal Processing Concepts and Algorithms using MATLAB. IIR Filter Design. Section Outline. Filter specifications Analog prototyping Filter design functions Introduction to the Filter Design and Analysis Tool (FDATool). Filter Design. IIR design methods
E N D
Practical Signal Processing Concepts and Algorithms using MATLAB IIR Filter Design
Section Outline • Filter specifications • Analog prototyping • Filter design functions • Introduction to the Filter Design and Analysis Tool (FDATool)
Filter Design • IIR design methods • Butterworth filter • Butterworth, Chebyshev • Types I and II, elliptic filters • Order selection functions • Direct IIR methods Design specifications • Remove noise above • a cutoff frequency • Set passband ripple, • stopband attenuation, • or transition width • Minimize filter order • Arbitrary response Less specific More specific
Filter Configurations Lowpass filter Highpass filter Bandpass filter Bandstop filter Normalization convention:0 ≤ f ≤ 1 = Nyquist frequency
Filter Specifications 0 0 Rp Magnitude (dB) Rs Transition band Passband Stopband 0 Wp Ws 1 Normalized frequency
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.
IIR Filter Types Butterworth Chebyshev Type I Chebyshev Type II Elliptic Bessel
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 • 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.
Example: Bandpass Filter Order n ≤ 10, sampling frequency fs = 10,000 Hz Rp 0.5 dB Rs 20 dB Ws(1) Wp(1) Wp(2) Ws(2) Middle C 0.02 0.03 0.0525 0.07 0.08
Butterworth Method: Analog Prototype >> protobutter
Butterworth Method: Discretization Impulse invariance -20 dB Bilinear transformation -20 dB
Chebyshev Type I Method >> chebyband Order 10
Elliptic Method >> ellipband Order 8
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
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];
Filter Type Design Function Bessel (analog only) [b,a] = besself(n,Wn,options)[z,p,k] = besself(n,Wn,options)[A,B,C,D] = besself(n,Wn,options) Butterworth [b,a] = butter(n,Wn,options)[z,p,k] = butter(n,Wn,options)[A,B,C,D] = butter(n,Wn,options) Chebyshev Type I [b,a] = cheby1(n,Rp,Wn,options)[z,p,k] = cheby1(n,Rp,Wn,options)[A,B,C,D] = cheby1(n,Rp,Wn,options) Chebyshev Type II [b,a] = cheby2(n,Rs,Wn,options)[z,p,k] = cheby2(n,Rs,Wn,options)[A,B,C,D] = cheby2(n,Rs,Wn,options) Elliptic [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) Complete Classical 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 1000Hz, design a 9th-order lowpass Chebyshev Type I filter with 0.5dB of ripple in the passband and a cutoff frequency of 300Hz, 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
Filter Design with SPTool >> sptool
Filter Design with FDATool >> fdatool
Importing Existing Filters Select Import Mode
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