Introduction To FIR Filter Design
Introduction To FIR Filter Design
0
0
( ) ( )
jn j
x n n e X e
F
= =
0 0
( ) ( ) or ( )
j jn j j jn
Y e Ce X e H e Ce
( )
( ) , ( ) ( )
j
g
d
H e
d
= =
6
H.1 Discrete time systems and filters
Ideal filters
The frequency response of an ideal filter has unit amplitude (gain) at the
passband, zero amplitude at the stopband and linear phase.
0
| ( )|
j
H e
c
c
B
0
| ( )|
j
H e
c
c
0
| ( )|
j
H e
0
0
B
1
0
| ( )|
j
H e
0
0
| ( )|
j
H e
Lowpass filter (LPF) Highpass filter (HPF)
Bandpass filter (BPF)
Bandstop filter (BSF)
Allpass filter
7
H.1 Discrete time systems and filters
deal filters
he ideal Lowpass Filter (LPF) may be expressed by the frequency
response
The impulse response is calculated by the inverse DTFT as follows
This filter is not causal and therefore it is not realizable.
1, | |
( )
0, | |
c
j
c
H e
s
=
< s
1 1 1
( ) ( ) ( )
2 2 2
sin( )
,
c
c c
c
j jn jn j n j n
c
h n X e e d e d e e
jn
n
n
n
= = =
= < <
} }
8
H.1 Discrete time systems and filters
Transfer functions of real (non-ideal) filters
The principle of zeros and poles positioning for the production of the
desirable frequency response is to put
the poles near to the points of the unit circle that correspond to
the frequencies that we want to amplify (or not attenuate)
the zeros close (or exactly on) the frequencies that we want to
attenuate (make zero)
Additionally, the following restrictions should apply:
All the poles must be in the unto circle so that the filter is stable.
All the complex zeros and poles must be complex conjugate pairs
so that the coefficients of the filter in the diefference equation are
real.
1
0 1
0
1
1 1
(1 )
( )
1 (1 )
M M
k
k k
k k
N N
k
k k
k k
z z b z
H z b
a z p z
= =
= =
= =
+
[
[
9
H.1 Discrete time systems and filters
Examples of real (non-ideal) filters
Lowpass
Highpass
Bandpass
1
1
1
( )
1
z
H z
az
+
=
1
1
1
( )
1
z
H z
az
=
+
2
2
1
( )
1
z
H z
az
=
+
10
H.1 Discrete time systems and filters
FIR filter realization
An FIR filter is described by the difference equation
and a transfer function (including only zeros) of the form
This can be realized in a direct form as drawn below
This requires + 1 multiplications, additions and memory places.
0
( )
M
k
k
k
H z b z
=
=
0 0
( ) ( ) ( ) ( )
M M
k
k k
y n b x n k h k x n k
= =
= =
1
z
0
b
1
b
1
z
1
z
1
z
2
b
3
b
1 M
b
M
b
( ) x n
( ) y n
11
H.1 Discrete time systems and filters
FIR direct form realization
Simplified form
1
z
0
b
1
b
1
z
1
z
1
z
2
b
3
b
1 M
b
M
b
( ) x n
( ) y n
1
z
1
z
1
z
1
z
0
b
1
b
2
b
1 M
b
M
b
( ) y n
( ) x n
12
H.1 Discrete time systems and filters
FIR filters of ljnear phase
A filter has a linear phase when
where = 0 or /2 and constant. For an FIR filter in the interval [0,],
the linear phase condition leads to the following symmetry conditions of
the impulse response:
( ) ,
j
H e = < <
( ) ( ), / 2, 0
( ) ( ), / 2, / 2
h n h M n N
h n h M n N
= = =
= = =
V
13
H.1 Discrete time systems and filters
IIR filter realization
An IR filter is described by the difference equation
and a transfer function of the form
0
1
( )
1
M
k
k
k
N
k
k
k
b z
H z
a z
=
=
+
1 0
( ) ( ) ( )
N M
k k
k k
y n a y n k b x n k
= =
= +
14
H.1 Discrete time systems and filters
IIR filter realization
Direct Form of type I Direct Form of type II
Number of mult.: + + 1 Number of mult.: + + 1
Number of add.: + Number of add.: +
Memory places: + Memory places: max{,}
1
z
1
z
1
z
1
z
0
b
1
b
1 M
b
M
b
( ) y n ( ) x n
1
z
1
z
1
a
1 N
a
N
a
1
z
1
z
0
b
1
b
1 M
b
M
b
( ) y n ( ) x n
1
z
1
a
1 N
a
N
a
15
.2 FIR filter design with windows
. Introduction to FIR digital filter design
16
.2 FIR filter design with windows
The basic idea
The basic idea of the window method (windowing) is based on:
The selection of a non-causal ideal filter of infinite impulse
response duration.
The modification of the impulse response with a proper function
(window) so that to produce a causal and linear phase filter.
The modification of the impulse response h(n) is applied with
multiplication with a proper function w(n) which is called window.
An ideal Lowpass Filter (LPF) with cuttof frequency
c
has a frequency
response of the form
where a is a delay that does not affect the phase linearity of the filter and
is mandatory in order to convert the non-causal filter to a causal one.
1 , | |
( )
0, | |
ja
c j
d
c
e
H e
s
=
< s
17
.2 FIR filter design with windows
Impulse response of ideal filter
The impulse response of an ideal LPF may be found with an IDFT of the
previous formula, which leads to
and is symmetrical with respect to delay a.
sin[ ( )]
( )
( )
c
d
n a
h n
n a
18
.2 FIR filter design with windows
Conversion to an FIR filter
In order to produce a FIR filter, causal and with linear phase, we restrict
the impulse response with a proper window function w(n), that is
symmetrical with respect to a, so that to conserve the symmetry of the
final impulse response.
The greater the delay a is, the greater the impulse response duration is
and the better the ideal filter is approximated (this results in smaller
transition band)
( ) ( ) ( )
d
h n h n w n =
19
.2 FIR filter design with windows
Filter characteristics
The characteristics of the filters that are of interest are:
The order (length) of the filter.
The transition band width.
The attenuation in the stopband.
With the window method it is not possible to control independently the
passband and the stopband and the ripples are not uniform (equal).
=
+
=
+
10
10
1
20log
1
20log
1
p
p
p
s
s
p
20
.2 FIR filter design with windows
Classic windows (h(n) = 0, n e [0, N-1]):
( )
( )
( ) ( )
2
1
2
1
2 4
1 1
Rectangular : ( ) 1, 0 1
Hanning : ( ) 0.5 0.5cos , 0 1
Hamming : ( ) 0.54 0.46cos , 0 1
Blackman: ( ) 0.42 0.5cos 0.08cos , 0 1
n
N
n
N
n n
N N
w n n N
w n n N
w n n N
w n n N
= s s
= s s
= s s
= + s s
window
Transition
bandwidth f
Minimum stopband
attenuation
Rectangular 0.9/ 21dB
Hanning 3.1/ 44dB
Hamming 3.3/ 53dB
Blackman 5.5/ 74dB
21
.2 FIR filter design with windows
Kaiser parametric window
The parametric window Kaiser is defined as
Given
p
,
s
, R
p
, and A
s
, the length of the filter and the parameter are
calculated as:
= +
>
=
+ < <
0.4
Transition bandwidth:
2
7.95
Order (length) : 1
14.36
0.1102( 8.7), 50
Parameter
0.5842( 21) 0.07886( 21), 21 50
s p
s
s s
s s s
f
A
N
f
A A
A A A
( )
2
2
0
1
0
1 1
, 0 1
( )
( )
0,
n
N
I
n N
w n
I
(
s s
=
22
.2 FIR filter design with windows
( ) ( ) ( )
d
h n h n w n =
Windows comparison
Rectangular
Hanning
23
.2 FIR filter design with windows
Windows comparison
Hamming
Blackman
24
.2 FIR filter design with windows
Windows comparison
Kaiser = 2
Kaiser = 8
25
.2 FIR filter design with windows
Example (LPF with cutoff frequency 0.2)
Rectangular Hanning
Hamming Blackman
26
.2 FIR filter design with windows
Example (LPF with cutoff frequency 0.2)
Rectangular Hanning
Hamming Blackman
27
.2 FIR filter design with windows
Example (LPF with cutoff frequency 0.2)
Hamming, = 31 Hamming, = 63
Hamming, = 127 Hamming, = 255
28
.2 FIR filter design with windows
Example of FIR filter design with windows
A. Design a filter with the following characteristics
------------------------------------------------
Attenuation more than 50 dB is given by the Hamming window. We
calculate the transition bandwidth
The cutoff frequency is given by
The order of the filter is
The ripple of the passband is 0.039 dB (calculated only with a computer).
0.2 , 0.25dB
0.3 , 50 dB
p p
s s
R
A
= =
= =
0.3 0.2
0.05
2 2
s p
f
= = =
3.3
1 67
N N
f
(
= + =
(
(
0.25
2
s p
c
+
= =
29
.2 FIR filter design with windows
Example of FIR filter design with windows
( )
1
2
33 1
2
sin[ ( )]
sin[0.25 ( 33)]
( ) ( ) ( ) ( ) 0.54 0.46cos
( 33)
( )
N
c
n
d
N
n
n
h n h n w n w n
n
n
= = = (
30
.2 FIR filter design with windows
Example of FIR filter design with windows
B. Design the following filter with the Kaiser window
------------------------------------------------
We calculate the transition bandwidth
The cutoff frequency is
The ripple in the passband is 0.044 dB (calculated with computer).
0.2 , 0.25dB
0.3 , 50 dB
p p
s s
R
A
= =
= =
0.3 0.2
0.05
2 2
s p
f
= = =
0.25
2
s p
c
+
= =
(
= + + =
(
(
= =
7.95
Order (length) : 1 1 61
14.36
Parameter 0.1102( 8.7) 4.5512
s
s
A
N
f
A
31
.2 FIR filter design with windows
Example of FIR filter design with windows
( )
2
1
0
30 2
1
0
2
4.5512 1 1 sin[ ( )]
sin[0.25 ( 30)]
( ) ( ) ( ) ( )
( 30) (4.5512)
( )
n N
c
d
N
I n
n
h n h n w n w n
n I
n
(
= = =
32
.2 FIR filter design with windows
Example of FIR filter design with windows
C. Design the following bandpass filter
------------------------------------------------
Attenuation over 60 dB can be achieved by the Blackman or the Kaiser
window. We will design the Blackman.
The impulse response of the bandpass filter has the form
The cutoff frequencies are
1 1
2 2
0.4 , 60 dB, 0.5 , 1dB
0.7 , 1dB, 0.8 , 60 dB
s s p p
p p s s
A R
R A
= = = =
= = = =
1 1 2 2
1 2
0.45 , 0.75
2 2
s p s p
c c
+ +
= = = =
1 1
2 1
2 2
1 1
2 2
( ) ( ) ( )
sin[ ( )] sin[ ( )]
( )
( ) ( )
d
N N
c c
d
N N
h n h n w n
n n
h n
n n
=
=
33
.2 FIR filter design with windows
Example of FIR filter design with windows
The transition bandwidth is
The order of the filter is calculated as
The ripple in the passband is equal to R
p
= 0.0033 dB (calculated by a
computer).
5.5
1 111
N N
f
(
= + =
(
(
1 1 2 2
0.05
2 2
p s s p
f
= = =
34
.2 FIR filter design with windows
Example of FIR filter design with windows
( ) ( )
2 4
110 110
sin[0.75 ( 55)] sin[0.45 ( 55)]
( ) 0.42 0.5cos 0.08cos
( 55) ( 55)
n n
n n
h n
n n
(
= + (
(