You are on page 1of 43

FIR Filters

FIR filters have transfer functions of the following


form:

H ( z )  b0  b1 z 1    bm z  m .

The impulse response is

h[n]  b0 [n]  b1 [n  1]    bm [n  m].


This impulse response function is finite in duration.
Such filters are referred to as finite impulse
response or FIR filters.

Any filter whose transfer function does not have a


denominator will have an impulse response that is
finite in duration.

There are no (realizable) analog filters with a finite


impulse response, or (stable) analog filters whose
transfer function does not have a denominator.
So why bother with FIR filters?

FIR filters do have one interesting property: unlike


IIR filters, they can have linear phase response.

H(ejw)
Example: Find the phase response of

1
H ( z )  (1  z ).
1
2

Solution: We let z=ejw, and find the angle of the


complex value.

jw  jw
H (e )  (1  e 1
2 ).
w ejw H(ejw) H(ejw)

0 1 1
2 (1  1) 0°

p/2 j
1
2 (1  j ) -45°

p -1 1
2 (1  1) *
-90°

*The phase must be evaluated as a limit here.


Frequency Response
0.25

0
 H(e ), x p
jw

-0.25

-0.5

-0.75
0 0.25 0.5 0.75 1
w, x p
Frequency Response
0.25

0
 H(e ), x p
jw

-0.25

-0.5

-0.75
0 0.25 0.5 0.75 1
w, x p
FIR filters do not always have linear phase. As an
example,

1
H ( z)   z .
1
2

jw  jw
H (e )   e 1
2 .
w ejw H(ejw) H(ejw)

0 1 1
2 1 0°

p/2 j
1
2 j -63°

p -1 1
2 1 -180°
Frequency Response
0.25

-0.25
 H(e w), x p

-0.5
j

-0.75

-1

-1.25
0 0.25 0.5 0.75 1
w, x p
Now, let us find the criteria for an FIR filter to have
linear phase.

Suppose the FIR filter was of the simple form

H ( z )  b0  b1 z 1.

H (e jw )  b0  b1e  jw .
If b0 = b1 = b, we have

H (e jw )  b  be  jw
 jw
 b(1  e )
 be  jw / 2 (e jw / 2  e  jw / 2 )
 jw / 2
 2be cos w2 .
The phase response of this filter is

jw w
H (e )   ,
2

which is in fact linear.


If b0 = -b1 = b, we have

H (e jw )  b  be  jw
 jw
 b(1  e )
 be  jw / 2 (e jw / 2  e  jw / 2 )
 jw / 2
 2 jbe sin w2 .
The phase response is

jw w p
H (e )   
2 2
As it turns out, as long as the coefficients are
symmetric (even or odd), the phase will be linear.

The following are examples of linear-phase FIR


filters:

1
H ( z)  1  z .
1
H ( z)  1  z .
1 2 3
H ( z)  1  z  z  z .
1 2 3
H ( z)  1  z  z  z .
1 2 3
H ( z)  1  z  z  z .
1 2 3
H ( z)  1  2z  2z  z .
1 2 3 4 5
H ( z )  1  2 z  3z  3z  2 z  z .
1 2 3 4
H ( z )  1  2 z  3z  2 z  z .
1 2 3 4
H ( z )  1  2 z  3z  2 z  z .
Exercise: For each of the previous examples, find
the (linear) relationship of phase to frequency
H(ejw).
Linear Phase and Group
Velocity

What is so special about linear phase?

Let f(w) be the phase response of a filter. Without


loss of generality, let us assume that the filter has
constant magnitude response.

jw jf (w )
H (e )  e .
Suppose we pass a sinewave

x1 (t )  cos w1t

through this filter. The corresponding output would


be

y1 (t )  cos(w1t  f (w1 )).


Suppose we pass another sinewave

x2 (t )  cos w2t

through this filter. The corresponding output would


be

y2 (t )  cos(w2t  f (w2 )).


Now suppose we pass the sum of the sinewaves

x(t )  x1 (t )  x2 (t )

through this filter. The corresponding output would


be

y (t )  y1 (t )  y2 (t )
 cos(w1t  f (w1 ))  cos(w 2t  f (w 2 )).
Now if the phase response is linear, i.e.,

f (w )   w,

then the output would be

y (t )  y1 (t )  y2 (t )
 cos(w1t  w1 )  cos(w 2t  w2 )
 cos(w1[t   ])  cos(w 2 [t   ])
 x1 (t   )  x2 (t   ).
The filter effectively shifts different frequencies by
the same amount in time. If the filter shifted the
frequencies by different amounts in time (as it would
with non-linear phase), then the signals would be
delayed by different amounts and would not be
aligned at the output of the filter. Such a non-
aligned result is called dispersion.

The derivative of the phase response is called the


group velocity. For linear phase, the group velocity
is constant (-).
Design of FIR Filters

Since there are no analog filters with a finite-duration


impulse response, FIR filters can not be patterned
after analog filters—new, original design techniques
have to be developed.

The first design technique is the Fourier Series


Method.

The second design technique is the Minimum Mean-


Square Error Technique.
The Fourier Series Method

Suppose we wished to design a filter with a desired


frequency response, Hd(ejw). A typical example
would be the following:
Hd(ejw)

w
wc wc
Let us take a periodic extension (in frequency
domain) of this function:

… … w
2p 2p

We could represent this periodic extension by a


Fourier series (in frequency domain).
The “period” would be 2p, and the fundamental
“frequency” would be 2p/2p1.


jw
H d (e )  c e
n  
n
jnw
,

where
1 p
cn 
2p p

H d (w )e  jnw dw .
We can readily construct the z-transform transfer
function of this filter:


H d ( z)  c z
n  
n
n
.

Thus, the coefficients cn turn out to be nearly the FIR


filter coefficients bn.
Example: Suppose the cutoff frequency of our
desired filter is wc=p/2. Find the coefficients of an
FIR filter.

Solution: We calculate the filter coefficients as


follows:

1 p
p H
 jnw
cn  (w )e dw
2p
d

1 p /2
p
 jnw
 (1)e dw
2p  /2
1 1  jnw p / 2
 e
2p ( jn) p / 2


1 1
2p ( jn)
e 
 jnp / 2
e  jnp / 2

1 np
 sin .
pn 2
For a practical filter the summation in the Fourier
series cannot be infinite: we must truncate the
Fourier series to n=-r to r (where r is a finite integer):

r
H ( z)  c
n r
n
n
z .

For r=5, the transfer function for our wc=p/2 filter is


as follows:
5
H ( z)   n
c z
n  5
n

 c5 z 5  c4 z 4  c3 z 3  c2 z 2  c1 z1
 c0 z 0  c1 z 1  c 2 z  2  c3 z 3  c 4 z  4  c5 z 5
1 5 1 3 1 1 1 1 1 1 3 1 5
 z  z  z   z  z  z
5p 3p p 2 p 3p 5p

Plots of the frequency response, for various values


of r, are shown on the following slide.
Frequency Response
2

1.5

r = 20
r = 50
1
|H(e )|
jw

r=5

0.5

-0.5
-1 -0.5 0 0.5 1
w, x p
While the frequency response improves for higher
orders, you will notice that there is always “rippling”
at the transition (even for higher orders). This
“rippling” is called Gibbs phenomenon. This
“rippling” can be decreased by the application of
windows.

A window is a filter which decreases the ripples.


The window is applied in time-domain: the filter
coefficients cn are weighted by factors wn which
achieve an extra filtering function.
The resultant windowed filter has transfer function

r
H ( z)  w c
n r
n n
n
z .
We have several types of windows: Hamming, von-
Hann, or “Hanning,” Blackman, Kaiser. Such filters
are available through MATLAB via commands like

>> win = hamming(2*r+1);

We can then multiply each of the coefficients by


these Hamming coefficients:

>> c = c.*win’;
The resultant filter coefficients cn will yield a filter
with decreased “rippling” at the transition. The
frequency plots for the previous filter with a
Hamming window applied are shown on the
following slide.
Frequency Response
2

1.5

r = 20
r = 50
1
|H(e )|
jw

r=5

0.5

-0.5
-1 -0.5 0 0.5 1
w, x p
The “rippling” is greatly reduced, but the steepness
of the frequency rolloff is decreased.
One last problem,

r
H ( z)  c
n r
n z n

is non-realizable: the impulse response has negative


terms and the system is non-causal. The system
basically responds r samples before the input is
applied. We fix this problem by delaying the
impulse response by r samples.
Our equivalent causal (realizable) filter (with delay)
transfer function is
r r
H ( z)  z
' r
c
n r
n z n
 c
n r
n z ( n  r )

2r
  c n  r z . n

n 0

Thus, h[n] = c-n-r, and the order of the filter is 2r.


In our previous example for r=5, and wc=p/2 our non-
realizable filter was

1 5 1 3 1 1 1 1 1 1 3 1 5
H ( z)  z  z  z   z  z  z
5p 3p p 2 p 3p 5p

The corresponding realizable filter is

1 1 2 1 4 1 5 1 6 1 8 1 10
H ' ( z)   z  z  z  z  z  z
5p 3p p 2 p 3p 5p

You might also like