Vous êtes sur la page 1sur 28

Digital Signal Processing

Chapter 3: FIR lter design


Vijaya Krishna A
Vijaya Krishna A EC-305: DSP
Introduction
Filters extract information from signal.
Filters are everywhere: both in natural systems and designed
ones.
We consider linear, time-invariant lters.
Denition
A lter is a (LTI) system that modies the spectral content of the
input signal. It passes some frequencies almost unaltered, and
blocks/attenuates other frequencies.
Classication:
Analog/Digital
FIR/IIR (among digital lters)
Linear phase/nonlinear phase.
Vijaya Krishna A EC-305: DSP
Introduction
Analog lters:
Continuous-time systems that act upon continuous-time
signals.
Still very much in use.
Needed for designing IIR lters.
Specied in terms of Laplace and Fourier transforms.
Types: Lowpass, highpass, bandpass, bandstop, notch, allpass
etc.
Digital lters:
Discrete-time systems that act upon discrete-time signals.
Specied in terms z-transform and DTFT.
The spectrum is periodic.
Vijaya Krishna A EC-305: DSP
Introduction
FIR lters: The output of a causal FIR lter depends on the
present input and nitely many past inputs.
y(n) =
M1

k=0
h(k)x(n k)
H(z) =
M1

n=0
h(n)z
n
IIR lters: The output of a causal IIR lter depends on the
present input and nitely many past inputs and outputs.
y(n) =
N

k=1
a
k
y(n k) +
M

k=0
b
k
x(n k)
H(z) =

M
k=0
b
k
z
k
1 +

N
k=1
a
k
z
k
Vijaya Krishna A EC-305: DSP
FIR lter design
The lter design problem: Given H(e
j
), nd h(n).
Consider the ideal lowpass lter
H(e
j
) =
_
1 ||
c
0
c
||
The corresponding h(n) is
h(n) =
_

n = 0

sin
c
n

c
n
n = 0
This lter cannot be realized because it is innitely long and
non-causal.
Paley-Wiener theorem: If h(n) is causal and has nite energy,
then
_

| log |H(e
j
)||d <
Vijaya Krishna A EC-305: DSP
Linear Phase
An M-length FIR lter h(n) has linear phase if and only if it is
either
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
(M1)
H(z
1
) = H(z)
H(z) and H(z
1
) have the same roots.
If z
0
is a root of H(z), then 1/z
0
is also a root of H(z).
If z
0
is a complex root of H(z), then z

0
and 1/z

0
are also
roots of H(z).
Vijaya Krishna A EC-305: DSP
Design of linear phase FIR lters using window functions
Let H
d
(e
j
) be the desired (ideal) frequency response. Let h
d
(n)
be the corresponding impulse response.
h
d
(n) =
1
2
_

H
d
(e
j
)e
j n
d
Lets consider only the samples of h
d
(n) between n = 0 and
n = M 1, for some chosen M. This implies
h(n) = h
d
(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 lters using window functions
Thus,
H(e
j
) = H
d
(e
j
) W(e
j
)
We have
W(e
j
) = e
j
M1
2
sin
M
2
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 lter
order M.
Peak sidelobe magnitude is independent of M.
Vijaya Krishna A EC-305: DSP
Rectangular window magnitude response: Dierent M
0 0.5 1 1.5 2 2.5 3 3.5
70
60
50
40
30
20
10
0
(rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
N=5
0 0.5 1 1.5 2 2.5 3 3.5
70
60
50
40
30
20
10
0
(rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
N=11
0 0.5 1 1.5 2 2.5 3 3.5
70
60
50
40
30
20
10
0
(rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
N=31
0 0.5 1 1.5 2 2.5 3 3.5
70
60
50
40
30
20
10
0
(rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
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.5
0
0.2
0.4
0.6
0.8
1
1.2
(rad/sample)
M
a
g
n
i
t
u
d
e
Linear Scale
0 0.5 1 1.5 2 2.5 3 3.5
100
80
60
40
20
0
20
(rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
Log Scale
Vijaya Krishna A EC-305: DSP
Bartlett window
0 5 10 15 20 25 30
0
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)
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency Response
w(n) = 1
2|n
M1
2
|
M 1
n = 0, 1 . . . , M 1
Vijaya Krishna A EC-305: DSP
Hamming window
0 5 10 15 20 25 30
0
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)
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency Response
w(n) = 0.54 0.46 cos
2n
M 1
n = 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)
M
a
g
n
i
t
u
d
e

(
d
B
)
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)
M
a
g
n
i
t
u
d
e

(
d
B
)
LPF with
c
=/4. (N=31)
Rectangular
Bartlett
Hamming
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 lter with the best transition band
for approximating the following response:
H
d
(e
j
) =
_
e
j 2
|| <

4
0

4
< || <
2
Design a linear phase FIR lter for approximating the following
response. The stopband ripple must be less than 0.003.
H
d
(e
j
) =
_
0 || <

4
e
j 3
4
< || <
Vijaya Krishna A EC-305: DSP
Ideal lter responses
Filter
type
H
d
(e
j
) h
d
(n)
Lowpass
_
e
jn
0

|| <
c
0
c
< || <
_

n = n
0
sin(
c
(nn
0
))
(nn
0
)
n = n
0
Highpass
_
0 || <
c
e
jn
0

c
< || <
_
1

c

n = n
0

sin(
c
(nn
0
))
(nn
0
)
n = n
0
Bandpass
_

_
0 || <
c
1
e
jn
0

c
1
< || <
c
2
0
c
2
< || <
_

c
2

c
1

n = n
0
sin
c
2
(nn
0
)sin
c
1
(nn
0
)
(nn
0
)
n = n
0
Bandstop
_

_
e
jn
0

|| <
c
1
0
c
1
< || <
c
2
e
jn
0

c
2
< || <
_
1

c
2

c
1

n = n
0
sin
c
1
(nn
0
)sin
c
2
(nn
0
)
(nn
0
)
n = n
0
Vijaya Krishna A EC-305: DSP
Ideal lter responses
Filter type H
d
(e
j
) h
d
(n)
Dierentiator j < <
_
0 n = 0
(1)
n
n
n = 0
Hilbert
transformer
_
j 0 < <
j < < 0
_
0 n = 0
1(1)
n
n
n = 0
Vijaya Krishna A EC-305: DSP
Kaiser Window
Kaiser window allows for a trade-o between the mainlobe width
and the sidelobe attenuation.
w(n) =
_

_
I
0

1
(
n

)
2

I
0
()
, 0nN 1
0 otherwise
where I
0
(x) is the modied Bessel function of the rst kind and 0
th
order, given by
I
0
(x) = 1 +

k=1
_
_
x
2
_
k
1
k!
_
2
=
N1
2
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 =
w
s
w
p
2
, N is found as
N
_
A7.95
14.36f
, A 21
0.9
f
, A < 21
Example: Design a linear phase lowpass lter with
p
= 0.3,

s
= 0.5, and a stopband ripple of
s
= 0.01, using the Kaiser
window.
Vijaya Krishna A EC-305: DSP
FIR lter design using frequency sampling
The desired frequency response H
d
(e
j
) is sampled at N
equidistant points in the interval [0, 2].
H(k) H
d
_
2k
N
_
k = 0, 1, . . . , N 1
The lter coecients h(n) are obtained as the N-point IDFT of
H(k).
h(n) =
1
N
N1

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 symmetric
responses:
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
N1
2

k=1
Re
_
H(k)e
j
2
N
nk
_
_
_
Examples:
Obtain a linear phase lowpass lter 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
H
k
(z)
where
H
k
(z) = b
k0
+ b
k1
z
1
+ b
k2
z
2
k = 1, 2, . . . , K
for FIR systems, and
H
k
(z) =
b
k0
+ b
k1
z
1
+ b
k2
z
2
1 + a
k1
z
1
+ a
k2
z
2
Parallel structure:
H(z) = C +
K

k=1
H
k
(z)
where
H
k
(z) =
b
k0
+ b
k1
z
1
1 + a
k1
z
1
+ a
k2
z
2
Vijaya Krishna A EC-305: DSP
Lattice Structure
The lter is realized as a cascade of two-port networks.
Useful in adaptive ltering, speech coding, wavelet lterbanks
etc.
Robust to coecient quantization.
Consider the rst order lter A
1
(z) = 1 + a
1
(1)z
1
.
For the two-port network, we have
f
1
(n) = x(n) + K
1
x(n 1)
g
1
(n) = K
1
x(n) + x(n 1)
f
1
(n) = y(n) if K
1
= a
1
(1).
Now consider A
2
(z) = 1 + a
2
(1)z
1
+ a
2
(2)z
2
.
From the lattice structure,
f
2
(n) = f
1
(n) + K
2
g
1
(n 1)
g
2
(n) = K
2
f
1
(n) + g
1
(n 1)
Vijaya Krishna A EC-305: DSP
f
2
(n) = x(n) + K
1
(1 + K
2
)x(n 1) + K
2
x(n 2)
= x(n) + a
2
(1)x(n 1) + a
2
(2)x(n 2)
Thus,
K
2
= a
2
(2)
K
1
=
a
2
(1)
1 + a
2
(2)
In general, with f
0
(n) = g
0
(n) = x(n), we have
f
m
(n) = f
m1
(n) + K
m
g
m1
(n 1) m = 1, 2, . . . , M 1
g
m
(n) = K
m
f
m1
(n) + g
m1
(n 1)
K
i
are called reection coecients
Vijaya Krishna A EC-305: DSP
With a
m
(0) = 1, we have
f
m
(n) =
m

k=0
a
m
(k)x(n k)
F
m
(z) = A
m
(z)X(z)
Similarly,
g
2
(n) = K
2
f
1
(n) + g
1
(n 1)
= a
2
(2)x(n) + a
2
(1)x(n 1) + x(n 2)
With b
m
(m) = 1, we have
g
m
(n) =
m

k=0
b
m
(k)x(n k)
G
m
(z) = B
m
(z)X(z)
where, if {1, a
m
(1), . . . , a
m
(m)} are the coecients of A
m
(z),
{a
m
(m), a
m
(m 1), . . . , a
m
(1), 1} are the coecients of B
m
(z)
Vijaya Krishna A EC-305: DSP
It can be shown that
B
m
(z) = z
m
A
m
(z
1
)
= The zeros of B
m
(z) are reciprocal of those of A
m
(z).
Step-up recursion:
A
0
(z) = 1.
A
m
(z) = A
m1
(z) + K
m
z
1
B
m1
(z)
= A
m1
(z) + K
m
z
m
A
m1
(z
1
)
Step-down recursion:
A
m
(z) = A
m1
(z) + K
m
z
1
B
m1
(z)
= A
m1
(z) + K
m
[B
m
(z) k
m
A
m1
(z
1
)]
A
m1
(z) =
A
m
(z) K
m
B
m
(z)
1 K
2
m
m = M 1, . . . , 1
K
m
= a
m
(m)
Vijaya Krishna A EC-305: DSP
The procedure breaks down if any K
m
= 1.
Roots of A
m
(z) lie inside the unit circle if and only if |K
i
| < 1
for i = 1, 2, . . . , m
Examples
Find H(z) if K
1
= K
2
=
1
3
, and K
3
= 1.
Draw the lattice structure for H(z) = 8 + 4z
1
+ 2z
2
+ z
3
.
All-pole lattice lters:
H(z) =
1
1 +

N
k=1
z
k
=
1
A
N
(z)
Or,
X(z) = A
N
(z)Y(z)
Can be obtained by interchanging the input and the output in the
FIR lattice.
Vijaya Krishna A EC-305: DSP
Set
f
N
(n) = x(n)
f
0
(n) = y(n)
The recursive relations are
f
N
(n) = x(n)
f
m1
(n) = f
m
(n) K
m
g
m1
(n 1)
g
m
(n) = K
m
f
m1
(n) + g
m1
(n 1)
y(n) = f
0
(n) = g
0
(n)
Vijaya Krishna A EC-305: DSP

Vous aimerez peut-être aussi