Anda di halaman 1dari 14

FIR Filter

Design
Window method

Spring 2012

© Ammar Abu-Hudrouss - ١
Islamic University Gaza

Introduction

An ideal low-pass filter has a frequency response characteristics

1,   c
H ( )  
0 , c    

The impulse response of this filter

 c
  , n0
hn   
 sin  c n n0
 n

As we can see h(n) is infinite and hence we need to


truncate the higher coefficients.

Digital Signal Processing


Slide ٢

١
Paely-Weiner Theorem
For practical implementation, the filter function should be causal.
Paely – Weiner theorem summarize the conditions that should be
satisfied to guarantee causality which are :

1. The frequency response H() cannot be zero except at a


finite set of points at frequency.
2. The magnitude H() cannot be constant in any finite range of
frequencies
3. The Transition between the passband and stopband cannot be
infinitely sharp .
4. Real part and Imaginary part of H() are interdependent by
Hilbert Transform.

٣
Digital Signal Processing
Slide ٣

Practical Filter

Digital Signal Processing


Slide ٤

٢
FIR Filter

A FIR system can be described by the following difference


equation
M 1
y n    bk xn  k 
k 0

The transfer function is given by

H  z   b0  b1 z 1  b2 z  2    bM z  M 1
The impulse response is

hn   b0 , b1 , b2 ,  , bM 
Then H(z) can be expressed as
M 1
H  z    h( k ) z  k
k 0

Digital Signal Processing


Slide ٥

Type I Symmetric FIR filter

In this type, the coefficients of impulse response are


symmetric
h n   h M  1  n 
And N = M-1 is even
Example: consider
H  z   h0  h1z 1  h2 z 2  h3z 3  h4 z 4
 h5z 5  h6 z 6

But as h(0)=h(6), h(1)=h(5), h(2)=h(4)

     
H  z   h0  1  z 6  h1 z 1  z 5  h2  z 2  z 4  h3z 3

Digital Signal Processing


Slide ٦

٣
Type I Symmetric FIR filter

Or
      
H  z   z 3 h0  z 3  z 3  h1 z 2  z 2  h2 z1  z 1  h3 
Converting to DTFT

H    e  j 3 2h0  cos3   h1 cos2   h2  cos   h3

H    e  j 3 H R  
HR() is a real-valued function but it can be positive or
negative, then the phase is given by

 3 H R    0
    
 3   H R    0
Digital Signal Processing
Slide ٧

Type I Symmetric FIR filter

The result can be generalized

2h0  cosN / 2    h1 cosN / 2  1   


H    e  j  N / 2   
h2  cos N / 2  2      h N / 2  

H    e  j  N / 2  H R  

the phase is given by


 N / 2  H R    0
    
 N / 2    H R    0

Digital Signal Processing


Slide ٨

٤
Type II Symmetric FIR filter

In this type, the coefficients of impulse response are


symmetric
h n   h M  1  n 
And N =M -1 is odd
After mathematic manipulation, we get

 j  N / 2   N 1/ 2  N  1  
H    e   2h 2  n  cosn  0.5 
 n 1   
The phase is given by
  N / 2 H R    0
    
  N / 2   H R    0

Digital Signal Processing


Slide ٩

Type III Symmetric FIR filter

In this type, the coefficients of impulse response are anti-


symmetric
h n    h M  1  n 

And M =N -1 is even
After mathematic manipulation, we get

 N /2  N  
H    e  j  N   / 2 2  h  n  sin n 
 n 1  2  
The phase is given by
  N    / 2  H R    0
    
  N    / 2    H R    0

Digital Signal Processing


Slide ١٠

٥
Type IV Symmetric FIR filter

In this type, the coefficients of impulse response are anti-


symmetric
h n    h M  1  n 

And M =N -1 is even
After mathematic manipulation, we get

 j   N   / 2    N 1/ 2  N  1  
H    e 2  h 2  n  sin n  0.5 
 n 1   
The phase is given by
  N    / 2  H R    0
    
  N    / 2    H R    0

Digital Signal Processing


Slide ١١

Properties of Linear Phase FIR Filters

All the four type have constant group delay (linear phase)

d  
  N / 2
d
1. Type I FIR filters have either an even number of
zeros or no zeros at z = 1 and z = −1.

2. Type II FIR filters have an even number of zeros or


no zeros at z = 1 and an odd number of zeros at z = −1.

3. Type III FIR filters have an odd number of zeros at


z = 1 and z = −1.

4. Type IV FIR filters have an odd number of zeros at z


= 1 and either an even or odd number of zeros at z = −1.

Digital Signal Processing


Slide ١٢

٦
Properties of Linear Phase FIR Filters

•Type I and II are suitable only for lowpass filters


•Type III is suitable for designing bandpass filters
•Type IV is used mainly for highpass and bandpass

Digital Signal Processing


Slide ١٣

Window method

The magnitude responses of four ideal classical types of digital


filters are shown in Figure.

Digital Signal Processing


Slide ١٤

٧
Windows method

An ideal low-pass filter has a frequency response characteristics:

 c
, n0
 
hLP n   
 sin c n n0
 n

To get FIR filter:


hLP (n) is truncated to be defined only between n = -N and n = N
This is equivalent to multiplying h(n) by w (n). Where

1, N  n  N
w ( )  
0, otherwise

Digital Signal Processing


Slide ١٥

Rectangular window

The resultant functions is given by

hd n   wn hLP n 

The new Hd (), will not be the same as the ideal H (). Gibbs phenomena is
raised by this truncation of h(n). The overshot can be reduced by
increasing M but the oscillation increases.

Digital Signal Processing


Slide ١٦

٨
other windows

To reduce gibbs phenomena, researchers have use different


type of windows such as
1) Bartlett windows
M 1
2n
2
w n   1  ; 0  n  M 1
M 1
2) Hann Windows
1   2 n  
w n   1  cos  M  1   0  n  M 1
2   

3) Hamming windows
 2 n 
w n   0 . 54  0 . 46 cos   0  n  M 1
 M 1

Digital Signal Processing


Slide ١٧

4) Blackman window
 2 n   4 n 
w n   0 . 42  0 . 5 cos    0 .08 cos   0  n  M 1
 M  1   M 1

5) Kaiser window

6) Lanczose window

Digital Signal Processing


Slide ١٨

٩
4) Tukey window

Digital Signal Processing


Slide ١٩

Impulse response for HP, BP and BS Filers

The impulse response of the highpass, bandpass and bandstop


are derived by the same method
  c
  , n0
h n   
  sin  c n  n 0
 n
  c 2   c1
  , n0
h n   
 1 sin  n   sin  n  n 0
 n c2 c1

   c 2  c1
 , n0
h n   

 1 sin  n   sin  n  n 0
 n c1 c2

Digital Signal Processing


Slide ٢٠

١٠
Examples

Example 1: Design a bandpass filter using hamming window of


length 11. given that c1 = 0.2 and c1 = 0.6
Solution: M = 11 = 2N + 1
N =5.
substituting in h (n) for bandpass filter and w (n) for hamming
window and shifting the result by 5
0.4, n0

h n    1
 n sin 0.6n   sin 0.4n  n 0

0,0.0289,0.1633,0.2449,0.1156,0.4,0.1156,
h n    
 0.2449,0.1633,0.0289,0 
 2 n 
w n   0 . 54  0 . 46 cos   0 n9
 10 
Digital Signal Processing
Slide ٢١

Examples

Example 1:

substituting in w (n) for hamming window

 2 n 
w n   0 . 54  0 . 46 cos   0 n9
 11 

0.08, 0.1679, 0.0379, 0.6821, 0.9121,1.0, 0.9121,


wn    
0.6821,0.0379 ,0.1679, 0.08 
The result is achieved by hw(n) = w(n)h(n)
0, 0.0049, - 0.0650, - 0.1671, 0.1055, 0.4, 0.1055, - 0.1671,
hw n    
- 0.0650, 0.0049, 0 

Digital Signal Processing


Slide ٢٢

١١
Hamming Window Examples

Example 2
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 Hamming window
b) Determine the transfer function and difference equation of the
designed FIR system.
c) plot the magnitude frequency response

 c  2f c Ts  2  800 / 8000  0.2

The coefficients of the lowpass filter has been calculated before

h 0   0 .2, h (  1)  h (1)  0 .1871

Digital Signal Processing


Slide ٢٣

Hamming Window Examples

For Hamming window with M = 3


w ( n )  0 .54  0 .46 cos n  
and for n = 0 ,1, 2
wham 0  1, wham (1)  wham (2)  0.08

Then the windowed impulse response coefficients are


hw 0  0.2, hw (1)  hw (2)  0.01497
convert to z-domain
H ( z )  0.01497  0.2 z 1  0.1497 z 2
Then the difference equation is
y (n)  0.01497 x (n)  0.2 x (n  1)  0.01497 x (n  2)

Digital Signal Processing


Slide ٢٤

١٢
Hamming Window Examples

H ( )  0.01497  0.2e  j  0.01497 e  j 2

H ( )  e  j (0.01497 e j  0.2  0.01497 e  j )


H ( )  e  j (0.2  0.02994 cos  )
H ( )  0.2  0.02994 cos 

  if 0.2  0.02994 cos   0


H ( )  
    if 0.2  0.02994 cos   0

Digital Signal Processing


Slide ٢٥

Hamming Window Examples

Digital Signal Processing


Slide ٢٦

١٣
Hamming Window Examples

Example 3:
a) Design a 5-tap FIR band reject filter with a lower cutoff frequency of
2,000 Hz, an upper cutoff frequency of 2,400 Hz, and a sampling rate
of 8,000 Hz using the Hamming window method.
b) Determine the transfer function.

2N + 1 = 5 which leads that N = 2, h (n) is given by


   H   L
 , n0
h n   

  sin  H n   sin  L n  n0
 n n
Then the five samples of h (n ) shifted by 2 is equal to
h2  0.9,
h(1)  h(3)  0.01558
h(0)  h(4)  0.09355
Digital Signal Processing
Slide ٢٧

Hamming Window Examples

For Hamming window with M = 5


 n 
w( n)  0.54  0.46 cos  
 2 
and for n = 0 ,1 ,2, 3, 4
wham 2   1,
wham (1)  wham (3)  0.54,
wham ( 0)  wham ( 4)  0.08,
Then the windowed impulse response coefficients are
hw 2  0.9,
hw (1)  hw (3)  0.00841
hw (0)  hw (4)  0.00748
Convert to z-domain
H ( z )  0.00748  0.00841z 1  0.9 z 2  0.00841z 3  0.00748z 4
Digital Signal Processing
Slide ٢٨

١٤

Anda mungkin juga menyukai