You are on page 1of 71

Digital Signal Processing

FIR & IIR


Dr. Arjon Turnip
1
DSP
AJT
Digital Filters
2
x
n
y
n
Digital Filter
Sampling
frequency
f
S
A
D
C
D
A
C
x(t)
y(t)
Analog
anti-
aliasing
filter
Analog
smoothing
filter
x
n
y
n
Digital Filter
DSP
AJT
Input and Output
3
X x e
n
j nT
n
n
e
( ) e
e
=

=
=+

Y y e
n
j nT
n
n
e
( ) e
e
=

=
=+

Fourier Transforms
Z Transfer Function
H z h z
n
n
n
( ) =

=
+

H h e H z
n
j nT
n
z e
e
j T
e
( ) ( ) e
e
e
= =

=
+
=

Y z X z H z ( ) ( ) ( ) =
DSP
AJT
Rational z Transfer Function
4
Linear equation with constant coefficients.
y b x a y
n i n i
i
Q
k n k
k
P
=

=

=

0 1
H z
N z
D z
b z
a z
i
i
i
Q
k
k
k
P
( )
( )
( )
= =
+

0
1
1
DSP
AJT
Ideal Filters
5
One of the reasons why we design a filter is to remove disturbances

) (n s
) (n v
) (n x
) ( ) ( n s n y ~
Filter
SIGNAL
NOISE
We discriminate between signal and noise in terms of the frequency
spectrum
F
) (F S
) (F V
0
F
0
F
0
F
F
) (F Y
0
F 0
F
DSP
AJT
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Ideal Filters
6
Problem: ideally we do not want the filter to distort the signal we
want to recover.
IDEAL
FILTER
) ( ) ( t s t x = ) ( ) ( T t As t y =
Same shape as
s(t), just scaled
and delayed.
Consequence on the Frequency Response:

=

otherwise
passband the in is F if Ae
F H
FT j
0
) (
2t
F
F
| ) ( | F H
) (F H Z
constant
linear
DSP
AJT
Types of Transfer Functions
7
The time-domain classification of an LTI digital transfer
function sequence is based on the length of its impulse
response:
- Finite impulse response (FIR) transfer function
- Infinite impulse response (IIR) transfer function
In the case of digital transfer functions with frequency-
selective frequency responses, there are two types of
classifications
(1) Classification based on the shape of the magnitude
function |H (e
j
) |
(2) Classification based on the the form of the phase
function ()
DSP
AJT
Classification: Magnitude Characteristics
8
One common classification is based on an ideal
magnitude response
A digital filter designed to pass signal components of
certain frequencies without distortion should have a
frequency response equal to one at these frequencies, and
should have a frequency response equal to zero at all
other frequencies
The range of frequencies where the frequency response
takes the value of one is called the passband
The range of frequencies where the frequency response
takes the value of zero is called the stopband
DSP
AJT
Digital Filters with Ideal Magnitude
Responses
9
Frequency responses of the four popular types of
ideal digital filters with real impulse response
coefficients are shown below:
DSP
AJT
Digital Filters with Ideal Magnitude
Responses
10
Lowpass filter: Passband -0
c

Stopband -
c

Highpass filter: Passband -
c

Stopband -0
c

Bandpass filter: Passband -
c1

c2


Stopband -0
c1
and
c2

Bandstop filter: Stopband -
c1

c2
Passband -0
c1
and
c2

The frequencies
c
,
c1
,and
c2
are called the cutoff frequencies

DSP
AJT
Digital Filters with Ideal Magnitude
Responses
11
Moreover, the magnitude response is allowed to
vary by a small amount both in the passband and
the stopband
Typical magnitude response specifications of a lowpass filter
are shown the right
DSP
AJT
Classification: Phase Characteristics
12
A second classification of a transfer function is with respect to its phase
characteristics
In many applications, it is necessary that the digital filter designed does
not distort the phase of the input signal components with frequencies in
the passband
One way to avoid any phase distortion is to make the frequency
response of the filter real and nonnegative, i.e., to design the filter with
a zero phase characteristic
However, it is not possible to design a causal digital filter with a zero
phase
The function filtfilt implements the above zero-phase filtering scheme
In the case of a causal transfer function with a nonzero phase response,
the phase distortion can be avoided by ensuring that the transfer
function has a unity magnitude and a linear-phase characteristic in the
frequency band of interest
DSP
AJT
Classification: Phase Characteristics
13
The most general type of a filter with a linear phase has
a frequency response given by H(e
j
)=e
-jD
which has
a linear phase from =0 to =2
Note also |H(e
j
)|=1

()=D
The output y[n] of this filter to an input x[n]=Ae
jn
is
then given by
y[n]=Ae
-jD
e
jn
=Ae
j(n-D)

If x
a
(t) and y
a
(t) represent the continuous-time signals
whose sampled versions, sampled at t = nT ,are x[n] and
y[n] given above, then the delay between x
a
(t) and y
a
(t)
is precisely the group delay of amount D

DSP
AJT
Classification: Phase Characteristics
14
If D is an integer, then y[n] is identical to x[n], but
delayed by D samples
If D is not an integer, y[n], being delayed by a fractional
part, is not identical to x[n]
In the latter case, the waveform of the underlying
continuous-time output is identical to the waveform of
the underlying continuous-time input and delayed D
units of time
If it is desired to pass input signal components in a
certain frequency range undistorted in both magnitude
and phase, then the transfer function should exhibit a
unity magnitude response and a linear-phase response in
the band of interest
DSP
AJT
Classification: Phase Characteristics
15
Figure below shows the frequency response if a lowpass
filter with a linear-phase characteristic in the passband
Since the signal components in
the stopband are blocked, the
phase response in the stopband
can be of any shape
Example Determine the
impulse response of an ideal
lowpass filter with a linear phase
response:

s s
< <
=

t e e
e e
e
e
c
c
n j
j
LP
e
e H
, 0
0 ,
) (
0
DSP
AJT
IIR and FIR Filters
16
IIR = Infinite Impulse Response
FIR = Finite Impulse Response
| |
| |
H z b z h z
n Q h
n Q h b
i
i
i
Q
n
n
n
n
n n
( )
,
,
= =
e =
e =

=
+

0
0 1 0
0 1
FIR
IIR
H z
N z
D z
( )
( )
( )
=
With D( ) constant. z =
DSP
AJT
FIR and IIR
17
FIR: output y
n
is a linear combination of a finite number of
input samples.


IIR: output y
n
is a linear combination of a finite number of
input and of output samples. Recursive form.
0 0
, .
Q Q
n i n i i n i i i
i i
y h x b x b h

= =
= = =

y b x a y
n i n i
i
Q
k n k
k
P
=

=

=

0 1
Advantages: always stable, the phase can be made exactly linear, we can
approximate any filter we want;
Disadvantages: we need a lot of coefficients (Q large) for good performance;
Advantages: very selective with a few coefficients;
Disadvantages: non necessarily stable, non linear phase.
DSP
AJT
Causality and Stability
18
A filter is causal if h
n
=0 for n < 0
A filter is stable if the output is bounded
for any bounded input.
Condition for stability is:
All the poles of H(z) are inside the unit circle
FIR are always stable.
Or:
h A
n
n=
+

<
DSP
AJT
19
Digital Filter Specifications
For example the magnitude response of a digital lowpass
filter may be given as indicated below
In the passband we require that
with a deviation


In the stopband we require that
with a deviation
p
e e s s 0
1 ) ( ~
e j
e G
p
o
p p
j
p
e G e e o o
e
s + s s , 1 ) ( 1
t e e s s
s
0 ) ( ~
e j
e G
s
o
t e e o
e
s s s
s s
j
e G , ) (
DSP
AJT
20
Filter specification parameters
- passband edge frequency
- stopband edge frequency
- peak ripple value in the passband
- peak ripple value in the stopband
p
e
s
e
s
o
p
o
Digital Filter Specifications
Practical specifications are often given in terms of loss function (in
dB)

Peak passband ripple
dB
Minimum stopband attenuation
dB
) ( log 20 ) (
10
e
e
j
e G = G
) 1 ( log 20
10 p p
o o =
) ( log 20
10 s s
o o =
DSP
AJT
21
In practice, passband edge frequency and
stopband edge frequency are specified in Hz
For digital filter design, normalized bandedge
frequencies need to be computed from
specifications in Hz using

T F
F
F
F
p
T
p
T
p
p
t
t
e 2
2
= =
O
=
T F
F
F
F
s
T
s
T
s
s
t
t
e 2
2
= =
O
=
s
F
p
F
Digital Filter Specifications
DSP
AJT
22
Example - Let kHz, kHz, and
kHz
Then

7 =
p
F 3 =
s
F
25 =
T
F
t
t
e 56 . 0
10 25
) 10 7 ( 2
3
3
=

=
p
t
t
e 24 . 0
10 25
) 10 3 ( 2
3
3
=

=
s
Digital Filter Specifications
DSP
AJT
23
The transfer function H(z) meeting the
specifications must be a causal transfer function
For IIR real digital filter the transfer function is a
real rational function of


H(z) must be stable and of lowest order N or M for
reduced computational complexity
Selection of Filter Type
1
z
N
N
M
M
z d z d z d d
z p z p z p p
z H


+ + + +
+ + + +
=

2
2
1
1 0
2
2
1
1 0
) (
DSP
AJT
24
Selection of Filter Type

FIR real digital filter transfer function is a
polynomial in (order N) with real
coefficients


For reduced computational complexity, degree N
of H(z) must be as small as possible
If a linear phase is desired then we must have:
(More on this later)

=
=

N
n
n
z n h z H
0
] [ ) (
] [ ] [ n N h n h =
1
z
DSP
AJT
Filter Design
25
Problem: Given a desired Frequency Response of the filter,
determine the impulse response .
H
d
( ) e
h n ( )
Recall: we relate the Frequency Response and the Impulse Response by the DTFT:
{ }

+
=

= =
n
n j
d d d
e n h n h DTFT H
e
e ) ( ) ( ) (
{ }
}
+

= =
t
t
e
e e
t
e d e H H IDTFT n h
n j
d d d
) (
2
1
) ( ) (
Example: Ideal Low Pass Filter
+t
t
+e
c
e
c
H
d
( ) e
A
e
( )
c
sin
1
( ) sinc
2
c
c
c j n
c
d
n
h n Ae d A A n
n
e
e
e
e
e e
e
t t t t
+

| |
= = =
|
\ .
}
) (n h
d
n
e
t
c
=
4
DTFT
DSP
AJT
Filter Design
26
Notice two facts:
the filter is not causal, i.e. the impulse response h(n) is non zero for n<0;
the impulse response has infinite duration.
This is not just a coincidence. In general the following can be shown:
If a filter is causal then
the frequency response cannot be zero on an interval;
magnitude and phase are not independent, i.e. they cannot be specified
arbitrarily

-
-
-
-
-
- -
h n ( )
- -
h n ( ) = 0
H( ) e
H( ) e = 0
As a consequence: an ideal filter cannot be causal.
DSP
AJT
Filter Design
27
Problem: we want to determine a causal Finite Impulse Response (FIR) approximation of the
ideal filter.
We do this by
a) Windowing
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
-100 -50 0 50 100
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
-100 -50 0 50 100
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
) (n h
d
) (n h
w

=
=
rectangular window
hamming window
) (n h
w
infinite impulse response
(ideal)
finite impulse response
L L
L L
L L
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
L L
DSP
AJT
Filter Design
28
b) Shifting in time, to make it causal:
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
) (n h
w
) ( ) ( L n h n h
w
=
DSP
AJT
Filter Design
29
Effects of windowing and shifting on the frequency response of the filter:
a) Windowing: since then
) ( ) ( ) ( n w n h n h
d w
=
) ( * ) (
2
1
) ( e e
t
e W H H
d w
=
e
c
e
c
e
) (e
d
H
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
40
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
40
*
*
=
| ) ( | e W
| ) ( | e
w
H
rectangular window
hamming window
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
=
DSP
AJT
Effect of windowing and shifting
30
Effect of windowing and shifting on the frequency response:
b) shifting: since then
) ( ) ( L n h n h
w
=
L j
w
e H H
e
e e

= ) ( ) (
Therefore
phase. in shift ) ( H ) H(
magnitude, on the effect no ) ( ) (
w
L
H H
w
e e e
e e
Z = Z
=
See what is ). (e
w
H Z
For a Low Pass Filter we can verify the symmetry Then ). ( ) ( n h n h
w w
=
) cos( ) ( 2 ) 0 ( ) ( ) (
1
n n h h e n h H
n
w w
n j
n
w w
e e
e

+
=

+
=
+ = =
real for all . Then e

= Z
otherwise , '
passband; in the 0
) (
care t don
H
w
e
DSP
AJT
Effect of windowing and shifting
31
The phase of FIR low pass filter:
passband; in the ) ( L H e e = Z
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
dont care
e
) (e H
dB
) (e H Z
degrees
Which shows that it is a Linear Phase Filter.
DSP
AJT
Ex. of Design FIR filter by Windows
32
Specs: Pass Band 0 - 4 kHz
Stop Band > 5kHz with attenuation of at least 40dB
Sampling Frequency 20kHz
Step 1: translate specifications into digital frequency
Pass Band
Stop Band
2 5 20 2 t t t / / = rad
0 2 4 20 2 5 = t t / / rad
40dB
F kHz 5 4 10
e t
t
2
2
5
t
Ae
t
=
10
Step 2: from pass band, determine ideal filter impulse
response
h n n
d
c c
( ) =
|
\

|
.
| =
|
\

|
.
|
e
t
e
t
sinc sinc
2n
5
2
5
DSP
AJT
Ex. of Design FIR filter by Windows
33
Step 3: from desired attenuation choose the window. In this case we can choose the hamming
window;
Step 4: from the transition region choose the length N of the impulse response. Choose an
odd number N such that:

8
10
t t
N
s
So choose N=81 which yields the shift L=40.
Finally the impulse response of the filter
h n
n
n
( )
. . cos , ,
=
|
\

|
.
|
|
\

|
.
|
|
\

|
.
| s s

2
5
054 0 46
2
80
0 80 sinc
2(n - 40)
5
if
0 otherwise
t
DSP
AJT
Ex. of Design FIR filter by Windows
34
The Frequency Response of the Filter:
e
e
H( ) e
ZH( ) e
dB
rad
DSP
AJT
35
FIR Design

FIR Digital Filter Design
Three commonly used approaches to FIR
filter design -
(1) Windowed Fourier series approach
(2) Frequency sampling approach
(3) Computer-based optimization methods
DSP
AJT
36
Design of FIR filters: Windows

(i) Start with ideal infinite duration
(ii) Truncate to finite length. (This produces
unwanted ripples increasing in height near
discontinuity.)
(iii) Modify to
Weight w(n) is the window

{ } ) (n h
) ( ). ( ) (
~
n w n h n h =
DSP
AJT
37
Windows
Commonly used windows
Rectangular
Bartlett
Hann
Hamming

Blackman

Kaiser

2
1
<
N
n
N
n 2
1
|
.
|

\
|
+
N
n t 2
cos 1
|
.
|

\
|
+
N
n t 2
cos 46 . 0 54 . 0
|
.
|

\
|
+
|
.
|

\
|
+
N
n
N
n t t 4
cos 08 . 0
2
cos 5 . 0 42 . 0
) (
1
2
1
0
2
0
| | J
N
n
J
(
(

|
.
|

\
|

DSP
AJT
Windows
38
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
e A
attenuation
For different windows we have different values of the transition region and the attenuation
in the stopband:
transition
region
Rectangular -13dB
Bartlett -27dB
Hanning -32dB
Hamming -43dB
Blackman -58dB
N / 4t
N / 8t
N / 8t
N / 8t
16 / N t
e A
n attenuatio
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
L L
1 2 + = L N
) (n h
w
n
with
DSP
AJT
39
Kaiser window
Transition
width (Hz)
Min. stop
attn dB
2.12 1.5/N 30
4.54 2.9/N 50
6.76 4.3/N 70
8.96 5.7/N 90
DSP
AJT
Parametrized Window: Kaiser Window
40
The Kaiser window has two parameters:
= N
|
Window Length and
To control attenuation in the Stop Band
0 20 40 60 80 100 120
0
0.5
1
1.5
n
] [n w
0 = |
1 = |
10 = |
5 = |
Attenuation in dB
Transition Region in rad
A
e A

N
|
)
`

Example:
Sampling Freq. 20 kHz
Pass Band 4 kHz
Stop Band 5kHz, with 40dB Attenuation

,
5
2t
e =
P
2
t
e =
S
dB A
rad
P S
40
10
=
=
= A
t
e e e

3953 . 3
45
=
=
|
N
DSP
AJT
Parametrized Window: Kaiser Window
41
Then we determine the Kaiser window
) , ( | N kaiser w=
] [n w
n
DSP
AJT
Parametrized Window: Kaiser Window
42
Then the impulse response of the FIR filter becomes
( )
] [
) (
) ( sin
] [ n w
L n
L n
n h
c



=
t
e
ideal impulse response
with
( )
20
9
2
1
t
e e e = + =
S P c
22 1 2 45 = + = = L L N


] [n h
n
dB
H | ) ( | e
(rad) e
Impulse Response
Frequency Response
DSP
AJT
Example
43
Design a digital filter which approximates a differentiator.
Specifications:
Desired Frequency Response:

>
+ s s
=
kHz F
kHz F kHz F j
F H
d
5 if 0
4 4 if 2
) (
t
Sampling Frequency
Attenuation in the stopband at least 50dB.
kHz F
s
20 =
Solution.
Step 1. Convert to digital
frequency

s <
s s =
= =
=
t e
t
t
e
t
e e
e
t e
| |
2
if 0

5
2

5
2
- if 000 , 20
) ( ) (
2 /
j F j
F H H
s
F F
d d
s
DSP
AJT
Example
44
Step 2: determine ideal impulse response
{ }
}

= =
5
2
5
2
000 , 20
2
1
) ( ) (
t
t
e
e e
t
e d e j H IDTFT n h
n j
d d
From integration tables or integrating by parts we obtain
|
.
|

\
|
=
}
a
x
a
e
dx xe
ax
ax
1
Therefore

=
=
|
|
|
|
.
|

\
|
|
.
|

\
|

|
.
|

\
|
=
0 if 0
0 if
5
2
sin
2
5
2
cos
5
4
000 , 20
) (
2
n
n
n
n
n
n
n h
d
t t
t
DSP
AJT
Example
45
Step 3. From the given attenuation we use the Blackman window.
This window has a transition region region of . From the
given transition region we solve for the complexity N as follows
N / 12t
N
t
t
t t
e
12
1 . 0
5
2
2
> = = A
which yields . Choose it odd as, for ex., N=121, ie. L=60. 120 > N
Step 4. Finally the result
|
|
.
|

\
|
|
.
|

\
|
+
|
.
|

\
|

|
|
|
|
.
|

\
|

|
.
|

\
|

|
.
|

\
|

=
120
4
cos 08 . 0
120
2
cos 5 . 0 42 . 0
) 60 (
5
) 60 ( 2
sin
2
60
5
) 60 ( 2
cos
5
4
000 , 20 ) (
2
n n
n
n
n
n
n h
t t
t t
t
120 0 for s s n
DSP
AJT
Example
46
0 20 40 60 80 100 120 140
-3
-2
-1
0
1
2
3
x 10
4
0 0.5 1 1.5 2 2.5 3
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
x 10
5
0 0.5 1 1.5 2 2.5 3 3.5
-250
-200
-150
-100
-50
0
50
100
150
Impulse response h(n)
e
e
) (e H
dB
H ) (e
Frequency Response
DSP
AJT
47
Example
Lowpass filter of length 51 and
2 / t e =
c
0 0.2 0.4 0.6 0.8 1
-100
-50
0
e / t
G
a
i
n
,

d
B

Lowpass Filter Designed Using Hamming window
0 0.2 0.4 0.6 0.8 1
-100
-50
0
e / t
G
a
i
n
,

d
B

Lowpass Filter Designed Using Blackman window
0 0.2 0.4 0.6 0.8 1
-100
-50
0
e / t
G
a
i
n
,

d
B

Lowpass Filter Designed Using Hann window
DSP
AJT
48
Frequency Sampling Method


In this approach we are given and
need to find
This is an interpolation problem and the
solution is given in the DFT part of the
course


It has similar problems to the windowing
approach

=

=

1
0
1
2
. 1
1
). (
1
) (
N
k
k
N
j
N
z e
z
k H
N
z H
t
) (k H
) (z H
DSP
AJT
49
Linear-Phase FIR Filter Design
by Optimisation
Amplitude response for all 4 types of linear-
phase FIR filters can be expressed as

where
) ( ) ( ) ( e e e A Q H =

=
4 Type for ), 2 / sin(
3 Type for ), sin(
2 Type for /2), cos(
1 Type for , 1
) (
e
e
e
e Q
DSP
AJT
50
Linear-Phase FIR Filter Design
by Optimisation
Modified form of weighted error function



where
)] ( ) ( ) ( )[ ( ) ( e e e e e D A Q W = E
] ) ( )[ ( ) (
) (
) (
e
e
e e e
Q
D
A Q W =
)] (
~
) ( )[ (
~
e e e D A W =
) ( ) ( ) (
~
e e e Q W W =
) ( / ) ( ) (
~
e e e Q D D =
DSP
AJT
51
Linear-Phase FIR Filter Design
by Optimisation
Optimisation Problem - Determine
which minimise the peak absolute value
of

over the specified frequency bands
After has been determined, construct
the original and hence h[n]
)] (
~
) cos( ] [
~
)[ (
~
) (
0
e e e e D k k a W
L
k

=
=
E
] [
~
k a
R e e
) (
e j
e A
] [
~
k a
DSP
AJT
52
Linear-Phase FIR Filter Design
by Optimisation
Solution is obtained via the Alternation
Theorem
The optimal solution has equiripple behaviour
consistent with the total number of available
parameters.
Parks and McClellan used the Remez
algorithm to develop a procedure for
designing linear FIR digital filters.

DSP
AJT
53
FIR Digital Filter Order
Estimation
Kaisers Formula:


Ie., N is inversely proportional to transition
band width and not on transition band
location
t e e
o o
2 / ) ( 6 . 14
) ( log 20
10
p s
s p
N

~
DSP
AJT
54
FIR Digital Filter Order
Estimation
Hermann-Rabiner-Chans Formula:


where


with
t e e
t e e o o o o
2 / ) (
] 2 / ) )[( , ( ) , (
2
p s
p s s p s p
F D
N


~

s p p s p
a a a D o o o o o
10 3 10 2
2
10 1
log ] ) (log ) (log [ ) , ( + + =

] ) (log ) (log [
6 10 5
2
10 4
a a a
p p
+ + + o o
] log [log ) , (
10 10 2 1 s p s p
b b F o o o o + =
4761 . 0 , 07114 . 0 , 005309 . 0
3 2 1
= = = a a a
4278 . 0 , 5941 . 0 , 00266 . 0
6 5 4
= = = a a a
51244 . 0 , 01217 . 11
2 1
= = b b
DSP
AJT
55
FIR Digital Filter Order
Estimation
Formula valid for
For , formula to be used is obtained
by interchanging and
Both formulae provide only an estimate of
the required filter order N
If specifications are not met, increase filter
order until they are met
s p
o o >
s p
o o <
p
o
s
o
DSP
AJT
56
FIR Digital Filter Order
Estimation
Fred Harris guide:


where A is the attenuation in dB
Then add about 10% to it
t e e 2 / ) ( 20
p s
A
N

~
DSP
AJT
57
Finite Impulse Response Filters

The transfer function is given by


The length of Impulse Response is N
All poles are at .
Zeros can be placed anywhere on the z-
plane

=

=

1
0
). ( ) (
N
n
n
z n h z H
0 = z
DSP
AJT
58
FIR: Linear phase


For phase linearity the FIR transfer
function must have zeros outside the
unit circle

DSP
AJT
59
FIR: Linear phase
To develop expression for phase response
set transfer function (order n)

In factored form


Where , is real &
zeros occur in conjugates
n
n
z h z h z h h z H

+ + + + = ... ) (
2
2
1
1 0
) 1 ( ). 1 ( ) (
1
2
1
1
1
1

=
[

[
= z z K z H
i
n
i
i
n
i
| o
1 , 1 > <
i i
| o
K
DSP
AJT
60
FIR: Linear phase
Let
where


Thus
) ( ) ( ) (
2 1
z N z KN z H =
) 1 ln( ) 1 ln( ) ln( )) ( ln(
2
1
1
1
1
1

+ =
=

=

n
i
i
n
i
i
z z K z H | o
) 1 ( ) (
1
1
1
1

=
[
= z z N
i
n
i
o ) 1 ( ) (
1
2
1
2

=
[
= z z N
i
n
i
|
DSP
AJT
61
FIR: Linear phase
Expand in a Laurent Series convergent
within the unit circle
To do so modify the second sum as




)
1
1 ln( ) ln( ) 1 ln(
2
1
1
2
1
1
2
1
z z z
i
n
i
i
n
i
i
n
i
|
| |

+

=
DSP
AJT
62
FIR: Linear phase
So that

Thus


where
)
1
1 ln( ) 1 ln( ) ln( ) ln( )) ( ln(
2
1
1
1
1
2

+

+ =
= =

n
i
i
n
i
i
z z z n K z H
|
o
m
N
m
m
m
N
m
z
m
s
z
m
s
z n K z H
2
1
1
2
) ln( ) ln( )) ( ln(

+ + =

=
=
1
1
1
n
i
m
i
N
m
s o

=
=

1
1
2
n
i
m
i
N
m
s |
DSP
AJT
63
FIR: Linear phase
are the root moments of the minimum
phase component
are the inverse root moments of the
maximum phase component
Now on the unit circle we have
and

u j
e z =
) (
) ( ) (
u | u
u
j j
e A e H =
1
N
m
s
2
N
m
s

DSP
AJT
64
Fundamental Relationships



hence (note Fourier form)

u u u
u
jm
N
m
m
jm
N
m
j
e
m
s
e
m
s
jn K e H
2
1
1
2
) ln( )) ( ln(

+ + =
) ( )) ( ln( ) ) ( ln( )) ( ln(
) (
u | u u
u | u
j A e A e H
j j
+ = =
u u m
m
s
m
s
K A
N
m
m
N
m
cos ) ( ) ln( )) ( ln(
2
1
1

+ + =
u u u | m
m
s
m
s
n
N
m
m
N
m
sin ) ( ) (
2
1
1
2

=
DSP
AJT
65
FIR: Linear phase

Thus for linear phase the second term in the
fundamental phase relationship must be identically
zero for all index values.
Hence
1) the maximum phase factor has zeros which are
the inverses of the those of the minimum phase
factor
2) the phase response is linear with group delay
(normalised) equal to the number of zeros outside
the unit circle
DSP
AJT
66
FIR: Linear phase

It follows that zeros of linear phase FIR
trasfer functions not on the circumference
of the unit circle occur in the form

| |
1

i
j
i
e
u

DSP
AJT
67
FIR: Linear phase

For Linear Phase t.f. (order N-1)

so that for N even:


) 1 ( ) ( n N h n h =

=

=

=

1
2
1
2
0
). ( ). ( ) (
N
N
n
n
N
n
n
z n h z n h z H

=

=

=

1
2
0
) 1 (
1
2
0
). 1 ( ). (
N
n
n N
N
n
n
z n N h z n h
| |

=

=

1
2
0
) (
N
n
m n
z z n h n N m = 1
DSP
AJT
68
FIR: Linear phase

for N odd:



I) On we have for N even, and
+ve sign
| |

|
.
|

\
|

+ =

=
|
.
|

\
|


1
2
1
0
2
1
2
1
). ( ) (
N
n
N
m n
z
N
h z z n h z H
1 : = z C

|
.
|

\
|
|
.
|

\
|

=

=
|
.
|

\
|

1
2
0
2
1
2
1
cos ). ( 2 . ) (
N
n
N
T j
T j
N
n T n h e e H e
e
e
DSP
AJT
69
FIR: Linear phase
II) While for ve sign


[Note: antisymmetric case adds rads to
phase, with discontinuity at ]
III) For N odd with +ve sign


|
.
|

\
|
|
.
|

\
|

=

=
|
.
|

\
|

1
2
0
2
1
2
1
sin ). ( 2 . ) (
N
n
N
T j
T j
N
n T n h j e e H e
e
e
2 / t
0 = e

|
.
|

\
|

=
(

2
1
) (
2
1
N
h e e H
N
T j
T j
e
e

|
.
|

\
|

+

=
2
3
0
2
1
cos ). ( 2
N
n
N
n T n h e
DSP
AJT
70
FIR: Linear phase
IV) While with a ve sign



[Notice that for the antisymmetric case to have
linear phase we require


The phase discontinuity is as for N even]

|
.
|

\
|

=

=
(

2
3
0
2
1
2
1
sin ). ( . 2 ) (
N
n
N
T j
T j
N
n T n h j e e H e
e
e
. 0
2
1
=
|
.
|

\
|
N
h
DSP
AJT
71
FIR: Linear phase

The cases most commonly used in filter
design are (I) and (III), for which the
amplitude characteristic can be written as a
polynomial in
2
cos
T e

You might also like