# FI R Fi l t D i FI R Fi l t D i FI R Fi l t er Desi gn FI R Fi l t er Desi gn

1 Fi ni t e I mpul se Response Fi l t er For mat 1. Fi ni t e I mpul se Response Fi l t er For mat
2. Four i er Tr ansf or m Desi gn
3. Wi ndow Met hod
FI R Fi l t er For mat ( 1) FI R Fi l t er For mat ( 1)
 Input-output relationship
K

b FIR filt ffi i t
( ) ( ) ( ) ( )
0 1
0
( ) 1
K
i K
i
y n b x n i b x n b x n b x n K
=
= ÷ = + ÷ + + ÷
¯

• b
i
: FIR filter coefficients
• K+ 1: FIR filter length
 Transfer Function
– ( ) ( ) ( ) ( )
1
0 1
K
K
Y z b X z b z X z b z X z
÷ ÷
= + + + 
( ) Y

( )
( )
( )
1
0 1
K
K
Y z
H z b b z b z
X z
÷ ÷
= = + + + 
Ch7. Finite Impulse Response Filter Design 2
FI R Fi l t er For mat ( 2) FI R Fi l t er For mat ( 2)
Ex 7.1 Given the following FIR filter: Ex 7.1 Given the following FIR filter:
Y(n)=0. 1x(n)+0. 25x(n- 1)+0. 2x(n- 2)
Determine the transfer function filter length nonzero Determine the transfer function, filter length, nonzero
coefficients, and impulse response.
 Properties from FIR filter format  Properties from FIR filter format
– All the poles are at the origin  STABLE
– Operations include p
• Multiplying the filter inputs by the corresponding filter coefficients
and accumulating them
Ch7. Finite Impulse Response Filter Design 3
Four i er Tr ansf or m Desi gn
I deal Low Pass Fi l t er ( 1) I deal Low Pass Fi l t er ( 1)
 Frequency Response

( )
1,
0,
c
j
H e
t
O
¦ O s O
¦
=
´
O s O s
¦
¹
0,
c
t O s O s
¦
¹
Ch7. Finite Impulse Response Filter Design 4
Four i er Tr ansf or m Desi gn
I deal Low Pass Fi l t er ( 1)
 Periodicity of the ideal lowpass frequency
I deal Low Pass Fi l t er ( 1)
response
Ch7. Finite Impulse Response Filter Design 5
Four i er Tr ansf or m Desi gn
I mpul se Response ( 1) I mpul se Response ( 1)
 Discrete-time Fourier Transform

| | ( )
1
2
j j n
x n X e e d
t
t
t
O O
÷
·
= O
í
– ( ) | |
j j n
n
X e x n e
·
O ÷ O
=÷·
=
¯
 Impulse response of the ideal lowpass filter
– | | ( )
1 1
for
2 2
c
j j n j n
h n H e e d e d n
t
O
O O O
= O = O ÷· < < ·
í í
| | ( )
2 2
c
t
t t
÷ ÷O
í í
( )
, 0
c
n
t
O
¦
=
¦
¦
– ( )
( )
sin
, 0
c
h n
n
n
n
t
t
¦
=
´
O
¦
=
¦
¹
Ch7. Finite Impulse Response Filter Design 6
Four i er Tr ansf or m Desi gn
I mpul se Response ( 2) I mpul se Response ( 2)
– Plot
– Theoretically h(n) exists for -∞<n<∞ and is
symmetrical about n=0. (h(n) = h(-n))
– As n increases, |h(n)| decreases. As n increases, |h(n)| decreases.
Ch7. Finite Impulse Response Filter Design 7
Four i er Tr ansf or m Desi gn
Causal FI R Fi l t er ( 1) Causal FI R Fi l t er ( 1)
 Infinite length of filter coefficients
– Truncated for FIR filter

N l
( ) ( ) ( ) ( ) ( ) ( )
1
1 0 1
M M
H z h M z h z h h z h M z
÷ ÷
= + + + + + +  
Noncausal
 Causal FIR Filter
Delay the truncated impulse response h(n) by M – Delay the truncated impulse response h(n) by M
samples

( )
1 2
0 1 2
M
M
H z b b z b z
÷ ÷
= + + + 
( )
for 0,1, , 2
n
b h n M n M = ÷ = 
Ch7. Finite Impulse Response Filter Design 8
Four i er Tr ansf or m Desi gn
Causal FI R Fi l t er ( 2) Causal FI R Fi l t er ( 2)
Ch7. Finite Impulse Response Filter Design 9
Four i er Tr ansf or m Desi gn
Ex ampl e 7 2 ( 1) Ex ampl e 7. 2 ( 1)
a. Calculate the filter coefficients for a 3-tap FIR
lowpass filter with a cutoff frequency of 800 Hz
and a sampling rate of 8,000 Hz using the
Fourier transform method Fourier transform method.
b. Determine the transfer function and difference
equation of the designed FIR system equation of the designed FIR system
c. Compute and plot the magnitude frequency
response for Ω = 0, π/4, π/2, 3π/4, and π response for Ω 0, π/4, π/2, 3π/4, and π
Ch7. Finite Impulse Response Filter Design 10
Four i er Tr ansf or m Desi gn
Ex ampl e 7 2 ( 2) Ex ampl e 7. 2 ( 2)
Ch7. Finite Impulse Response Filter Design 11
Four i er Tr ansf or m Desi gn
Ex ampl e 7 2 ( 3) Ex ampl e 7. 2 ( 3)
Ch7. Finite Impulse Response Filter Design 12
Four i er Tr ansf or m Desi gn
Ex ampl e 7 2 ( 4) Ex ampl e 7. 2 ( 4)
Ch7. Finite Impulse Response Filter Design 13
Four i er Tr ansf or m Desi gn
Obser v at i ons Obser v at i ons
 Gibbs effect
– The oscillations exhibited in the passband (main lobe)
and stop band (side lobes) of the magnitude frequency
response response
– Originates from the abrupt truncation of the infinite
impulse response
– Window functions will be used to remedy the problem
 A large number of the filter coefficients
Sh ll ff h t i ti f th t iti b d – Sharp roll-off characteristics of the transition band
– Increased time delay and increased computational
complexity for implementing the designed FIR filter. p y p g g
 The phase response is linear in the passband
– Symmetrical coefficients (odd number)
Ch7. Finite Impulse Response Filter Design 14
Ch7. Finite Impulse Response Filter Design 15
Ch7. Finite Impulse Response Filter Design 16
Ch7. Finite Impulse Response Filter Design 17
Wi ndow Met hod
I nt r oduct i on I nt r oduct i on
 Fourier transform design with window functions
– Remedy the undesirable Gibbs oscillations in the
passband and stopband of the designed FIR filter
Gradually weight the designed FIR coefficients down to – Gradually weight the designed FIR coefficients down to
zeros at both ends for the range of -M≤n≤M
 FIR filter coefficients
– h
w
(n) = h(n)w(n)
• w(n): window function
• h(n): ideal impulse response
Ch7. Finite Impulse Response Filter Design 18
Wi ndow Met hod
Wi ndow f unct i on ( 1) Wi ndow f unct i on ( 1)
 Rectangular window
( ) 1 M≤ ≤M (7 15) – w
rec
(n) = 1, -M≤n≤M (7.15)
 Triangular (Bartlett) window
– (7.16)
 Hanning window
( )
1 ,
tri
n
w n M n M
M
= ÷ ÷ s s
Hanning window
– (7.17)
 Hamming window
( ) 0.5 0.5cos ,
han
n
w n M n M
M
t
= + ÷ s s
| |
|
\ .
 Hamming window
– (7.18)
( ) 0.54 0.46cos ,
ham
n
w n M n M
M
t
= + ÷ s s
| |
|
\ .
 Blackman window
– (7.19) ( )
2
0.42 0.5 cos 0.08 cos ,
black
n n
w n M n M
M M
t t
= + + ÷ s s
| | | |
| |
\ . \ .
Ch7. Finite Impulse Response Filter Design 19
M M
\ . \ .
Wi ndow Met hod
Wi ndow f unct i on ( 2) Wi ndow f unct i on ( 2)
Ch7. Finite Impulse Response Filter Design 20
Wi ndow Met hod
Ex ampl e 7 4 ( 1) Ex ampl e 7. 4 ( 1)
 Given the calculated filter coefficients
h( 0) = 0. 25, h( - 1) = h( 1) = 0. 22508, h( - 2) = h( 2) = 0. 15915,
h( - 3) = h( 3) = 0. 007503 ( ) ( )
a. Apply the Hamming window function to obtain
windowed coefficients h
w
(n).
b Plot the impulse response h(n) and windowed impulse b. Plot the impulse response h(n) and windowed impulse
response h
w
(n).
Ch7. Finite Impulse Response Filter Design 21
Wi ndow Met hod
Ex ampl e 7 4 ( 2) Ex ampl e 7. 4 ( 2)
Ch7. Finite Impulse Response Filter Design 22
Wi ndow Met hod
Desi gn pr ocedur e Desi gn pr ocedur e
1. Obtain the FIR filter coefficients h(n) via the
Fourier transform method (Table 7.1)
2. Multiply the generated FIR filter coefficients by
h l d i d the selected window sequence

 where w(n) is chosen to be one of the window functions listed in
( ) ( ) ( )
, , , 0,1, , ,
w
h n h n w n n M M = = ÷  
where w(n) is chosen to be one of the window functions listed in
eqs. (7.15) to (7.19) in page 22.
3. Delay the windowed impulse sequence h
w
(n) by
M l t t th i d d FIR filt M samples to get the windowed FIR filter
coefficients:
( )
, 0, 1, , 2
n w
b h n M n M = ÷ = 
Ch7. Finite Impulse Response Filter Design 23
Wi ndow Met hod
Ex ampl e 7 5 ( 1) Ex ampl e 7. 5 ( 1)
a. Design a 3-tap FIR lowpass filter with a cutoff
frequency of 800 Hz and a sampling rate of 8,000
Hz using the Hamming window function.
b. Determine the transfer function and difference
equation of the designed FIR system equation of the designed FIR system.
C t d l t th it d f c. Compute and plot the magnitude frequency
response for Ω=0, π/4, π/2, 3π/4, and π radians.
Ch7. Finite Impulse Response Filter Design 24
Wi ndow Met hod
Ex ampl e 7 5 ( 2) Ex ampl e 7. 5 ( 2)
Ch7. Finite Impulse Response Filter Design 25
Wi ndow Met hod
Ex ampl e 7 5 ( 3) Ex ampl e 7. 5 ( 3)
Ch7. Finite Impulse Response Filter Design 26
Wi ndow Met hod
E l 7 6 Ex ampl e 7. 6
a. Determine a 5-tap FIR band reject filter with a
lower cutoff frequency of 2,000 Hz, an upper
frequency of 2,400 Hz, and a sampling rate of
8 000 Hz using the Hamming window function 8,000 Hz using the Hamming window function.
b Determine the transfer function b. Determine the transfer function.
Ch7. Finite Impulse Response Filter Design 27
Wi ndow Met hod
Compar i son of magni t ude f r equency r esponses Compar i son of magni t ude f r equency r esponses
Ch7. Finite Impulse Response Filter Design 28
Wi ndow Met hod
How t o choose a w i ndow ? ( 1) How t o choose a w i ndow ? ( 1)
 Specifications:
– Fig. 7.14
– Table 7.7 FIR filter length estimation
 ; normalized transition width
stop pass
s
f f
f
f
÷
A =
 Filter length for Hamming window: N=3.3/Δf
 Passband ripple
( )
dB 20l 1 o o

 Stopband attenuation
( )
10
dB = 20log 1
p p
o o +
( )
dB 20log o o

 Cut-off frequency
– f = (f + f )/2
( )
10
dB = 20log
s s
o o ÷
Ch7. Finite Impulse Response Filter Design 29
– f
c
= (f
pass
+ f
stop
)/2
Wi ndow Met hod
H t h i d ? ( 2) How t o choose a w i ndow ? ( 2)
Ch7. Finite Impulse Response Filter Design 30
Wi ndow Met hod
How t o choose a w i ndow ? ( 3) How t o choose a w i ndow ? ( 3)
Ch7. Finite Impulse Response Filter Design 31
Wi ndow Met hod
Ex ampl e ( 1) Ex ampl e ( 1)
Ex. A bandpass filter must be designed according to
the following specifications:
passband 150 – 250 Hz
transition width 50 Hz
passband ripple 0.1 dB
stopband attenuation 60 dB
sampling frequency 1 kHz
32
Wi ndow Met hod
Ex ampl e ( 2)
a) Specify the desired frequency response of filter,
(H ( ))
Ex ampl e ( 2)
(H
D
(ω)).
b) Obtain h
D
[n].
c) Find all the window functions which satisfy the given c) Find all the window functions which satisfy the given
specifications from the following table.
d) Find the required value for N to use each window
f ti f th lt f ( ) function from the results of (c).
e) Mention the window function having the smallest value
of N, and find h(0) for the window function. , ( )
Ch7. Finite Impulse Response Filter Design 33

FIR Filter Format (1)
 Input-output relationship
– y ( n) 

 b x  n  i   b x  n   b x  n  1    b x  n  K 
i 0 1 K i 0

K

• bi: FIR filter coefficients filt ffi i t • K+1: FIR filter length

 Transfer Function
1 K – Y  z   b0 X  z   b1 z X  z     bK z X  z 

– H z 

Y z X z

 b0  b1 z    bK z

1

K

Ch7. Finite Impulse Response Filter Design

2

FIR Filter Format (2)
Ex 7.1 Given the following FIR filter:
Y(n)=0.1x(n)+0.25x(n-1)+0.2x(n-2) Determine the transfer function, filter length, nonzero function length coefficients, and impulse response.

 Properties from FIR filter format
– All the poles are at the origin  STABLE p – Operations include
• Multiplying the filter inputs by the corresponding filter coefficients and accumulating them

Ch7. Finite Impulse Response Filter Design

3

c      j Ch7. Finite Impulse Response Filter Design 4 .Fourier Transform Design Ideal Low Pass Filter (1)  Frequency Response 1.   c  – H e    0.

Fourier Transform Design Ideal Low Pass Filter (1)  Periodicity of the ideal lowpass frequency response Ch7. Finite Impulse Response Filter Design 5 .

n  0  n  Ch7.Fourier Transform Design Impulse Response (1)  Discrete-time Fourier Transform 1 x  n  – 2     X  e j  e jn d   jn – X e j    x  n e n   Impulse response of the ideal lowpass filter 1 – h  n  2 1 H  e j  e jn d    2   c c  e jn d  for    n    c . n0    – h  n    sin  c n  . Finite Impulse Response Filter Design 6 .

Ch7. Finite Impulse Response Filter Design 7 .Fourier Transform Design Impulse Response (2) – Plot – Theoretically h(n) exists for -∞<n<∞ and is symmetrical about n=0. |h(n)| decreases. (h(n) = h(-n)) – As n increases.

 .Fourier Transform Design Causal FIR Filter (1)  Infinite length of filter coefficients – Truncated for FIR filter – H  z   h  M  z M    h 1 z  h  0   h 1 z 1    h  M  z  M N Noncausal l  Causal FIR Filter – Delay the truncated impulse response h(n) by M samples – H  z   b0  b1 z 1    b2 M z 2 M bn  h  n  M  for n  0. Finite Impulse Response Filter Design 8 .1. 2M Ch7.

Fourier Transform Design Causal FIR Filter (2) Ch7. Finite Impulse Response Filter Design 9 .

π/2. Compute and plot the magnitude frequency response for Ω = 0. and π radians. b. π/4.000 Hz using the Fourier transform method method.Fourier Transform Design Example 7 2 (1) 7. Determine the transfer function and difference equation of the designed FIR system c. Calculate the filter coefficients for a 3-tap FIR lowpass filter with a cutoff frequency of 800 Hz and a sampling rate of 8. Finite Impulse Response Filter Design 10 . 3π/4.2 a. Ch7.

Finite Impulse Response Filter Design 11 .2 Ch7.Fourier Transform Design Example 7 2 (2) 7.

Finite Impulse Response Filter Design 12 .Fourier Transform Design Example 7 2 (3) 7.2 Ch7.

Fourier Transform Design Example 7 2 (4) 7.2 Ch7. Finite Impulse Response Filter Design 13 .

Finite Impulse Response Filter Design 14 .Fourier Transform Design Observations  Gibbs effect – The oscillations exhibited in the passband (main lobe) and stop band (side lobes) of the magnitude frequency response – Originates from the abrupt truncation of the infinite impulse response – Window functions will be used to remedy the problem  A large number of the filter coefficients – Sh Sharp roll-off characteristics of th transition band ll ff h t i ti f the t iti b d – Increased time delay and increased computational complexity for implementing the designed FIR filter. p y p g g  The phase response is linear in the passband – Symmetrical coefficients (odd number) Ch7.

Ch7. Finite Impulse Response Filter Design 15 .

Ch7. Finite Impulse Response Filter Design 16 .

Finite Impulse Response Filter Design 17 .Ch7.

Finite Impulse Response Filter Design 18 .Window Method Introduction  Fourier transform design with window functions – Remedy the undesirable Gibbs oscillations in the passband and stopband of the designed FIR filter – Gradually weight the designed FIR coefficients down to zeros at both ends for the range of -M≤n≤M  FIR filter coefficients – hw(n) = h(n)w(n) • w(n): window function • h(n): ideal impulse response Ch7.

46 cos   n M  n M (7.15) (7 15)  Triangular (Bartlett) window – wtri  n   1  n M .19) 19 Ch7.16)  Hanning window – whan  n   0.5 cos   Hamming window  n M  .5  0.42  0. Finite Impulse Response Filter Design .5 cos  (7.  M  n  M    2 n   0.08 cos   . -M≤n≤M (n) 1 M≤ ≤M (7.Window Method Window function (1)  Rectangular window – wrec( ) = 1.17) – wham  n   0.  M  n  M   .  M  n  M   M  (7.18)  Blackman window – wblack  n   0. M n M (7.54  0.

Window Method Window function (2) Ch7. Finite Impulse Response Filter Design 20 .

25. Apply the Hamming window function to obtain windowed coefficients hw(n). Finite Impulse Response Filter Design 21 .15915.Window Method Example 7 4 (1) 7. Ch7.007503 ( ) ( ) a. b.22508. b Plot the impulse response h(n) and windowed impulse response hw(n). h(-2)=h(2)=0.4  Given the calculated filter coefficients h(0)=0. h(-1)=h(1)=0. h(-3)=h(3)=0.

4 Ch7.Window Method Example 7 4 (2) 7. Finite Impulse Response Filter Design 22 .

3. 1.19) in page 22. M .  . 2 M Ch7. Obtain the FIR filter coefficients h(n) via the Fourier transform method (Table 7. Finite Impulse Response Filter Design 23 .  .Window Method Design procedure 1. 2. Delay the windowed impulse sequence hw(n) by M samples t get the windowed FIR filter l to t th i d d filt coefficients: bn  hw  n  M  .1.1) Multiply the generated FIR filter coefficients by the selected window sequence h l d i d n   M . 0.  . (7. n  0.15) to (7.  hw  n   h  n  w  n  .  where w(n) is chosen to be one of the window functions listed in eqs.

Ch7. Finite Impulse Response Filter Design 24 . b.000 Hz using the Hamming window function. Determine the transfer function and difference equation of the designed FIR system system. C Compute and plot th magnitude frequency t d l t the it d f response for Ω=0.Window Method Example 7 5 (1) 7. c. and π radians. Design a 3-tap FIR lowpass filter with a cutoff frequency of 800 Hz and a sampling rate of 8. π/4.5 a. π/2. 3π/4.

5 Ch7. Finite Impulse Response Filter Design 25 .Window Method Example 7 5 (2) 7.

5 Ch7. Finite Impulse Response Filter Design 26 .Window Method Example 7 5 (3) 7.

6 E l 76 a. function b. Ch7.Window Method Example 7.000 8 000 Hz using the Hamming window function. Determine a 5-tap FIR band reject filter with a lower cutoff frequency of 2. an upper frequency of 2.400 Hz. Finite Impulse Response Filter Design 27 . and a sampling rate of 8.000 Hz. b Determine the transfer function function.

Comparison of magnitude frequency responses Window Method Ch7. Finite Impulse Response Filter Design 28 .

3/Δf  Passband ripple 20log –  p dB = 20l 10 1   p  –  s dB =  20log10  s   Stopband attenuation  Cut-off frequency – fc = (fpass + fstop)/2 Ch7.How to choose a window? (1)  Specifications: – Fig. Finite Impulse Response Filter Design 29 . normalized transition width  Filter length for Hamming window: N=3.7 FIR filter length estimation Window Method  f  f stop  f pass fs . 7.14 – Table 7.

How t choose a window? (2) H to h i d ? Window Method Ch7. Finite Impulse Response Filter Design 30 .

How to choose a window? (3) Window Method Ch7. Finite Impulse Response Filter Design 31 .

1 dB stopband attenuation 60 dB sampling frequency 1 kHz 32 . A bandpass filter must be designed according to the following specifications: passband 150 – 250 Hz transition width 50 Hz passband ripple 0.Window Method Example (1) Ex.

d) Find the required value for N to use each window function from the results of (c). and find h(0) for the window function.Window Method Example (2) a) Specify the desired frequency response of filter. f ti f th lt f ( ) e) Mention the window function having the smallest value of N. (HD( )) (ω)). ( ) Ch7. Finite Impulse Response Filter Design 33 . b) Obtain hD[n]. c) Find all the window functions which satisfy the given specifications from the following table. .