Post on 22-Feb-2016
description
transcript
Finite-duration impulse response (FIR) filter (Order=M-1, Length=M)
• The impulse response
• The system function
• The difference equation (Linear convolution)
• The frequency response (DTFT)
else,0
10,)(
Mnbnh n
1
0
11
110)(
M
n
nn
MM zbzbzbbzH
1
0110 )()1()1()()(
M
kkM knxbMnxbnxbnxbny
1
0
)()(M
n
jnnezebzHH j
Linear-phase FIR filters
Linear-phase FIR filter (Order=M-1, Length=M)
•
• = 0, /2. is a constant
• Four types
Linear-phase FIR filters
,)(H
Type-1 linear-phase FIR filter (Symmetrical, M odd)
• = 0. = (M-1)/2 (integer)
• Symmetric about (the index of symmetry)
•
Linear-phase FIR filters
)]2
1(cos[)(2)2
1()(
)()(
23
0
nMnhMhH
eHHM
nr
jr
10 ),1()( MnnMhnh
Type-2 linear-phase FIR filter (Symmetrical, M even)
• = 0. = (M-1)/2 (non-integer)
•
Linear-phase FIR filters
)]2
1(cos[)(2)(
)()(12/
0
nMnhH
eHHM
nr
jr
10 ),1()( MnnMhnh
Type-3 linear-phase FIR filter (Antisymmetrical, M odd)
• = /2. = (M-1)/2 (integer)
•
Linear-phase FIR filters
0)2/)1((10 ),1()(
MhMnnMhnh
)]2
1(sin[)(2)(
)()(
23
0
nMnhH
eHHM
nr
jr
Type-4 linear-phase FIR filter (Antisymmetrical, M even)
• = /2. = (M-1)/2 (non-integer)
•
Linear-phase FIR filters
10 ),1()( MnnMhnh
)]2
1(sin[)(2)(
)()(12/
0
nMnhH
eHHM
nr
jr
Design Specs (LPF)
FIR LPF filter specifications: (a) Absolute (b) Relative
• Band [0,p]: pass band
• Band [s, ]: stop band
• Band [p, s]: transition band
• 1: Absolute ripple in pass band
• 2: Absolute ripple in stop band
• Rp: Relative ripple in pass band (in dB)
• As: Relative ripple in stop band (in dB)
Design Specs (LPF)
0)(
)(log20 scale dB
max10
HH
1
110 1
1log20
Rp
1
210 1
log20
As
Window Design Techniques
-30 -20 -10 0 10 20 30-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25Ideal LPF c=/4
Shifting
-30 -20 -10 0 10 20 30-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25Ideal LPF c= /4-shifted
-30 -20 -10 0 10 20 30-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25LPF by Window Design Technique
Window Design Techniques
General Design Procedures:
: Ideal frequency response (given)
• Step 1
• Step 2
• Step 3
)(IDEALH
21
)()(
MeHH j
IDEALd
deHHIDTFTnh njddd
)(21)]([)(
10 ),()()( M-nnwnhnh d
Window function
• symmetric about over
• 0 otherwise
10 M-n
Window Design Techniques
Rectangular Window
otherwise,0
10,1)(
Mnnw
• Exact transition width = s - p = 1.8/M
• Min. stopband attenuation = 21dB
• MATLAB function: w=boxcar (M)
Window Design Techniques
Bartlett Window
• Exact transition width = s - p = 6.1/M
• Min. stopband attenuation = 25dB
• MATLAB function: w=bartlett (M)
otherwise,0
12
1,1
222
10,1
2
)( MnMM
n
MnM
n
nw
Window Design Techniques
Hann Window
• Exact transition width = s - p = 6.2/M
• Min. stopband attenuation = 44dB
• MATLAB function: w=hann (M)
otherwise,0
10)],1
2cos(1[50)( MnM-π n.nw
Window Design Techniques
Hamming Window
• Exact transition width = s - p = 6.6/M
• Min. stopband attenuation = 53dB
• MATLAB function: w=hamming (M)
otherwise,0
10)],1
2cos(46.0540)( MnM-π n.nw
0 5 10 15 20 25 30 35 40 450
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1Hamming Window: M=45
Window Design Techniques
Blackman Window
• Exact transition width = s - p = 11/M
• Min. stopband attenuation = 74dB
• MATLAB function: w=blackman (M)
otherwise,0
10)],1
4cos(08.0)1
2cos(5.0420)( MnM-π n
M-π n.nw
0 5 10 15 20 25 30 35 40 450
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1Blackman Window: M=45
Window Design Techniques
LPF Design
c
cLPFH
,0,1
)(
c
cj
d
eH
,0,
)(
)()](sin[
21
)(21)]([)(
)(
nnde
deHHIDTFTnh
cnj
njddd
c
c
function hd=ideal_lp(wc,M)%hd: ideal LPF impulse response between 0 and M-1%wc: cut-off frequencies in radians%M: length of the filter alpha=(M-1)/2;n=[0:M-1];m=n-alpha;fc=wc/pi;hd=fc*sinc(fc*m);
Window Design Techniques
LPF Design
%Example 1 in FIR filter design wp=0.2*pi; ws=0.3*pi; tr_width=ws-wp;M=ceil(6.6*pi/tr_width)+1;n=[0:M-1];wc=(ws+wp)/2; %ideal cutoff frequencyhd=ideal_lp(wc,M);w_hamming=(hamming(M))';h=hd.*w_hamming; figure(1);stem(n,h); title('h(n)')figure(2);freqz(h,[1])
Example: p=0.2
s=0.3
As=50 dB
Window Design Techniques
0 10 20 30 40 50 60 70-0.05
0
0.05
0.1
0.15
0.2
0.25
0.3LPF: h(n)
Window Design Techniques
0 0.2 0.4 0.6 0.8 1-2000
-1500
-1000
-500
0
Normalized Frequency ( rad/sample)
Pha
se (
degr
ees)
0 0.2 0.4 0.6 0.8 1-150
-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (
dB)
LPF
Window Design Techniques
BPS example:
1s=0.2, 1p=0.35, 2p=0.65, 2s=0.8
As=60 dB
Two transition band widths must be the same!
Window Design Techniques
%Example 2 in FIR filter design% BPS design wp1=0.35*pi; ws1=0.2*pi; wp2=0.65*pi; ws2=0.8*pi; %only one transition bandwidth allowed in window designtr_width=min(wp1-ws1,ws2-wp2); M=ceil(11*pi/tr_width)+1;n=[0:M-1]; wc1=(ws1+wp1)/2; %ideal cutoff frequency 1wc2=(ws2+wp2)/2; %ideal cutoff frequency 2 hd=ideal_lp(wc2,M)-ideal_lp(wc1,M);w_blackman=(blackman(M))';h=hd.*w_blackman; figure(1);stem(n,h); title('h(n)')figure(2);freqz(h,[1])
Window Design Techniques
0 10 20 30 40 50 60 70 80-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5BPS: h(n)
Window Design Techniques
0 0.2 0.4 0.6 0.8 1-6000
-4000
-2000
0
2000
Normalized Frequency ( rad/sample)
Pha
se (
degr
ees)
0 0.2 0.4 0.6 0.8 1-150
-100
-50
0
50
Normalized Frequency ( rad/sample)
Mag
nitu
de (
dB)
BPS
Window Design Techniques
Example: Digital differentiator
%Example 2 in FIR filter design% Digital differentiator design M=21;alpha=(M-1)/2;n=0:M-1;hd=(cos(pi*(n-alpha)))./(n-alpha);hd(alpha+1)=0;w_ham=(hamming(M))';h=hd.*w_ham; [H,W]=freqz(h,[1]);plot(W/pi,abs(H)); title('Digital differentiator: |H(\omega)|')
Window Design Techniques
0 5 10 15 20-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1Digital differentiator: h(n)
Window Design Techniques
0 0.2 0.4 0.6 0.8 10
0.5
1
1.5
2
2.5
3Digital differentiator: |H()|
Window Design Techniques
>> t=linspace(-2,2,1000);>> xt=sin(2*pi*t);yt=conv(xt,h);>> subplot(2,1,1);plot(xt);title('x(t)=sin(2\pit)')>> subplot(2,1,2);plot(yt(22:end));title('y(t)=Dx(t)')
0 200 400 600 800 1000-1
-0.5
0
0.5
1x(t)=sin(2t)
0 200 400 600 800 1000-0.04
-0.02
0
0.02
0.04y(t)=Dx(t)