Finite Impulse Response (FIR) Filter Design
Finite Impulse Response (FIR) Filter Design
2/74
2. Linear phase response
Phase response of FIR filter
N
H (e jT
) h(k )e jkT (1)
k 0
= H (e jT ) e j ( )
3/74
– Condition of linear phase response
( ) (3)
( ) (4)
4/74
• If a filter satisfies the condition given in equation (3)
– From equation (1) and (2)
( )
N
h(n) sin nT
= tan 1 n0
N
h(n) cos nT
n0
thus
N
h(n) sin nT
tan = n 0
N
h(n) cos nT
n 0
5/74
N
h(n) sin( nT ) 0
n0
NT / 2
6/74
• When the condition given in equation (4) only
– The filter will have a constant group delay only
– It is represented in Fig 7.1 (c),(d)
h ( n ) h( N n )
NT / 2
/2
7/74
Center of symmetry
Fig. 7-1.
8/74
Table 7.1 A summary of the key point about the four types of linear phase FIR filters
9/74
Example 7-1
(1) Symmetric impulse response for linear phase response.
No phase distortion
h(n) h( N n) or h(n) h( N n)
10/74
• Frequency response H ( )
H ( ) H (e jT )
10
= h(k )e jkT
k 0
=h(0) h(1)e jT h(2)e j 2T h(3)e j 3T h(4)e j 4T h(5)e j 5T
+h(6)e j 6T h(7)e j 7T h(8)e j 8T h(9)e j 9T h(10)e j10T
=e j 5T [h(0)e j 5T h(1)e j 4T h(2)e j 3T h(3)e j 2T h(4)e jT h(5)
+h(6)e jT h(7)e j 2T h(8)e j 3T h(9)e j 4T h(10)e j 5T ]
H ( )=e j 5T [h(0)(e j 5T e j 5T ) h(1)(e j 4T e j 4T ) h(2)(e j 3T e j 3T )
h(3)(e j 2T e j 2T ) h(4)(e jT e jT ) h(5)]
e j 5T [2h(0) cos(5T ) 2h(1) cos(4T ) 2 h(2) cos(3T )
2h(3) cos(2T ) 2h(4) cos(T ) h(5)]
5
H ( )= a(k ) cos(kT )e j 5T H ( ) e j ( )
k 0
5
where H ( ) = a( k ) cos( kT )
k 0
( ) 5T
11/74
(3) N 9
h(0) h(9)
h(1) h(8)
h(2) h(7)
h(3) h(6)
h(4) h(5)
H ( )=e j 9T /2 [h(0)(e j 9T e j 9T ) h(1)(e j 7T e j 7T ) h(2)(e j 5T e j 3T )
h(3)(e j 3T e j 3T ) h(4)(e jT e jT )]
e j 9T /2 [2h(0) cos(9T / 2) 2h(1) cos(7T / 2) 2 h(2) cos(5T / 2)
2h(3) cos(3T / 2) 2h(4) cos(T / 2)]
= H ( ) e j ( )
5
where H ( )= b(k ) cos[ (k 1/ 2)T ]
k 1
( ) (9 / 2)T
N 1 N 1
b( k ) 2h( k ), k 1, 2, ,
2 2
12/74
3. Zero distribution of FIR filters
Transfer function for FIR filter
N
H ( z ) h( k ) z k
k 0
N
H ( z ) h( N k ) z k
k 0
0
= h( k ) z k z N
k N
=z N H ( z 1 )
13/74
Four types of linear phase FIR filters
– H ( z ) have zero at z z0
z0 re j
z0 1 r 1e j
( z0* ) 1 r 1e j
14/74
– If zero on unit circle
r 1, 1/ r 1
z0 e j
z0 1 e j z0*
(1 e j z 1 )(1 e j z 1 )
(1 rz 1 )(1 r 1 z 1 )
– If zeros on z 1
(1 z 1 )
15/74
Necessary
zero
Fig. 7-2.
16/74
4. FIR filter specifications
Filter specifications
p peak passband deviation (or ripples)
r stopband deviation
s sampling frequency
17/74
ILPF
Satisfies spec’s
Fig. 7-3.
18/74
Characterization of FIR filter
N
y ( n ) h( k ) x ( n k )
k 0
N
H ( z ) h( k ) z k
k 0
19/74
5. Window method
FIR filter
– Frequency response of filter H I ( )
– Corresponding impulse response hI (n)
1
hI (n)
2 H
I ( )e jn d
2 f c sin(nc )
, n 0, - n
= nc
2 fc , n0
20/74
Fig. 7-4.
21/74
Truncation to FIR
h(n) hI (n) w(n) "windowing"
H(e j ) 1
2 H I (e j ) W(e j )
1
2
H I (e j )W(e j ( ) )d
– Rectangular Window
1 , n 0,1,..., N
w(n)
0 , elsewhere
22/74
Fig. 7-5.
23/74
Fig. 7-6.
24/74
Fig. 7-7.
25/74
Table 7.2 summary of ideal impulse responses for standard frequency selective filters
hI (n)
hI (n) hI (n)
f c , f1 and f 2 are the normalized passband or stopband edge frequencies; N is the length of
filter
26/74
Common window function types
– Hamming window
F 3.32 / N
27/74
– Characteristics of common window functions
Fig. 7-8.
28/74
Table 7.3 summary of important features of common window functions
29/74
– Kaiser window
2
I0 1 2 n N
N
w n , 0n N
I0
0 , elsewhere
2
L
( x / 2) k
I 0 ( x) 1
k 1 k !
where typically L 25
30/74
• Kaiser Formulas – for LPF design
A 20log10 ( )
min( p , s )
0, if A 21dB
0.5842( A 21)0.4 0.07886( A 21), if 21dB A 50dB
0.1102( A 8.7) if A 50dB
A 7.95
N
14.36F
31/74
Example 7-2
– Obtain coefficients of FIR lowpass using hamming
window
Passband cutoff frequency f p : 1.5kHz
Transition width f : 0.5kHz
Stopband attenuation 50dB
Sampling frequency f s : 8kHz
• Lowpass filter
sin nc
2 f c , n0
hI n nc
2 fc , n0
F f / f s 0.5 / 8 0.0625
N
c2 f sin ( n )c
2 , N
n , 0 n N
N 2
hI (n) (n )c
2
N
2 fc , n
2
33/74
2 0.21875
n 0 : hI (0) sin(27 2 0.21875)
27 2 0.21875
0.00655
w(0) 0.54 0.46 cos(0) 0.08
h(0) hI (0) w(0) 0.00052398
2 0.21875
n 1 : hI (1) sin(26 2 0.21875)
26 2 0.21875
0.011311
w(1) 0.54 0.46 cos(2 / 54)
0.08311
h(1) hI (1) w(1) 0.00094054
34/74
2 0.21875
n 2 : hI (2) sin(25 2 0.21875)
25 2 0.21875
0.00248397
w(2) 0.54 0.46 cos(2 2 / 54)
0.092399
h(2) hI (2) w(2) 0.000229516
2 0.21875
n 26 : hI (26) sin( 1 2 0.21875)
1 2 0.21875
0.312936
35/74
w(26) 0.54 0.46 cos(2 26 / 54)
0.9968896
h(26) hI (26) w(26) 0.3112226
n 27 : hI (27) 2 f c 2 0.21875
0.4375
w(27) 0.54 0.46 cos(2 27 / 54)
1
h(27) hI (27) w(27) 0.4375
36/74
Fig. 7-9.
37/74
Example 7-3
– Obtain coefficients using Kaiser or Blackman window
Stopband attenuation : 40dB
passband attenuation : 0.01dB
Transition region f : 500 Hz
Sampling frequency f s : 10kHz
Passband cutoff frequency f p : 1200 Hz
r p 0.00115
38/74
• Using Kaiser window
N
2 f c sin n c
hI (n) 2
, 0n N
N
n c
2
39/74
h(n) hI (n) w(n)
2 0.145
n 0 : hI (0) sin(35.5 2 0.145)
35.5 2 0.145
0.00717
2n N
2
I0 1
N I (0)
w(0) 0 0.023
I0 ( ) I 0 (5.52)
40/74
2 0.145
n 1: hI (1) sin(34.5 2 0.145)
34.5 2 0.145
0.0001449
69
2
I 0 5.52 1
71 I (1.3)
w(1) 0 0.0337975
I 0 (5.52) I 0 (5.52)
41/74
2 0.145
n 2 : hI (2) sin( 34.5 2 0.145)
33.5 2 0.145
0.007415484
69
2
I 0 5.52 1
71 I (1.8266)
w(2) 0 0.04657999
I 0 (5.52) I 0 (5.52)
42/74
2 0.145
n 35 : hI (35) sin(0.5 2 0.145)
0.5 2 0.145
0.280073974
1
2
I 0 5.52 1
71 I (5.51945)
w(35) 0 0.999503146
I 0 (5.52) I 0 (5.52)
43/74
Fig. 7-10.
44/74
Summary of window method
1. Specify the ‘ideal’ or desired frequency response of filter, H I ( )
2. Obtain the impulse response, hI (n), of the desired filter by
evaluating the inverse Fourier transform
3. Select a window function that satisfies the passband or
attenuation specifications and then determine the number of filter
coefficients
4. Obtain values of w(n) for the chosen window function and the
values of the actual FIR coefficients, h(n), by multiplying
hI (n) by w( n)
h(n) hI (n) w(n)
45/74
Advantages and disadvantages
– Simplicity
– Lack of flexibility
– The passband and stopband edge frequencies cannot be
precisely specified
– For a given window(except the Kaiser), the maximum
ripple amplitude in filter response is fixed regardless of
how large we make N
46/74
6. The optimal method
Basic concepts
– Equiripple passband and stopband
E ( ) W ( )[ H I ( ) H ( )]
min[max E ( ) ]
47/74
Practical response
Ideal response
Fig. 7-11.
48/74
Fig. 7-12.
49/74
– Optimal method involves the following steps
• Use the Remez exchange algorithm to find the optimum set of
extremal frequencies
• Determine the frequency response using the extremal
frequencies
• Obtain the impulse response coefficients
50/74
Optimal FIR filer design
N
H ( z ) h( k ) z k
k 0
where h( n) h( n)
N /2 N /2
H ( ) h(0) 2h( k ) cos kT a( k ) cos kT
k 1 k 0
1 , 0 f fp
H1 f
0 , f r f 0.5
1
, 0 f fp This weighting function permits different peak
W f k
1 error in the two band
, f r f 0.5
51/74
N /2
H ( f ) H (e j 2 f
) a(k ) cos k 2 f
k 0
E ( f ) W ( f )[ H ( f ) H I ( f )]
where f are 0, f p and f r , 0.5
min[max E ( f ) ]
Find a (k )
52/74
– Alternation theorem
Let F 0, f p f r , 0.5
If E ( f ) has equiripple inside bands F and more than m+2 extremal point
then H ( f ) HI ( f )
E ( fi ) E ( f i 1 ) e, i 0,1, , l 1
f 0 f1 f l (l m 1)
where e max E( f )
f 0, f p & f r ,0.5
53/74
• From equation (7-33) and (7-34)
W ( f i ) H ( f i ) H I ( f i ) ( 1) i e, i 0,1, 2, , m 1
• Matrix form
54/74
– Summary
Step 1. Select filter length as 2m+1
Step 2. Select m+2 f i point in F
Step 3. Calculate a(k ) and e using equation (7)
Step 4. Calculate E ( f ) using equation (5). If E( f ) e in some
of f , go to step 5, otherwise go to step 6
Step 5. Determine m local minma or maxma points
Step 6. Calculate h(0) a(0), h(k ) a(k ) / 2 when k 1, 2, , m
N
where H ( z ) h(k ) z
k 0
k
55/74
– Example 7-4
• Specification of desired filter
– Ideal low pass filter
– Filter length : 3
– pT 1[rad], rT 1.2[rad]
– k 2
• Normalized frequency
f 0 0.5 / 2 , f1 1/ 2 , f 2 1.2 / 2
56/74
• From H I ( f 0 ) H I ( f1 ) 1, H I ( f 2 ) 0, W ( f 0 ) W ( f1 ) 1/ 2 and W ( f 2 ) 1
1 0.8776 2 a(0) 1
1 0.5403 2 a(1) 1
1 0.3624 1 e 0
• Cutoff frequency
1 1.2
f 0 f1 f 2 0.5
2 2
58/74
Fig. 7-13.
59/74
Optimization using MATLAB
– Park-McClellan
– Remez
b remez(N,F, M )
b remez(N,F, M, WT )
60/74
– Example 7-5
• Specification of desired filter
– Band pass region : 0 – 1000Hz
– Transition region : 500Hz
– Filter length : 45
– Sampling frequency : 10,000Hz
62/74
Fig.7-14.
63/74
– Example 7-6
• Specification of desired filter
– Band pass region : 3kHz – 4kHz
– Transition region : 500Hz
– Pass band ripple : 1dB
– Rejection region : 25dB
– Sampling frequency : 20kHz
64/74
• Transform dB to normal value
Ap
10 20 1 Ar
p Ap r 10 20
10 20
1
65/74
Table 7-5.
66/74
Fig. 7-15.
67/74
7. Frequency sampling method
68/74
– For linear phase filters (for N even)
N2 1
1
h( n ) 2 H (k ) cos[2 k (n ) / N ] H (0)
N k 1
where ( N 1) / 2
– For N odd
• Upper limit in summation is ( N 1) / 2
69/74
Fig. 7-16.
70/74
– Example 7-7
1 N /21
(1) Show the h ( n )
N k 1
2 H ( k ) cos[2 k ( n ) / N ] H (0)
Fig. 7-17.
72/74
• Samples of magnitude in frequency
1, k 0,1, 2
H (k )
0, k 3, 4
Table 7-6.
73/74
8. Comparison of most commonly
method
– Window method
• The easiest, but lacks flexibility especially when passband and
stopband ripples are different
– Frequency sampling method
• Well suited to recursive implementation of FIR filters
– Optimal method
• Most powerful and flexible
74/74