Professional Documents
Culture Documents
Digital Filters
Digital Filters
Digital Filters
3
Finite Impulse Response Filters
[Reading material: Section 10.2]
Symmetric vs. anti-symmetric
Want FIR with linear phase
M taps at times n=0, 1, …, M-1
Symmetric: h(n)=h(M-1-n)
– H(ω)=Hr(ω)e-jω(M-1)/2
– Magnitude Hr(ω) superposition of cosines
𝜔𝜔 𝑀𝑀−1
− , 𝐻𝐻𝑟𝑟 𝜔𝜔 > 0
2
– Phase Θ 𝜔𝜔 = � 𝜔𝜔 𝑀𝑀−1
− + 𝜋𝜋, 𝐻𝐻𝑟𝑟 𝜔𝜔 < 0
2
Asymmetric: h(n)=-h(M-1-n)
– Magnitude superposition of sines
– M odd middle tap @ (M-1)/2 contains zero
10
Highpass / lowpass / other?
Asymmetric Hr(ω) superposition of sines Hr(0)=Hr(π)=0
– Bad for lowpass / highpass
– Feasible for bandpass
11
FIR Design with Windowing
Key idea
Start with desired freq response Hd(ω)
Convert to hd(n)
Multiply by window w(n)
Evaluate “quality” of resulting finite-duration h(n)=hd(n)w(n)
– Iterate (use different window) as needed
hd(n) h(n)
Hd(ω) F-1 Evaluate
reconsider
w(n) window
13
Design criteria
Choice of window involves:
– Symmetric or anti-symmetric?
– Odd or even M?
– Trade-off between large M (many taps storage, computation, delay)
and closeness to Hd(ω)
hd(n) h(n)
Hd(ω) F-1 Evaluate
reconsider
w(n) window
14
Impact of window structure
Recall time domain product, h(n)=hd(n)w(n)
15
Example
1, 𝑛𝑛 ∈ {0,1, … , 𝑀𝑀 − 1}
Start w/rectangular window, 𝑤𝑤 𝑛𝑛 = �
0, 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒
– Effect merely to truncate infinitely long hd(n)
– This is simplest possible window
– However…
Frequency response
𝑀𝑀−1
1 − 𝑒𝑒 −𝑗𝑗𝜔𝜔𝜔𝜔 sin(𝜔𝜔𝜔𝜔/2)
𝑊𝑊 𝜔𝜔 = � 𝑒𝑒 −𝑗𝑗𝜔𝜔𝜔𝜔 = −𝑗𝑗𝜔𝜔
= 𝑒𝑒 −𝑗𝑗𝜔𝜔(𝑀𝑀−1)/2
1 − 𝑒𝑒 sin(𝜔𝜔/2)
𝑛𝑛=0
sin(𝜔𝜔𝜔𝜔/2)
Magnitude response, 𝑊𝑊 𝜔𝜔 =
sin(𝜔𝜔/2)
sin(𝜔𝜔𝜔𝜔/2)
Piecewise linear phase depends on sign of
sin(𝜔𝜔/2)
16
Example continued (Matlab)
Let’s examine rectangular window numerically
M1=31; % shorter window
M2=61; % longer window
w=1e-4:1e-3:pi; % frequencies being evaluated
H1=sin(w*M1/2)./sin(w/2);
H2=sin(w*M2/2)./sin(w/2);
plot(w,log(abs(H1)),w,log(abs(H2))) 6
-4
-10
-12
0 0.5 1 1.5 2 2.5 3 3.5
17
Considerations in window selection
Want narrow main lobe quick transitions
18
Some popular windows
1) Rectangular (no window)
3) Hamming window
– Same 2X main lobe width
– Lower side lobes (3X in log scale) than rectangular
19
More windows
4) Hann
– Side lobes taper nicely
– But start higher (2X in log scale)
– Same 2X main lobe width
5) Blackman
– Wider main lobe (3X)
– Low side lobes (4X in log scale)
20
Design example
𝑒𝑒 −𝑗𝑗𝜔𝜔(𝑀𝑀−1)/2 , 𝜔𝜔 < 𝜔𝜔𝑐𝑐
Will design ideal LPF, 𝐻𝐻𝑑𝑑 𝜔𝜔 = �
0, 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒
– Exponent term provides delay of (M-1)/2 samples, corresponding to
middle of filter
𝑀𝑀−1
sin(𝜔𝜔𝑐𝑐 𝜋𝜋(𝑛𝑛− )) 𝑀𝑀−1
2
𝑀𝑀−1 , 𝑛𝑛 ≠
2
Time response, ℎ𝑑𝑑 𝑛𝑛 = 𝜋𝜋(𝑛𝑛−
2
)
𝜔𝜔𝑐𝑐 𝑀𝑀−1
, 𝑛𝑛 =
𝜋𝜋 2
21
Design example continued
To reduce oscillations of finite-duration filter, will use window:
1) Hamming: 2X wider main lobe, ≈3X side lobes ( smaller
oscillations)
2) Hann: 2X wider, 2X lower side lobes, taper off better ( clean
stop band)
3) Blackman: 3X wider, 4X lower side lobes
22
Infinite Impulse Response Filters
[Reading material: Section 10.3]
Main idea
Design of analog filters (resistors, capacitors, inductors, …) has
been around for decades
Common approach to designing infinite impulse response (IIR)
filters involves
– Design analog filter
– Convert to digital
24
Rationale for filter conversion
Recall (ECE 301 & 308) Laplace transfer function H(s)
𝐵𝐵(𝑠𝑠) ∑𝑀𝑀𝑘𝑘=0 𝑏𝑏𝑘𝑘 𝑠𝑠
𝑘𝑘
𝐻𝐻 𝑠𝑠 = = 𝑁𝑁
𝐴𝐴(𝑠𝑠) ∑𝑘𝑘=0 𝑎𝑎𝑘𝑘 𝑠𝑠 𝑘𝑘
Corresponds to differential equation (continuous time)
𝑁𝑁 𝑀𝑀
𝑑𝑑 𝑘𝑘 𝑑𝑑 𝑘𝑘
� 𝑎𝑎𝑘𝑘 𝑘𝑘 𝑦𝑦 𝑡𝑡 = � 𝑏𝑏𝑘𝑘 𝑘𝑘 𝑥𝑥 𝑡𝑡
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑘𝑘=0 𝑘𝑘=0
Analogous to difference equation
25
Conversion #1: approximating derivatives
𝑑𝑑𝑑𝑑 𝑑𝑑𝑦𝑦
Time derivatives and approximated (using calculus)
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑑𝑑𝑑𝑑 𝑥𝑥 𝑛𝑛 −𝑥𝑥(𝑛𝑛−1)
| ≈ (sampling time T)
𝑑𝑑𝑑𝑑 𝑡𝑡=𝑁𝑁𝑁𝑁 𝑇𝑇
1−𝑧𝑧 −1 1−𝑧𝑧 −1
Can show that s maps to 𝐻𝐻 𝑧𝑧 = 𝐻𝐻(𝑠𝑠 = )
𝑇𝑇 𝑇𝑇
26
Conversion #2: sampling h(t)
The analog filter’s impulse response is ha(t)
27
Conversion #3: bilinear transformation
In study of functions of complex variables, bilinear
transformations map circles to circles
– From jΩ-axis in s-plane (think of jΩ-axis as infinitely big circle)
– To unit circle in z axis
2 1−𝑧𝑧 −1
Appropriate complex mapping is 𝑠𝑠 =
𝑇𝑇 1+𝑧𝑧 −1
– T is design parameter
Ω𝑇𝑇
– Can be computed using 𝜔𝜔 = 2 tan−1
2
– Analogous to how quickly we move along jΩ-axis
28
Example 10.3.4
𝑠𝑠+0.1
Consider analog filter 𝐻𝐻𝑎𝑎 𝑠𝑠 =
(𝑠𝑠+0.1)2 +16
This is LPF whose resonance frequency (a.k.a. natural
frequency in ECE 308) is Ωr=160.5=4
Want to map resonance frequency to ωr=π/2
We do so by properly selecting T
Ω𝑟𝑟𝑇𝑇
𝜔𝜔𝑟𝑟 = 2 tan−1
2
𝜋𝜋 4𝑇𝑇
= 2 tan−1
2 2
𝜋𝜋 4𝑇𝑇 1
tan =1= = 2𝑇𝑇 𝑇𝑇 =
4 2 2
29
Example 10.3.4 continued
𝑠𝑠+0.1
Want to convert 𝐻𝐻𝑎𝑎 𝑠𝑠 = to H(z)
(𝑠𝑠+0.1)2 +16
2 1−𝑧𝑧 −1 1−𝑧𝑧 −1
Recall 𝑠𝑠 = = 4
𝑇𝑇 1+𝑧𝑧 −1 1+𝑧𝑧 −1
1−𝑧𝑧−1
1−𝑧𝑧 −1 4 +0.1
1+𝑧𝑧−1
Let’s substitute: 𝐻𝐻 𝑧𝑧 = 𝐻𝐻𝑎𝑎 𝑠𝑠 = 4 = 2
1+𝑧𝑧 −1 1−𝑧𝑧−1
4 +0.1 +16
1+𝑧𝑧−1
30