Upload
kannarpadi
View
41
Download
1
Embed Size (px)
DESCRIPTION
Introduction to FIR filter design
Citation preview
Digital Signal Processing
Chapter 3: FIR filter design
Vijaya Krishna A
Vijaya Krishna A EC-305: DSP
Introduction
Filters extract information from signal.
Filters are everywhere: both in natural systems and designedones.
We consider linear, time-invariant filters.
Definition
A filter is a (LTI) system that modifies the spectral content of theinput signal. It passes some frequencies almost unaltered, andblocks/attenuates other frequencies.
Classification:
Analog/DigitalFIR/IIR (among digital filters)Linear phase/nonlinear phase.
Vijaya Krishna A EC-305: DSP
Introduction
Analog filters:
Continuous-time systems that act upon continuous-timesignals.Still very much in use.Needed for designing IIR filters.Specified in terms of Laplace and Fourier transforms.Types: Lowpass, highpass, bandpass, bandstop, notch, allpassetc.
Digital filters:
Discrete-time systems that act upon discrete-time signals.Specified in terms z-transform and DTFT.The spectrum is periodic.
Vijaya Krishna A EC-305: DSP
Introduction
FIR filters: The output of a causal FIR filter depends on thepresent input and finitely many past inputs.
y(n) =M−1∑k=0
h(k)x(n − k)
H(z) =M−1∑n=0
h(n)z−n
IIR filters: The output of a causal IIR filter depends on thepresent input and finitely many past inputs and outputs.
y(n) = −N∑
k=1
aky(n − k) +M∑
k=0
bkx(n − k)
H(z) =
∑Mk=0 bkz−k
1 +∑N
k=1 akz−k
Vijaya Krishna A EC-305: DSP
FIR filter design
The filter design problem: Given H(e jω), find h(n).Consider the ideal lowpass filter
H(e jω) =
{1 |ω| ≤ ωc
0 ωc ≤ |ω| ≤ π
The corresponding h(n) is
h(n) =
{ωcπ n = 0ωcπ
sinωcnωcn
n 6= 0
This filter cannot be realized because it is infinitely long andnon-causal.Paley-Wiener theorem: If h(n) is causal and has finite energy,then ∫ π
−π| log |H(e jω)||dω <∞
Vijaya Krishna A EC-305: DSP
Linear Phase
An M-length FIR filter h(n) has linear phase if and only if it iseither
Symmetric
h(n) = h(M − 1− n) n = 0, 1, . . . ,M − 1
or antisymmetric
h(n) = −h(M − 1− n) n = 0, 1, . . . ,M − 1
If h(n) has linear phase, it follows that
z−(M−1)H(z−1) = ±H(z)
H(z) and H(z−1) have the same roots.
If z0 is a root of H(z), then 1/z0 is also a root of H(z).
If z0 is a complex root of H(z), then z∗0 and 1/z∗0 are alsoroots of H(z).
Vijaya Krishna A EC-305: DSP
Design of linear phase FIR filters using window functions
Let Hd(e jω) be the desired (ideal) frequency response. Let hd(n)be the corresponding impulse response.
hd(n) =1
2π
∫ π
−πHd(e jω)e jωndω
Let’s consider only the samples of hd(n) between n = 0 andn = M − 1, for some chosen M. This implies
h(n) = hd(n)w(n),
where
w(n) =
{1 n = 0, 1, . . . ,M − 1
0 otherwise
w(n) is the rectangular window function.
Vijaya Krishna A EC-305: DSP
Linear phase FIR filters using window functions
Thus,H(e jω) = Hd(e jω) ∗W (e jω)
We have
W (e jω) = e−jωM−12
sin ωM2
sin ω2
Convolution with W (e jω) introduces
Transition band.Passband ripple and stopband ripple.
Transition band has a width of 4πM rad/sample.
Same as the width of the mainlobe of W (e jω).
=⇒ Smaller the required transition band, higher the filterorder M.
Peak sidelobe magnitude is independent of M.
Vijaya Krishna A EC-305: DSP
Rectangular window magnitude response: Different M
0 0.5 1 1.5 2 2.5 3 3.5−70
−60
−50
−40
−30
−20
−10
0
ω (rad/sample)
Mag
nitu
de (
dB)
N=5
0 0.5 1 1.5 2 2.5 3 3.5−70
−60
−50
−40
−30
−20
−10
0
ω (rad/sample)
Mag
nitu
de (
dB)
N=11
0 0.5 1 1.5 2 2.5 3 3.5−70
−60
−50
−40
−30
−20
−10
0
ω (rad/sample)
Mag
nitu
de (
dB)
N=31
0 0.5 1 1.5 2 2.5 3 3.5−70
−60
−50
−40
−30
−20
−10
0
ω (rad/sample)
Mag
nitu
de (
dB)
N=61
Vijaya Krishna A EC-305: DSP
LPF using rectangular window with M = 31
0 0.5 1 1.5 2 2.5 3 3.50
0.2
0.4
0.6
0.8
1
1.2
ω (rad/sample)
Mag
nitu
deLinear Scale
0 0.5 1 1.5 2 2.5 3 3.5−100
−80
−60
−40
−20
0
20
ω (rad/sample)
Mag
nitu
de (
dB)
Log Scale
Vijaya Krishna A EC-305: DSP
Bartlett window
0 5 10 15 20 25 300
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
n
Bartlett window (N=31)
0 0.5 1 1.5 2 2.5 3 3.5−100
−80
−60
−40
−20
0
20
ω (rad/sample)
Mag
nitu
de (
dB)
Frequency Response
w(n) = 1−2|n − M−1
2 |M − 1
n = 0, 1 . . . ,M − 1
Vijaya Krishna A EC-305: DSP
Hamming window
0 5 10 15 20 25 300
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
n
Hamming window (N=31)
0 0.5 1 1.5 2 2.5 3 3.5−100
−80
−60
−40
−20
0
20
ω (rad/sample)
Mag
nitu
de (
dB)
Frequency Response
w(n) = 0.54− 0.46 cos2πn
M − 1n = 0, 1 . . . ,M − 1
Vijaya Krishna A EC-305: DSP
Magnitude response comparison (M = 31)
0 0.5 1 1.5 2 2.5 3 3.5−160
−140
−120
−100
−80
−60
−40
−20
0
20
ω (rad/sample)
Mag
nitu
de (
dB)
N=31
Rectangular
Bartlett
Hamming
Vijaya Krishna A EC-305: DSP
LPF comparison (M = 31)
0 0.5 1 1.5 2 2.5 3 3.5−120
−100
−80
−60
−40
−20
0
20
ω (rad/sample)
Mag
nitu
de (
dB)
LPF with ωc=π/4. (N=31)
RectangularBartlettHamming
Vijaya Krishna A EC-305: DSP
Comparison
Window Mainlobe width Peak sidelobe Stopband attenuation
Rectangular 4πM -13 dB -21 dB
Bartlett 8πM -27 dB -25 dB
Hamming 8πM -43 dB -53 dB
Exercises:
1 Find the linear phase FIR filter with the best transition bandfor approximating the following response:
Hd(e jω) =
{e−j2ω |ω| < π
4
0 π4 < |ω| < π
2 Design a linear phase FIR filter for approximating the followingresponse. The stopband ripple must be less than 0.003.
Hd(e jω) =
{0 |ω| < π
4
e−j3ω π4 < |ω| < π
Vijaya Krishna A EC-305: DSP
Ideal filter responses
Filtertype
Hd(e jω) hd(n)
Lowpass
{e−jn0ω |ω| < ωc
0 ωc < |ω| < π
{ωcπ n = n0sin(ωc (n−n0))π(n−n0) n 6= n0
Highpass
{0 |ω| < ωc
e−jn0ω ωc < |ω| < π
{1− ωc
π n = n0
− sin(ωc (n−n0))π(n−n0) n 6= n0
Bandpass
0 |ω| < ωc1
e−jn0ω ωc1 < |ω| < ωc2
0 ωc2 < |ω| < π
{ωc2−ωc1π n = n0
sinωc2 (n−n0)−sinωc1 (n−n0)
π(n−n0) n 6= n0
Bandstop
e−jn0ω |ω| < ωc1
0 ωc1 < |ω| < ωc2
e−jn0ω ωc2 < |ω| < π
{1− ωc2−ωc1
π n = n0sinωc1 (n−n0)−sinωc2 (n−n0)
π(n−n0) n 6= n0
Vijaya Krishna A EC-305: DSP
Ideal filter responses
Filter type Hd(e jω) hd(n)
Differentiator jω − π < ω < π
{0 n = 0(−1)n
n n 6= 0
Hilberttransformer
{−j 0 < ω < π
j −π < ω < 0
{0 n = 01−(−1)n
πn n 6= 0
Vijaya Krishna A EC-305: DSP
Kaiser Window
Kaiser window allows for a trade-off between the mainlobe widthand the sidelobe attenuation.
w(n) =
I0
(β√
1−( n−αα )
2)
I0(β) , 0≤n≤N − 1
0 otherwise
where I0(x) is the modified Bessel function of the first kind and 0th
order, given by
I0(x) = 1 +∞∑
k=1
[(x
2
)k 1
k!
]2
α = N−12 determines the size of the window.
β controls the shape of the window.If β = 0, w(n) is the rectangular window.If β = 5.44, w(n) is the Hamming window.
Vijaya Krishna A EC-305: DSP
Choosing β:Let
δ = min{δp, δs}A = −20 log δ
Then
β =
0.1102(A− 8.7), A > 50
0.5842(A− 21)0.4 + 0.07886(A− 21), 50 ≥ A ≥ 21
0, A < 21
Given the transition width ∆f =ws−wp
2π , N is found as
N ≥
{A−7.9514.36∆f , A ≥ 210.9∆f , A < 21
Example: Design a linear phase lowpass filter with ωp = 0.3π,ωs = 0.5π, and a stopband ripple of δs = 0.01, using the Kaiserwindow.
Vijaya Krishna A EC-305: DSP
FIR filter design using frequency sampling
The desired frequency response Hd(e jω) is sampled at Nequidistant points in the interval [0, 2π].
H(k) ≡ Hd
(2πk
N
)k = 0, 1, . . . ,N − 1
The filter coefficients h(n) are obtained as the N-point IDFT ofH(k).
h(n) =1
N
N−1∑k=0
H(k)e j 2πN
nk n = 0, 1, . . . ,N − 1
In order to obtain real h(n), we consider only conjugate symmetricresponses:
H(N − k) = H∗(k), k = 0, 1, . . . ,N − 1
2
and H(0) is real.
Vijaya Krishna A EC-305: DSP
In this case, h(n) can be expressed as
h(n) =1
N
H(0) + 2
N−12∑
k=1
Re{
H(k)e j 2πN
nk}
Examples:
Obtain a linear phase lowpass filter with ωc = π2 and N = 7,
using the frequency sampling approach.
Vijaya Krishna A EC-305: DSP
Filter Structures
Cascade structure:
H(z) =K∏
k=1
Hk(z)
where
Hk(z) = bk0 + bk1z−1 + bk2z−2 k = 1, 2, . . . ,K
for FIR systems, and
Hk(z) =bk0 + bk1z−1 + bk2z−2
1 + ak1z−1 + ak2z−2Parallel structure:
H(z) = C +K∑
k=1
Hk(z)
where
Hk(z) =bk0 + bk1z−1
1 + ak1z−1 + ak2z−2
Vijaya Krishna A EC-305: DSP
Lattice Structure
The filter is realized as a cascade of two-port networks.
Useful in adaptive filtering, speech coding, wavelet filterbanksetc.
Robust to coefficient quantization.
Consider the first order filter A1(z) = 1 + a1(1)z−1.For the two-port network, we have
f1(n) = x(n) + K1x(n − 1)
g1(n) = K1x(n) + x(n − 1)
f1(n) = y(n) if K1 = a1(1).Now consider A2(z) = 1 + a2(1)z−1 + a2(2)z−2.From the lattice structure,
f2(n) = f1(n) + K2g1(n − 1)
g2(n) = K2f1(n) + g1(n − 1)
Vijaya Krishna A EC-305: DSP
f2(n) = x(n) + K1(1 + K2)x(n − 1) + K2x(n − 2)
= x(n) + a2(1)x(n − 1) + a2(2)x(n − 2)
Thus,
K2 = a2(2)
K1 =a2(1)
1 + a2(2)
In general, with f0(n) = g0(n) = x(n), we have
fm(n) = fm−1(n) + Kmgm−1(n − 1) m = 1, 2, . . . ,M − 1
gm(n) = Kmfm−1(n) + gm−1(n − 1)
Ki are called reflection coefficients
Vijaya Krishna A EC-305: DSP
With am(0) = 1, we have
fm(n) =m∑
k=0
am(k)x(n − k)
Fm(z) = Am(z)X (z)
Similarly,
g2(n) = K2f1(n) + g1(n − 1)
= a2(2)x(n) + a2(1)x(n − 1) + x(n − 2)
With bm(m) = 1, we have
gm(n) =m∑
k=0
bm(k)x(n − k)
Gm(z) = Bm(z)X (z)
where, if {1, am(1), . . . , am(m)} are the coefficients of Am(z),{am(m), am(m − 1), . . . , am(1), 1} are the coefficients of Bm(z)
Vijaya Krishna A EC-305: DSP
It can be shown that
Bm(z) = z−mAm(z−1)
=⇒ The zeros of Bm(z) are reciprocal of those of Am(z).Step-up recursion:A0(z) = 1.
Am(z) = Am−1(z) + Kmz−1Bm−1(z)
= Am−1(z) + Kmz−mAm−1(z−1)
Step-down recursion:
Am(z) = Am−1(z) + Kmz−1Bm−1(z)
= Am−1(z) + Km[Bm(z)− kmAm−1(z−1)]
Am−1(z) =Am(z)− KmBm(z)
1− K 2m
m = M − 1, . . . , 1
Km = am(m)Vijaya Krishna A EC-305: DSP
The procedure breaks down if any Km = 1.
Roots of Am(z) lie inside the unit circle if and only if |Ki | < 1for i = 1, 2, . . . ,m
Examples
Find H(z) if K1 = K2 = 13 , and K3 = 1.
Draw the lattice structure for H(z) = 8 + 4z−1 + 2z−2 + z−3.
All-pole lattice filters:
H(z) =1
1 +∑N
k=1 z−k=
1
AN(z)
Or,X (z) = AN(z)Y (z)
Can be obtained by interchanging the input and the output in theFIR lattice.
Vijaya Krishna A EC-305: DSP
Set
fN(n) = x(n)
f0(n) = y(n)
The recursive relations are
fN(n) = x(n)
fm−1(n) = fm(n)− Kmgm−1(n − 1)
gm(n) = Kmfm−1(n) + gm−1(n − 1)
y(n) = f0(n) = g0(n)
Vijaya Krishna A EC-305: DSP