Loading documents preview...
Digital Filter Design procedure: 1. Specify Discrete-Time domain filter requirements (LP,HP,…; ωp, ωs, …; αp, αs) 2. Use easiest (T=2) inverse bilinear transformation to warp frequencies to Continuous-Time domain : p tan ( p 2) s tan ( s 2)
3. Design analog filter for (Ωp, Ωs, …, αp, αs ) and obtain Ha(s)=BCT(s)/ACT(s) 4. Convert to Discrete-time domain, using bilinear transformation, to obtain the rational transfer function G(z)=BDT(z)/ADT (z) G ( z ) H a ( s ) | 1 z 1 s
1 z 1
Point 3 of previous slide is realized by:
Analog Filter Design procedure 1. Develop specifications of an analog lowpass filter prototype HLP(s) (choose ΩP=1) from specifications of desired analog filter HD(ŝ) using a frequency ˆ transformation s=F(ŝ) (e.g. HP to LP: s sˆ ) p
p
2. Design the prototype analog lowpass filter
3. Derive the transfer function HD(ŝ) of the desired filter by inverse frequency transformation ŝ=F-1(s)
Peak passband ripple:
p 20 log10 (1 p ) Minimum stopband attenuation
s 20 log10 ( s ) Peak ripple values δp and δs are obtained by inverting formulas:
p 1 10
s 10
s
20
Example: αp=0.15 dB → δp=0.017121 αs=41 dB → δs=0.0089125
p 20
Maximum passband attenuation
max 20 log10 ( 1 2 ) Minimum stopband attenuation
1 s 20 log10 A Inverting formulas:
2 10
max 10
s
A 10 20 Example: αmax=0.5 dB → ε2=0.12202 αs=40 dB → A=100
1
Chebyshev polynomials and Chebyshev filters RECURSION:
Type 1 Chebyshev filter
Type 2 Chebyshev filter
Exercise: Given the Chebyshev polynomial of order 5, i.e. T5(x), for -2≤ x ≤ 2: • Plot T5 ( x) 2 • Plot T5 ( x)
2 • Plot 1 / 1 0.1 T5 ( x)
• Plot
10 1 / 1 2 1 T5 ( x )
(corresponding to squared amplitude of a Type1 filter) (corresponding to squared amplitude of a Type2 filter)
x=-2:1/100:2;
%Chebyshev Type1 polynomial y=16*x.^5-20*x.^3+5*x; plot(x,y); pause axis([-2 2 -2 2]); pause plot(x,y.^2); axis([-2 2 -2 2]); pause
%Chebyshev Type1 filter plot(x,1./(1+0.1*y.^2)) pause
%Chebyshev Type2 filter y2=16*x.^-5-20*x.^-3+5*x.^-1; plot(x,1./(1+10*y2.^-2))
Try also using higher order polynomials
T52 ( x)
T5 ( x)
1 / 1 0.1 T52 ( x)
10 1 / 1 2 1 T5 ( x )
Analog lowpass filter design It is realized in Matlab by one of the following (see help of single functions): Butterworth: [N,Wn]=buttord(Wp,Ws,Rp,Rs,’s’); [B,A]=butter(N,Wn,’s’);
Chebyshev Type 1: [N,Wn]=cheb1ord(Wp,Ws,Rp,Rs,’s’); [B,A]=cheby1(N,Rp,Wn,’s’);
Chebyshev Type 2: [N,Wn]= cheb2ord(Wp,Ws,Rp,Rs,’s’); [B,A]= cheby2(N,Rs,Wn,’s’);
Elliptic: [N,Wn]=ellipord(Wp,Ws,Rp,Rs,’s’); [B,A]=ellip(N,Rp,Rs,Wn,’s’); Wp,Ws in rad/s Rp decibels of peak-to-peak passband ripple Rs minimum stopband attenuation in dB
Frequency transformations from LP analog filters in Matlab: [NUMT,DENT] = lp2lp(NUM,DEN,Wo)
transforms the analog lowpass filter prototype NUM(s)/DEN(s) with unity cutoff frequency of 1 rad/sec to a lowpass filter with cutoff frequency Wo (rad/sec) [NUMT,DENT] = lp2hp(NUM,DEN,Wo)
transforms the analog lowpass filter prototype with a cutoff angular frequency of 1 rad/s into highpass filters with desired cutoff angular frequency Wo [NUMT,DENT] = lp2bp(NUM,DEN,Wo,Bw)
transforms analog lowpass filter prototypes with a cutoff angular frequency of 1 rad/s into bandpass filters with desired center frequency Wo and bandwidth Bw [NUMT,DENT] = lp2bs(NUM,DEN,Wo,Bw)
transforms analog lowpass filter prototypes with a cutoff angular frequency of 1 rad/s into bandstop filters with desired center frequency Wo and bandwidth Bw
Bilinear transformation in Matlab: [num,den]=bilinear(NUM,DEN,fs)
converts an s-domain transfer function Ha(s) given by coefficients NUM and DEN to a discrete time equivalent G(z) given by coefficients num and den Row vectors NUM and DEN specify the coefficients of the numerator and denominator, respectively, in descending powers of s fs is the sampling frequency in hertz (fs=0.5 for the simplified condition T=2) bilinear returns the coefficients of the discrete-time equivalent filter in row vectors num and den in descending powers of z (ascending powers of z–1)
Filter design example Design a digital filter according to the following requirements: Lowpass, 1 dB ripple in passband, ωp=0.4π, stopband attenuation ≥ 40 dB at ωs=0.5π and attenuation increasing with frequency. Passband ripples, stopband monotonic → Chebyshev1 We assume T=2 → simplifies bilinear transformation Warp band-edges to continuous-time domain: p p tan tan 0.2 0.7265 rad / s 2 s tan s tan 0.25 1.0 rad / s 2 Magnitude specifications: 1 dB passband ripple 1 10 1/ 20 0.8913 0.5087 1 2 40 dB stopband attenuation 1 10 40 / 20 0.01 A 100 A
Required Chebyshev1 filter order:
A2 1 cosh 7.09 N 1 s cosh p 1
i.e. needs N=8
Filter design example (continued) Design analog filter and then map it to discrete time domain: N=8; Wp=0.7265; pbripple=1.0; [B,A]=cheby1(N,pbripple,Wp,’s’); [b,a]=bilinear(B,A,0.5); %we assumed T=2 [H,W]=freqs(B,A,0:1/100:2); plot(W,20*log10(abs(H))); axis([0 2 -60 5]); [HD,w]=freqz(b,a); plot(w/pi,20*log10(abs(HD))); axis([0 1 -60 5]); H ( j )
Analog filter
Ω
HD(e j )
Digital filter
ω/π
Design of Highpass IIR Digital Filter – Chebyshev Type 1 Specifications:
passband edge: 700 Hz stopband edge: 500 Hz passband ripple: 1dB minimum stopband attenuation: 32 dB sampling frequency: 2kHz
Fp=700; Fs=500; alpha_p=1; alpha_s=32; FT=2000;
%Normalized angular bandedge (in rad/sample) wp=2*pi*Fp/FT; ws=2*pi*Fs/FT;
%Assuming T=2 in inverse bilinear transformation Wp=tan(wp/2); %in rad/s
Band-edges of the discrete-time HP filter
Band-edges of the continuous-time HP Ws=tan(ws/2); filter Band-edges of the Wp_lp=1; %Normalized passband edge continuous-time LP Ws_lp=Wp_lp*Wp/Ws; %Frequency transformation HP to LP prototype
%find filter order and pass-band edge frequency [N,Wn]=cheb1ord(1,Ws_lp,alpha_p,alpha_s,'s');
%Design the LP prototype [B,A]=cheby1(N,alpha_p,Wn,'s');
%Apply frequency transformation LP to HP [BT,AT]=lp2hp(B,A,Wp);
%Apply bilinear transformation to get the discrete-time filter (again T=2) [num,den]=bilinear(BT,AT,0.5);
%Plot the amplitude of obtained transfer function [H,w]=freqz(num,den); plot(w/pi,20*log10(abs(H))); axis([0 1 -50 5]); %Zoom H ( e j )
ω/π
Design of Highpass IIR Digital Filter - Elliptic Specifications:
Fp=250; Fs=200; alpha_p=1; alpha_s=80; FT=1000; wp=2*pi*Fp/FT; ws=2*pi*Fs/FT; Wp=tan(wp/2); Ws=tan(ws/2);
passband edge: 250 Hz stopband edge: 200 Hz passband ripple: 1dB minimum stopband attenuation: 80 dB sampling frequency: 1kHz
Wp_lp=1; Ws_lp=Wp_lp*Wp/Ws; [N,Wn]=ellipord(1,Ws_lp,alpha_p,alpha_s,'s'); [B,A]=ellip(N,alpha_p,alpha_s,Wn,'s'); [BT,AT]=lp2hp(B,A,Wp); [num,den]=bilinear(BT,AT,0.5); [H,w]=freqz(num,den); plot(w/pi,20*log10(abs(H)));
The design procedure of the previous slide can be realized automatically by Matlab with a direct digital design: [N,Wn]=ellipord(wp/pi,ws/pi,alpha_p,alpha_s); [num1,den1]=ellip(N,alpha_p,alpha_s,Wn,’high’);
Use of ellipord and ellip directly in the discrete time domain!
[H1,w]=freqz(num1,den1); plot(w/pi,20*log10(abs(H1)),'r');
Matlab is applying bilinear transformation and frequency transformation for us.
Digital lowpass filter design It is directly realized in Matlab by one of the following (see help of single functions): Butterworth: [N,Wn]=buttord(Wp,Ws,Rp,Rs); [b,a]=butter(N,Wn);
Chebyshev Type 1: [N,Wn]=cheb1ord(Wp,Ws,Rp,Rs); [b,a]=cheby1(N,Rp,Wn);
Chebyshev Type 2: [N,Wn]= cheb2ord(Wp,Ws,Rp,Rs); [b,a]= cheby2(N,Rs,Wn);
Elliptic: [N,Wn]=ellipord(Wp,Ws,Rp,Rs); [b,a]=ellip(N,Rp,Rs,Wn); Wp,Ws normalized frequencies in the range 0…1. (1 corresponds to half the sampling rate) Rp decibels of peak-to-peak passband ripple Rs minimum stopband attenuation in dB
Design of Butterworth digital filters using the function b u t t e r : Lowpass: [b,a]=butter(N,Wn,’low’);
Highpass: [b,a]=butter(N,Wn,’high’);
Bandpass: [b,a]=butter(N,[Wn1,Wn2]); %two passband edge frequencies
Bandstop: [b,a]=butter(N,[Wn1,Wn2],’stop’); %two stopband edge frequencies
Note: bandpass and bandstop filters will have order 2*N Wn are normalized frequencies in the range 0…1
Similar syntax holds for cheby1 , cheby2 , ellip (see help of these functions).
Exercise 1: Design digital Butterworth filters with the following specifications: Order N=5; Sampling frequency fs=8000 Hz 1. 2. 3. 4.
Lowpass, cutoff frequency= 1000 Hz Highpass, cutoff frequency = 2000 Hz Bandpass, pass band = [1000, 2000] Hz Bandstop, stop band = [1000, 2000] Hz
Lowpass filter using directly digital design: fs=8000; N=5; fc=1000; [b,a]=butter(N,fc/(fs/2),’low’); [H,w]=freqz(b,a); subplot(2,2,1); plot(w/pi*fs/2,abs(H)); xlabel(‘Freq (Hz)’); title(‘Freq. response of a low-pass filter’); grid on
Complete the exercise with the other three cases.
Exercise 2: Compare the orders of Butterworth, Chebyshev Type1, Chebyshev Type2 and elliptic filters meeting the following specifications: • • • • •
Lowpass Passband edge at ω=π/2 Maximum passband deviation of 1 dB Stopband edge at ω=0.6π Minimum stopband attenuation of 40 dB
[Use buttord, cheb1ord, cheb2ord, ellipord, with input parameters (0.5,0.6,1,40) and output parameters [N,Wn]. See help of these functions]
Exercise 3: Compare the frequency responses of Butterworth, Chebyshev Type1, Chebyshev Type2 and Elliptic lowpass filters of order 6 with cut-off frequency ω=π/2.
Butterworth Chebyshev 1 Chebyshev 2 Elliptic
Exercise 4: Design a digital highpass elliptic filter with the following specifications: FT=1.5 MHz, Fp=600 kHz, Fs=210kHz, αp=0.4 dB, αs=45 dB. Derive first the analog lowpass prototype and then convert it into the desired digital filter.
p alpha_p=0.4; alpha_s=45; s wp=2*pi*Fp/FT; p ws=2*pi*Fs/FT; s ˆ 3.076 Wp=tan(wp/2); p ˆ 0.471 Ws=tan(ws/2); s Wp_lp=1; p 1 ˆ p s p Ws_lp=Wp/Ws; ˆ s
0.0556s 2 0.8329 H LP ( s ) 3 s 1.3315s 2 1.6434s 0.8329
sˆ 3 0.6322sˆ H HP ( sˆ) 3 sˆ 6.0726sˆ 2 15.1418sˆ 35.0007
[N, Wn]=ellipord(Wp_lp, Ws_lp, alpha_p, alpha_s, ‘s’); [B,A]=ellip(N, alpha_p, alpha_s, Wn, ‘s’); [BT, AT]=lp2hp(B, A, Wp); [num, den]=bilinear(BT, AT, 0.5);
0.0285 0.0414 z 1 0.0414 z 2 0.0285 z 3 GHP ( z ) 1 1.9413z 1 1.5169 z 2 0.4357 z 3 Check zero and pole positions on the complex plane. Compare with direct digital design: [N,Wn]=ellipord(wp/pi,ws/pi,alpha_p,alpha_s); [b,a]=ellip(N,alpha_p,alpha_s,Wn,‘high’);