You are on page 1of 52

DIGITAL FILTER DESIGN

Digital Filter Design


Objective: Determination of the realizable
transfer function G(Z) approximating a
given frequency response specification is
an important step in the development of
a digital filter.
If an IIR filter is desired, G(Z) should be a
stable real function.
Digital filter design is the process of
deriving the transfer function G(z).
2

Digital Filter Specifications


Usually, either the magnitude and/or the
phase (delay) response is specified for the
design of digital filter for most applications.
In some situations, the unit sample
response or the step response may be
specified.
In most practical applications. The problem
of interest is the development of a
realizable approximation to a given
magnitude response specification.
3

Digital Filter Specifications


We discuss in this course only the
magnitude approximation problem.
There are four basic types of ideal
filters with magnitude responses as
H (e )
H (e )
shown below
LP

HP

c 0

HBP (e j )

c
0
HBS (e j )

c2 c1

c1 c2

c2 c1

c1 c2

Digital Filter Specifications


As the impulse response corresponding to
each of these ideal filters is noncausal and
of infinite length, these filters are not
realizable.
In practice, the magnitude response
specifications of a digital filter in the
passband and in the stopband are given
with some acceptable tolerance.
In addition, a transition band is specified
between the passband and stopband.
5

Digital Filter Specifications


G e
For
example,
the
magnitude
response
of a digital lowpass
filter may be given as indicated
below
j

Digital Filter Specifications


As indicated in the figure, in the
passband,
G e 1
p p, we require that
defined by 0
with anjerror
,i.e.,
j

1 p G e

G e j 0

1 p ,

(e ) s , defined
s by
s
stopband,
In the G
, we require that
with an

Digital Filter Specifications

p - passband edge frequency


s - stopband edge frequency
p- peak ripple value in the passband
s- peak ripple value in the stopband
G e
G e
Since
is a periodic function of ,
and
of a real-coefficient digital
filter is an even function of
As a result, filter specifications are given
only for the frequency range 0 .
j

Digital Filter Specifications


Specifications are often given in
terms of loss function (in dB)
G ( ) 20 log10 G (e j )

Peak passband ripple


p 20 log
dB10 (1 p )
Minimum stopband attenuation
s 20 log10 (dB
s)
9

Digital Filter Specifications


Magnitude specifications may
alternately be given in a normalized
form as indicated below

10

Digital Filter Specifications


Here, the maximum value of the
magnitude in the passband is
assumed to be unity.

1 1 2

- Maximum passband
deviation, given by the minimum
value of the magnitude in the
1
passband.
A

- Maximum stopband magnitude

11

Digital Filter Specifications


For the normalized specification,
maximum value of the gain function
or the minimum value of the loss
function is 0 dB
2 attenuation
Maximum
passband
max 20 log
(
1

) dB
10
For p << 1, it can be shown that
max 20 log10 (1 2 p )

dB

12

Digital Filter Specifications


Fp
In practice, passband edge frequency
and stopband edge
Fs frequency
are specified in Hz.
For digital filter design, normalized
bandedge frequencies need to be
computed from specifications in Hz
p 2 Fp
using

FT

FT

2 FpT

s 2 Fs
s

2 Fs T
FT
FT

13

Digital Filter Specifications


Example
Let Fp 7
FT 25
Fs 3
kHz,
kHz,
and
kHz
Then
2 (7 103 )
p
0.56
3
25 10
2 (3 103 )
s
0.24
3
25 10
14

Selection of Filter Type


The transfer function H(z) meeting the
frequency response specifications should
be a causal transfer function.
For IIR digital filter design, the IIR transfer
function is a real rational function of z-1.
p0 p1 z 1 p2 z 2 pM z M
H ( z)
d 0 d1 z 1 d 2 z 2 d N z N

H(z) must be a stable transfer function and


must be of lowest order N for reduced
computational complexity.
15

Selection of Filter Type


For FIR digital filter design, the FIR
transfer function is a polynomial in z-1
with real coefficients:
N
H ( z ) h[n] z n
n 0

For reduced computational complexity,


degree N of H(z) must be as small as
possible.
If a linear phase is desired, the filter
coefficients must satisfy the constraint:
16

Selection of Filter Type


Advantages in using an FIR filter
Can be designed with exact linear phase,
Filter structure always stable with quantized
coefficients.

Disadvantages in using an FIR filter


Order of an FIR filter, in most cases, is
considerably higher than the order of an
equivalent IIR filter meeting the same
specifications, and FIR filter has thus
higher computational complexity.
17

Digital Filter Design:


Basic Approaches
Most common approach to IIR filter
design
Convert the digital filter specifications
into an analog prototype lowpass
filter specifications
Determine the analog lowpass filter
transfer function Ha(s).
Transform Ha(s) into the
digital transfer function G(z).

desired
18

Digital Filter Design:


Basic Approaches
This approach has been widely used
for the following reasons:
Analog approximation techniques are
highly advanced
They usually yield closed-form solutions
Extensive tables are available for analog
filter design
Many
applications
require
digital
simulation of analog systems
19

Digital Filter Design:


Basic Approaches
An analog transfer function to be
denoted as
P s
Ha s

Da s

where the subscript a specifically


indicates the analog domain.
A digital transfer function derived
from Ha(s) shall be Pdenoted
as
z
G z

D z

20

Digital Filter Design:


Basic Approaches
Basic idea behind the conversion of Ha(s)
into G(z) is to apply a mapping from the sdomain to the z-domain so that essential
properties of the analog frequency
response are preserved.
Thus mapping function should be such that
Imaginary (j) axis in the s-plane be mapped
onto the unit circle of the z-plane.
A stable analog transfer function be mapped
into a stable digital transfer function.
21

Digital Filter Design:


Basic Approaches
FIR filter design is based on a direct
approximation of the specified magnitude
response,
with
the
often
added
requirement that the phase be linear.
The design of an FIR filter of order N may
be accomplished by finding either the
length-(N+1) impulse response samples
{h[n]} or the (N+1) samples of its
frequency response H(e j ).
22

Digital Filter Design:


Basic Approaches
Three commonly used approaches to
FIR filter design
Windowed Fourier series approach
Frequency sampling approach
Computer-based optimization methods

23

IIR Digital Filter Design: Bilinear


Transformation Method
Bilinear transformation 2 1 z 1
s

T 1 z 1

Above transformation maps a single


point in the s-plane to a unique point
in the z-plane and vice-versa.
Relation between G(z) and Ha(s) is
then given by
G z H a s s 2 1 z 1

T 1 z 1

24

Bilinear Transformation
Digital filter design consists of 3 steps:
Develop the specifications of Ha(s) by
applying the inverse bilinear transformation
to specifications of G(z).
Design Ha(s).
Determine
G(z)
by
applying
bilinear
transformation to Ha(s).

As a result, the parameter T has no effect


on G(z) and T = 2 is chosen for
convenience.
25

Bilinear Transformation
Inverse bilinear transformation for T
= 2 is
1 s
z

1 s

For s 0 j 0
1 0 j 0

z
1 0 j 0

Thus,

2
1

2
0
0
z
2
1

0 j02
2

0 0

z 1

0 0

z 1

0 0

z 1

26

Bilinear Transformation
Mapping of s-plane into the z-plane

27

Bilinear Transformation
For z = ej with T = 2 we have
1 e j
j
j tan 2
j
1 e

Or

= tan (/2)

28

Bilinear Transformation
Mapping is highly nonlinear.
Complete negative imaginary axis in
the s-plane from = to = 0 is
mapped into the lower half of the unit
circle in the z-plane from z =-1 to z = 1.
Complete positive imaginary axis in the
s-plane from = 0 to = is mapped
into the upper half of the unit circle in
the z-plane from z = 1 to z =-1
29

Bilinear Transformation
Nonlinear mapping introduces a
distortion in the frequency axis called
frequency warping
Effect of warping shown below

30

Bilinear Transformation
Steps in the design of a digital filter
Prewarp (p,s)
to find their analog equivalents
(p ,s ).
Design the analog filter Ha(s).
Design the digital filter G(z) by applying bilinear
transformation to Ha(s).

Transformation can be used only to design


digital filters with prescribed magnitude
response with piecewise constant values.
Transformation does not preserve phase
response of analog filter.
31

IIR Digital Filter Design Using


Bilinear Transformation
Example - Consider
H a ( s)

c
s c

Applying bilinear transformation to


the above
we get the transfer
function of a first-order digital
lowpass Butterworth filter
G z Ha s

1 z 1
s
1 z 1

c 1 z 1

1
1
1

32

IIR Digital Filter Design Using


Bilinear Transformation
Rearranging terms we get
1 1 z 1
G( z)
.
2 1 z 1

where
1 c 1 tan c / 2

1 c 1 tan c / 2

33

IIR Digital Filter Design Using


Bilinear Transformation
Example - Consider the second-order
analog notch transfer function
s 2 02
Ha s 2
s Bs 02
for which

H a j0 0
H a j 0 H a j 1

o is called the notch frequency.


If
then
H a j 2 H a j1 1 2
B = 2 1 is the 3-dB notch
bandwidth.

34

IIR Digital Filter Design Using


Bilinear Transformation
Then

G z Ha s

1 z 1

1
1

1 2 1 z

1 B 2 1 z
2
0

2
0

2
0

2
0

1 02 z 2

1 02 B z 2

1
1 2 z 1 z 2

.
2 1 2 1 z 1 z 2

where

1 02 B 1 tan Bw 2

2
1 0 B 1 tan Bw 2
1 02

cos 0
2
1 0

35

IIR Digital Filter Design Using


Bilinear Transformation
Example - Design a 2nd-order digital
notch filter operating at a sampling
rate of 400 Hz with a notch
frequency at 60 Hz, 3-dB notch
bandwidth
of 6 Hz.
2 60 / 400 0.3
Thus B 2 6 / 400 0.03
o

From the
above
0.90993 values we get
0.587785
36

IIR Digital Filter Design Using


Bilinear Transformation
Thus
0.954965 1.1226287 z 1 0.954965 z 2
G z
1 1.1226287 z 1 0.90993 z 2

The gain and phase responses are


shown below

37

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Example
Design
a
lowpass
Butterworth digital filter with p =
0.25, s = 0.55,
p 0.5 and
dB.
0.1220185
s 15
2

Thus

A2 31.622777

G e j0 1

If

20this
log10 Gimplies
e j 0.25 0.5
20 log10 G e j 0.55 15
38

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Prewarping we get

p tan p / 2 tan 0.25 / 2 0.4142136


s tan s / 2 tan 0.55 / 2 1.1708496

The inverse transition ratio is


1 s

2.8266809
k p

The inverse discrimination ratio is


1

k1

A2 1
15.841979

39

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Thus

log10 1 k1
N
2.6586997
log10 1 k

We choose N = 3
To determine c we use
H a j p
2

1 p s

2N

1 2

40

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Then we get

c 1.419915 p 0.588148

3rd-order
lowpass
Butterworth
transfer function for c=1 is
1
H an s
s 1 s 2 s 1

Denormalizing to get c= 0.588148


we arriveH ats H s
a

an

0.588148

41

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Applying bilinear transformation to Ha(s)
we get the desired digital transfer function
G z Ha s

1 z 1
1 z 1

Magnitude and gain responses of G(z)


shown below:

42

Design of IIR Highpass, Bandpass,


and Bandstop Digital Filters
First Approach
1.

Prewarp digital frequency specifications of desired


digital filter GD(z) to arrive at frequency specifications
of analog filter HD(s) of same type.

2.

Convert frequency specifications of H D(s) into that of


prototype analog lowpass filter H LP(s).

3.

Design analog lowpass filter H LP(s).

4.

Convert HLP(s) into HD(s) using inverse frequency


transformation used in Step 2.

5.

Design desired digital filter G D(z) by applying bilinear


transformation to HLP(s).
43

Design of IIR Highpass, Bandpass,


and Bandstop Digital Filters
Second Approach
1. Prewarp digital frequency specifications of
desired digital filter GD(z) to arrive at frequency
specifications of analog filter HD(s) of same type.
2. Convert frequency specifications of HD(s) into
that of prototype analog lowpass filter HLP(s).
3. Design analog lowpass filter HLP(s).
4. Convert HLP(s) into an IIR GLP(z) digital transfer
function using bilinear transformation.
5. Transform GLP(z) into the desired digital transfer
function GD(z).
44

IIR Highpass Digital Filter Design


Design of a Type 1 Chebyshev IIR
digital highpass filter
Specifications:
Fp 700 Hz , Fs 500 Hz , p 1dB, s 32dB, FT 2kHz.

Normalized
frequencies
2 F
p

FT

angular

bandedge

2 700
0.7
2000

2 Fs 2 500
s

0.5
FT
2000
45

IIR Highpass Digital Filter


Design
Prewarping these frequencies we get
tan / 2 1.9626105

p
p
tan / 2 1.0

s
s

For the prototype analog lowpass


filter choose p=1.

p
p
Using

we get

s=1.962105.

Analog
specifications:
p 1, s lowpass
1.926105, filter
p 1dB
, s 32dB
46

IIR Bandpass Digital Filter


Design
Design of a Butterworth IIR digital
bandpass filter
Specifications: p1 0.45 , p 2 0.65 , s1 0.3 ,
s 2 0.75 , p 1dB, s 40dB

Prewarping we get
tan / 2 0.8540807

p1
p1

tan / 2 1.6318517

p2
p2
tan / 2 0.5095254

s1
s1
tan / 2 2.41421356

s2
s2
47

IIR Bandpass Digital Filter


Design
Width of passband Bw p 2 p1 0.777771
2

1.393733

0
p1 p 2

1.23010325
2

s1 s 2
0

and
We therefore modify s1
so that

s1
s2
2 . to

exhibit geometric symmetry with respect


0
We set s1 0.5773031
.
For the prototype analog lowpass filter we
choose p=1.
48

IIR Bandpass Digital Filter


Design
2
2

Using
p
B

w
s

we get

1.393733 0.3332788
2.3617627
0.5773031 0.777771

Specifications of prototype
Butterworth lowpass filter:

analog

p 1, s 2.3617627, p 1dB, s 40dB


49

IIR Bandstop Digital Filter


Design
Design of an elliptic IIR digital
bandstop filter
s1 0.45 , s 2 0.65 , p1 0.3 ,
Specifications:
p 2 0.75 , p 1dB, s 40dB

tan
Prewarping

we
get
s1
s1 / 2 0.8540807,
tan / 2 1.6318517

s2
s2
tan / 2 0.5095254,

p1
s1
tan / 2 2.41421356

p2
s2
50

IIR Bandstop Digital Filter


Design
Width of stopband Bw s 2 s1 0.777771
2

1.393733

0
s1 s 2

1.23010325
2

p1 p 2
0

and
We therefore modify p1
so that

p1
p2
2 . to

exhibit geometric symmetry with respect


0
We set p1 0.5773031
.
For the prototype analog lowpass filter we
choose s=1.
51

IIR Bandstop Digital Filter


Design
B

Using
s
2
2

we get

0.5773031 0.777771
p
0.4234126
1.393733 0.3332788

Specifications of prototype
Butterworth lowpass filter:

analog

s 1, p 0.4234126, p 1dB, s 40dB


52