Professional Documents
Culture Documents
Digital Filters
Digital Filters
Digital Filters
= k
k n k x ) ( ) ( o
Since x(k) is a number and not a variable
y(n) =
| | ) ( ) ( k n F k x
k
=
o
or y(n) =
=
k
k n h k x ) ( ) (
or y(n) = x(n)*h(n)
Thus the response y(n) of a digital filter to the input x(n) is
given by the convolution of its impulse sequence h(n) with
the input x(n).
Transfer Function
Consider the input output relationship of a digital filter
y(n) = x(n)*h(n)
Taking z-transform of the above relation, and recalling that
convolution in the time domain gets transformed into
multiplication in the frequency domain we get
Y(z) = X(z)H(z)
where Y(z) is the z-transform of the output y(n), X(z) is the z-
transform of the input x(n) and H(z) is the z-transform of the
discrete impulse response h(n) of the digital filter . Thus
H(z) = Y(z)/ X(z)
7
Class notes of EKT353 by Prof. Dr. Farid Ghani
The z-transform of the impulse response sequence of the digital
filter which is also the ratio of the z-transform of the output to
the z-transform of the input is called the transfer function or
the system function of the digital filter.
We thus see that the transfer function is normally
expressed as a ratio of two polynomials in z that is it is a
rational function of z.
Consider again the difference equation of the system (Eqn.1)
= =
=
q
0 k
p
1 k
k) a(k)y(n k) b(k)x(n y(n)
Taking the z-transform we get
1 2 q
1 2 3 p
1 2 3 p
1 2 q
b(0) b(1)z +b(2)z .... b(q)z B(z)
H(z)
1+a(1)z +a(2)z a(3)z .... a(p)z A(z)
A(z) 1+a(1)z +a(2)z a(3)z .... a(p)z
H(z) B(z) b(0) b(1)z +b(2)z .... b(q)z
+ + +
= =
+ +
= + +
= = + + +
Or
p q
k k
k 1 k 0
Y(Z) 1+ a(k)z X(z) b(k)z
= =
(
=
(
Or
q
k
k 0
p
k
k 1
b(k)z
Y(Z)
H(z)
X(z)
1+ a(k)z
=
= =
Or
1 2 q
1 2 3 p
b(0) b(1)z +b(2)z .... b(q)z B(z)
H(z)
1+a(1)z +a(2)z a(3)z .... a(p)z A(z)
+ + +
= =
+ +
Where
8
Class notes of EKT353 by Prof. Dr. Farid Ghani
1 2 q
B(z) b(0) b(1)z +b(2)z .... b(q)z
= + + +
is the numerator polynomial in z
-1
with degree q and
1 2 3 p
A(z) 1+a(1)z +a(2)z a(3)z .... a(p)z
= + +
is the denominator polynomial in z-1 with degree p. Both the
polynomial have real coefficients and in general p > q.
The roots of the numerator polynomial B(z) are the zeros and
the roots of the denominator polynomial A(z) are the poles of
the digital filter . As for causal systems the degree of the
numerator polynomial is less than that of the denominator
polynomial. The order of the filter is p.
NOTE: A LTI system is stable if all its pole lie within the
unit circle in the z-plane
It should be noted that for a non recursive filter, all the
coefficients a
k
are zero so that A(z) = 1. In this case the transfer
function is given by
1 2 q
H(z) B(z) b(0) b(1)z +b(2)z .... b(q)z
= = + + +
This indicates that a non- recursive filter has no poles but
only zeros.
On the other hand for a recursive filter some or all the a
k
are
non zero and the transfer function is
1 2 q
1 2 3 p
b(0) b(1)z +b(2)z .... b(q)z B(z)
H(z)
1+a(1)z +a(2)z a(3)z .... a(p)z A(z)
+ + +
= =
+ +
Digital
Filter
X(z) Y(z)
9
Class notes of EKT353 by Prof. Dr. Farid Ghani
This indicates that a recursive filter has both zeros and
poles.
Cascade and Parallel Connection
If L transfer functions H
1
(z), H
2
(z) . . . , H
L
(z) are connected in
cascade (series), the resultant transfer function is the product of
the individual transfer functions. That is
H(z) = H
1
(z). H
2
(z) . . . H
L
(z).
This is shown in the following block diagram.
H
1
(z)
h
1
(n)
y
1
(n)
Y
1
(z)
H
2
(z)
h
2
(n)
y
2
(n)
Y
2
(z)
H
L
(z)
h
L
(n)
y(n)
Y(z)
. . . .
x(n)
X(z)
Systems /filters connected in cascade
If the systems are connected in parallel than the overall transfer
function is the sum of the individual transfer functions. That is
H(z) = H
1
(z). H
2
(z) . . . H
L
(z).
This is shown in the following block diagram.
H
1
(z)
h
1
(n)
y
1
(n)
Y
1
(z)
H
2
(z)
h
2
(n)
y
2
(n)
Y
2
(z)
H
L
(z)
h
L
(n)
y
L
(n)
Y
L
(z)
.
.
.
.
x(n)
X(z)
.
.
.
.
+
y(n)
Y(z)
10
Class notes of EKT353 by Prof. Dr. Farid Ghani
Frequency response of digital filter
Consider the transfer function H(z) of a digital filter .
Since z is a complex frequency it can be expressed in polar
coordinates
z = r e
je
where r = magnitude of z and is the phase angle.
Thus
H(z) = H(re
je)
Letting r =1,
H(z) = H(e
je
)
H(e
je
) is called the frequency response of the digital filter and
is defined as the response of the filter to a sinusoidal of varying
frequency.
The equation states that the Transfer function of a digital filter
evaluated for | Z|= 1 gives its frequency response. In other
words transfer function of the system evaluated at the unit circle
gives the frequency response of the digital filter .
Following are the properties of the frequency response of a real
sequence h(n).
1. H(e
je
) takes on values for all on a continuous basis.
2. H(e
je
) is periodic with period 2t.
3. The magnitude response |H(e
je
)| is an even function of e
and is symmetrical about t.
4. The phase response ZH(e
je
) is an odd function of e and
is antisymmetrical about t.
11
Class notes of EKT353 by Prof. Dr. Farid Ghani
Realization of Digital FiltersFilters
We have seen previously that a digital filter with rational
transfer function and having input x(n) and output y(n) is
described by a linear constant coefficient difference equation
q p
k 0 k 1
y(n) b(k)x(n k) a(k)y(n k)
= =
=
(1)
and the corresponding z-transform is given by
q p
k k
k 0 k 1
Y(z) X(z) b(k)z Y(z) a(k)z
= =
=
(2)
If the difference equation has one or more terms a(k) that are
non-zero the difference equation and the corresponding digital
filter is called recursive or Infinite Impulse Response (IIR) Filter.
On the other hand if all the terms a(k) are zero then the
resulting difference equation and the corresponding digital filter
is termed as Finite Impulse Response (FIR) Filter.
From Equations (1) and (2) it is seen that the basic
computational (hardware) elements required to find the output
of the filter are:
1. ADDER
2. MULTIPLIER
3. UNIT DELAY
The filter is realized by connecting these elements as per the
difference equation describing the filter. This operation then
provides the block diagram for the implementation or
realization of the filter having the given difference equation
/transfer function.
The notations that are used for the three hardware elements
and the block diagram are as shown below:
12
Class notes of EKT353 by Prof. Dr. Farid Ghani
+
x(n)
y(n)
x(n)+y(n)
Adder
ax(n)
x(n)
a
Multiplier
z
-1
x(n) x(n-1)
Unit Delay
A Filter is represented pictorially using a signal flow graph that
is a network of directed branches that are connected at nodes.
Each branch has an input and an output with the direction
indicated by an arrow head. The nodes in a block diagram
correspond to either adders or branch points. Adders
corresponds to nodes with more than one incoming branches
and branch points with more than one out going branches as
shown.
Node j Node k
X
j
(n)
X
k
(n)
Signal flow graph consisting of nodes and branches and node
variables. Node j represents and adder and node k represents a
branch point
The output of each branch is a linear transformation of the
branch input and the linear operator is indicated next to the
arrow. For linear time invariant systems/filters these linear
13
Class notes of EKT353 by Prof. Dr. Farid Ghani
operator consists of multipliers and delays as shown in the
following diagrams.
x(n) y(n)=ax(n)
Input
output
a
x(n) y(n)=x(n-1)
Input
output
Z
-1
Multiplier
Unit Delay
Finally there are two special types of nodes
1. Source nodes: These are nodes that have no incoming
branches and are used for sequences that are input to the
system/filter.
2. Sink nodes: These are nodes that have only entering
branches and are used to represent output sequences.
Structures for FIR Filters
A causal FIR Filter has a transfer function H(z) that is a
polynomial in z
-1
. That is
N
-n
n=0
H(z) = h(n)z
(1)
h(n) for n= 0,1, 2 . .n is the discrete impulse response of the
filter.
Notice that the transfer function of the FIR filter has no
poles and has only zeros.
For an input x(n) to the filter the output y(n) is given by
y(n) = h(n)*x(n)
Or y(n) = h(k)x(n-k) n= 0, 1, 2, . . .
14
Class notes of EKT353 by Prof. Dr. Farid Ghani
For each value of n evaluating this sum requires (N+1)
multiplications and N additions. There are several different
realization/implementation block diagrams for this system and
these are considered below.
1. Direct Form
The most common way to implement a FIR Filter is in direct
form using a tapped delay line as shown in figure below. Let
h(n) be the discrete impulse response of the filter of length
N+1 and H(z) its z-transform.
h(n) = h
0
, h
1
, h
2
, h
3
, h
4
, . . . . , h
N
and H(z) = h
0
+h
1
z
-1
+ h
2
z
-2
+ h
3
z
-3
+ h
4
z
-4
+ . . . . +h
N
z
-N
N
-n
n=0
H(z) = h(n)z
h(0)
h(1) h(2) h(3) h(N-1) h(N)
z
-1
z
-1
z
-1
z
-1 x(n)
y(n)
. .
. .
15
Class notes of EKT353 by Prof. Dr. Farid Ghani
.
.
.
.
.
.
Z
-1
Z
-1
Z
-1
Z
-1
h(0)
h(1)
h(2)
h(N-2)
h(N-1)
h(N)
x(n) y(n)
This structure requires (N+1) multiplications, N addition and
N delays.
2. Cascade Form
For a causal filter the transfer function may be
factored into product of 2
nd
order factors of the form
1+ b
1
(1)z
-1
+ b
1
(2)z
-2
The realization of a single second order factor is as shown
in figure.
z
-1
z
-1
b
1
(1)
x(n)
y(n)
b
1
(2)
Realization of a second order factor
16
Class notes of EKT353 by Prof. Dr. Farid Ghani
Thus if the transfer function of the filter is of order N, there will
be N/2 number of such factors. Let
N1=N/2
Then H(z) can be written as
1 2 1 2
1 1 2 2
1 2 1 2
3 3 N1 N1
H(z) A 1 b (1)z b (2)z 1 b (1)z b (2)z
1 b (1)z b (2)z .... 1 b (1)z b (2)z
( (
= + + + +
( ( + + + +
Or
N1
1 2
k k
k 1
H(z) A 1 b (1)z b (2)z
=
(
= + +
[
Written in this form H(z) may be implemented as a cascade of
second order FIR filters as shown in figure below. The
advantage of this form of realization is that any number of
second order sections can be cascaded to realize a filter of any
length.
b
1
(1)
z
-1
z
-1
z
-1
z
-1
x(n)
y(n)
. .
b
2
(1) b
Ns
(1)
b
1
(2) b
2
(2) b
Ns
(2)
z
-1
z
-1
17
Class notes of EKT353 by Prof. Dr. Farid Ghani
Structures for IIR (Recursive) Digital Filters
Let the z-transfer function of the IIR filter be H(z) and its
sampled impulse response sequence be h(n). Let x(n) be the
input sequence with z-transform X(z) and y(n) with z-
transform Y(z) be the output sequence. This arrangement is
shown in the following figure.
IIR
FILTER
h(n)
H(z)
Input
x(n)
X(z)
Output
y(n)
Y(z)
The input x(n) and the output y(n) of a causal IIR filter are
related with a rational transfer function H(z) where H(z) is given
by
q
k
k 0
p
k
k 0
b(k)z
y(z) B(z)
H(z)
x(z) A(z)
a(k)z
=
= = =
(1)
Where it is assumed that
1 2 -(q-1) -q
B(z) b(0) b(1)z b(2)z . . . +b(q-1)z +b(q)z
= + + +
1 2 -(p-1) -p
A(z) 1 a(1)z a(2)z . . . +a(q-1)z +b(q)z
= + + +
(2)
So that the inverse z-transforms of B(z) and A(z) are
b(n) = b(0), b(1), b(2), . . . . . , b(q-1), b(q)
a(n) = a(0), a(1), a(2), . . . . . , a(p-1), a(p) (2a)
The corresponding difference equation is
q p
k 0 k 0
y(n) b(k)x(n k) a(k)y(n k)
= =
=
(3)
18
Class notes of EKT353 by Prof. Dr. Farid Ghani
We assume that a(1) =1
There are several structures that can be used to implement
an IIR filter described by the above transfer function (Eqn.1)
or the difference equation (Eqn. 3) and these are considered
below.
Direct Form Structures
There are two direct form IIR filter structures Direct Form I
and Direct Form II.
Direct Form I Structure
The Direct Form I structure is an implementation that results
when Eqn. 3 above is written in terms of two equations as
considered below
Equation 1 can be represented in block diagram form as
H(z) X(z)
Y(z)
B(z)/
A(z)
X(z)
Y(z)
B(z) X(z) Y(z) 1/A(z)
W(z)
OR
OR
Where
W(z) = B(z) X(z)
or w(n) = b(n) * x(n)
q
k 0
w(n) b(k)x(n k)
=
=
(4)
Now
Y(z) = w(z)/A(z)
19
Class notes of EKT353 by Prof. Dr. Farid Ghani
or Y(z) A(z) = W(z)
Putting the value of A(z) we get
1 2 -(p-1) -p
Y(z) 1 a(1)z a(2)z . . . +a(q-1)z +b(q)z W(z)
(
+ + + =
Or
1 2
-(p-1) -p
Y(z) a(1)Y(z)z a(2)Y(z)z . . .
W(z)
+a(q-1)Y(z)z +b(q)Y(z)z
(
+ + +
=
(
(
Or
1 2
-(p-1) -p
a(1)Y(z)z a(2)Y(z)z . . .
Y(z) W(z)
+a(q-1)Y(z)z +b(q)Y(z)z
(
+ +
=
(
(
Taking inverse z-transform
a(1)y(n 1) a(2)Y(n 2) . . .
y(n) w(n)
+a(q-1)y(n (p 1))+b(p)y(n p)
+ +
(
=
(
Or
p
k=1
y(n) =w(n) - a(k)y(n k)
(5)
Thus from Equations 3, 4 and 5 we see that equation 3 can be
split in Equations 4 and 5. That is in equations
q
k 0
w(n) b(k)x(n k)
=
=
p
k=1
y(n) =w(n) - a(k)y(n k)
The first of the above equations (Eqn. 4) corresponds to a FIR
filter with input x(n) and output w(n) and discrete weighting
sequence b(n). The second of the above equations
corresponds to a filter that has all poles and no zeros with input
20
Class notes of EKT353 by Prof. Dr. Farid Ghani
w(n) and output y(n). Thus the above pair of Equations (Eqns. 4
and 5) represent a cascade of two filters/systems
| |
1
Y(z) B(z)X(z)
A(z)
( =
(6)
As shown in figure below.
z
-1
z
-1
z
-1
z
-1
b(0)
b(1)
b(2)
b(q-1)
b(q)
-a(1)
-a(2)
-a(p-1)
-a(p)
x(n) y(n)
.
.
.
.
.
.
.
.
.
.
.
.
z
-1
z
-1
Direct Form I realization of an IIR Filter
The computational requirements for Direct Form I structure are
1. Number of multiplications = ( p+q+1) per output sample
2. Number of additions = (p+q) per output sample
3. Number of delay units = (p+q)
21
Class notes of EKT353 by Prof. Dr. Farid Ghani
Direct Form II Structure
The Direct Form II Structure is obtained by reversing the
order of the cascade of B(z) and A(z) as shown in the
following figure.
1/A(z) X(z) Y(z)
W(z)
B(z)
With this implementation x(n) is first filtered with the all pole filter
1/A(z) and then with B(z). In this case the two difference equations
describing the filter are similar to Equations 4, and 5 and are given
below
p
k 1
w(n) x(n) a(k)w(n k)
=
=
(7)
And
q
k 0
y(n) b(k)w(n k)
=
=
(8)
Just as in the case of Direct Form I structure, the structure
represented by the difference Equations 7 and 8 is as shown in
the following figure.
22
Class notes of EKT353 by Prof. Dr. Farid Ghani
z
-1
z
-1
z
-1
z
-1
z
-1
z
-1
b(0)
b(1)
b(2)
b(q-1)
b(q)
-a(1)
-a(2)
-a(p-1)
-a(p)
x(n) y(n)
.
.
.
.
.
.
.
.
.
.
.
.
Direct Form II Structure of the IIR Filter obtained by reversing
the Direct Form I structure
This structure may then be further simplified by noting that the
two sets of delays are delaying the same sequence and,
therefore, the two sets can be combined into a single set. This
results in to give the Direct Form II structure that is shown in the
following figure.
Note that the following figure corresponds to the case
when p=q. If pq then the corresponding values of b(0) or
a(0) would be zero.
23
Class notes of EKT353 by Prof. Dr. Farid Ghani
z
-1
z
-1
z
-1
b(0)
b(1)
b(2)
b(q-1)
b(q)
-a(1)
-a(1)
-a(p-1)
-a(p)
x(n) y(n)
.
.
.
.
.
.
.
.
.
.
.
.
Direct Form II Structure for an IIR Filter when p=q
Cascade Structure
The cascade structure is derived by factoring the numerator and
the denominator polynomials of H(z) . Thus
q
k
k max(p.q)
k 0 k
p k
k k 1
k
k 1
b(k)z
1 z
H(z) A
1 z
1 a(k)z
=
=
|
= =
o
+
This factorization corresponds to cascade of first order filters
each having one pole and one zero. However, in general the
24
Class notes of EKT353 by Prof. Dr. Farid Ghani
will be complex for real a(k) and b(k) and will appear as
complex conjugate pairs. These may be combined to form
second order factors with real coefficients. Thus the k
th
second
order factor of H(z) is given by
1 2
1k 2k
k
1 2
1k 2k
1 z z
H (z)
1 z z
+| +|
=
+o +o
As an example a sixth order IIR filter implemented as a cascade
of three second order filters in Direct Form II is as shown in
figure.
This may be noted that there is a considerable flexibility in
how a filter may be implemented in cascade form by
selecting different pairs of poles and zeros for example.
z
-1
z
-1
-
11
-
21
11
21
z
-1
z
-1
-
12
-
22
12
22
z
-1
z
-1
-
13
-
23
13
23
x(n) y(n)
Second order Section I Second order Section II Second order Section III
A sixth order IIR Filter implemented as a cascade of three
Direct Form II second order filters
Parallel Structure
An alternative to factoring H(z) is to expand H(z) through partial
fractions and express it as sum of second order factors and
results in the parallel structure for the IIR filter. The procedure
is discussed below.
Consider the transfer function H(z) of the IIR filter given as
25
Class notes of EKT353 by Prof. Dr. Farid Ghani
q
k
k max(p.q)
k 0 k
p k
k k 1
k
k 1
b(k)z
1 z
H(z) A
1 z
1 a(k)z
=
=
|
= =
o
+
If p>q and
i
k
(the roots of the denominator polynomial are
distinct) H(z) may be expanded by partial fraction expansion as p first
order factors
( )
p
k
1
k 1
k
C
H(z)
1 z
=
=
o
Where the coefficients C
k
and
k
are in general complex. This
expression corresponds to a sum of p first order transfer
functions and may be realized by connecting these in parallel.
However, the coefficients of h(n) and H(z) are real and
therefore, the poles of H(z)
k
, will have complex values in
general and will appear as conjugate pairs. These complex
roots in partial fraction may be combined to form second order
systems with real coefficients. So that
1
Ns
0k 1k
1 2
k 1
1k 2k
z
H(z)
1 z z
=
+
=
+o +o
Figure shows the implementation of six order IIR filter as a
parallel combination of three second order Direct FORM II
filters.
26
Class notes of EKT353 by Prof. Dr. Farid Ghani
z
-1
z
-1
-
11
-
21
11
z
-1
z
-1
-
12
-
22
z
-1
z
-1
-
13
-
23
x(n) y(n)
Second order Section I
Second order Section II
Second order Section III
01
02
12
03
13
A six order IIR filter implemented as a parallel connection of
three second order direct form II structures
If p is less than or equal to q, the partial fraction expansion will
also contain a term of the form
1 2 -(q-p)
0 1 2 (q-p)
c c z c z . . . . +c z
+ + +
Which is an FIR filter that is placed in parallel with the other
terms in the expression of H(z).