You are on page 1of 10

Digital Filter Design

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

Objective - Determination of a 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 rational function
Digital filter design is the process of
deriving the transfer function G(z)
1

Copyright 2005, S. K. Mitra

Digital Filter Specifications

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 shown below
HLP(e j )

HHP (e j )

c 0

c2 c1

HBS (e j )

HBP (e j )

c1

c2

c2 c1

c1

Copyright 2005, S. K. Mitra

c2

Copyright 2005, S. K. Mitra

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 tolerances
In addition, a transition band is specified
between the passband and stopband
Copyright 2005, S. K. Mitra

Digital Filter Specifications

Digital Filter Specifications


j

As indicated in the figure, in the passband,


defined by 0 p , we require that
G (e j ) 1 with an error p, i.e.,

For example, the magnitude response G (e )


of a digital lowpass filter may be given as
indicated below

1 p G ( e j ) 1 + p ,

In the stopband, defined by s , we


require that G (e j ) 0 with an error s ,
i.e.,
G ( e j ) s , s
5

Copyright 2005, S. K. Mitra

Copyright 2005, S. K. Mitra

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
Since G (e j ) is a periodic function of ,
and G (e j ) of a real-coefficient digital
filter is an even function of
As a result, filter specifications are given
only for the frequency range 0
Copyright 2005, S. K. Mitra

Digital Filter Specifications


Specifications are often given in terms of
j
loss function A () = 20 log10 G (e ) in
dB
Peak passband ripple
p = 20 log10 (1 p ) dB
Minimum stopband attenuation
s = 20 log10 ( s ) dB
8

Copyright 2005, S. K. Mitra

Digital Filter Specifications

Digital Filter Specifications

Magnitude specifications may alternately be


given in a normalized form as indicated
below

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 passband
1 - Maximum stopband magnitude
A

Copyright 2005, S. K. Mitra

Digital Filter Specifications


For the normalized specification, maximum
value of the gain function or the minimum
value of the loss function is 0 dB
Maximum passband attenuation max = 20 log10 1 + 2 dB
For p << 1, it can be shown that
max 20 log10 (1 2 p ) dB

11

Copyright 2005, S. K. Mitra

10

Copyright 2005, S. K. Mitra

Digital Filter Specifications


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

Copyright 2005, S. K. Mitra

Digital Filter Specifications


Example - Let Fp = 7 kHz, Fs = 3 kHz, and
FT = 25 kHz
Then
2(7 103 )
p =
= 0.56
25 103
s =

2(3 103 )
= 0.24
25 103

13

Copyright 2005, S. K. Mitra

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 + p1z 1 + p2 z 2 + L + pM z M
, MN
d 0 + d1z 1 + d 2 z 2 + L + d N z N
H(z) must be a stable transfer function and
must be of lowest order N for reduced
14 computational complexity
H ( z) =

Copyright 2005, S. K. Mitra

Selection of Filter Type

Selection of Filter Type


For FIR digital filter design, the FIR
transfer function is a polynomial in z 1
with real coefficients:

Advantages in using an FIR filter (1) Can be designed with exact linear phase,
(2) 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

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:
h[n] = h[ N n]
15

Copyright 2005, S. K. Mitra

16

Digital Filter Design:


Basic Approaches

Digital Filter Design:


Basic Approaches
Most common approach to IIR filter design (1) Convert the digital filter specifications
into an analog prototype lowpass filter
specifications
(2) Determine the analog lowpass filter
transfer function H a (s )
(3) Transform H a (s ) into the desired digital
transfer function G ( z )
17

Copyright 2005, S. K. Mitra

Copyright 2005, S. K. Mitra

18

This approach has been widely used for the


following reasons:
(1) Analog approximation techniques are
highly advanced
(2) They usually yield closed-form
solutions
(3) Extensive tables are available for
analog filter design
(4) Many applications require digital
simulation of analog systems
Copyright 2005, S. K. Mitra

Digital Filter Design:


Basic Approaches

Digital Filter Design:


Basic Approaches

An analog transfer function to be denoted as


P ( s)
H a ( s) = a
Da ( s )

Basic idea behind the conversion of H a (s )


into G ( z ) is to apply a mapping from the
s-domain 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

where the subscript a specifically


indicates the analog domain
A digital transfer function derived from H a ( s )
shall be denoted as
P( z )
G( z) =
D( z )
19

Copyright 2005, S. K. Mitra

20

Digital Filter Design:


Basic Approaches

Copyright 2005, S. K. Mitra

Three commonly used approaches to FIR


filter design (1) Windowed Fourier series approach
(2) Frequency sampling approach
(3) Computer-based optimization methods

22

IIR Digital Filter Design: Bilinear


Transformation Method

Digital filter design consists of 3 steps:


(1) Develop the specifications of Ha ( s ) by
applying the inverse bilinear transformation
to specifications of G(z)
(2) Design Ha (s )
(3) 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

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 ) = Ha ( s ) 2 1 z 1
s=

T 1+ z 1

Copyright 2005, S. K. Mitra

Copyright 2005, S. K. Mitra

Bilinear Transformation

Bilinear transformation 1

s = 2 1 z 1
T 1 + z

23

Copyright 2005, S. K. Mitra

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 )
21

mapped onto the unit circle of the z-plane


A stable analog transfer function be mapped
into a stable digital transfer function

24

Copyright 2005, S. K. Mitra

Bilinear Transformation

Bilinear Transformation

Inverse bilinear transformation for T = 2 is


z = 1+ s
1 s

Mapping of s-plane into the z-plane

For s = o + jo
2
2
(1 + o ) + jo
2 (1 + o ) + o
z=
z =
(1 o ) jo
(1 o ) 2 + o2
o = 0 z = 1
Thus,

o < 0 z < 1
o > 0 z > 1

25

Copyright 2005, S. K. Mitra

26

Bilinear Transformation

Bilinear Transformation

For z = e with T = 2 we have


j e j / 2 (e j / 2 e j / 2 )
j = 1 e j = j / 2 j / 2 j / 2
1+ e
e
(e
+e
)
j 2 sin( / 2)
=
= j tan( / 2)
2 cos( / 2)
or = tan( / 2)

27

Copyright 2005, S. K. Mitra

Mapping is highly nonlinear


Complete negative imaginary axis in the splane 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 splane from = 0 to = is mapped into the
upper half of the unit circle in the z-plane
from z = 1 to z = 1
28

29

= tan(/2)

Copyright 2005, S. K. Mitra

Copyright 2005, S. K. Mitra

Bilinear Transformation

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

Copyright 2005, S. K. Mitra

Steps in the design of a digital filter (1) Prewarp ( p , s ) to find their analog
equivalents ( p , s )
(2) Design the analog filter H a (s )
(3) Design the digital filter G(z) by applying
bilinear transformation to H a (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

30

Copyright 2005, S. K. Mitra

IIR Digital Filter Design Using


Bilinear Transformation

IIR Digital Filter Design Using


Bilinear Transformation

Example - Consider
c
s + c
Applying bilinear transformation to the above
we get the transfer function of a first-order
digital lowpass Butterworth filter

Rearranging terms we get

H a ( s) =

1+ z 1

where

c (1 + z 1 )
=
(1 z 1 ) + c (1 + z 1 )

31

Copyright 2005, S. K. Mitra

32

Copyright 2005, S. K. Mitra

IIR Digital Filter Design Using


Bilinear Transformation

IIR Digital Filter Design Using


Bilinear Transformation

Example - Consider the second-order analog


notch transfer function
s 2 + o2
H a ( s) = 2
s + B s + o2
for which H a ( jo ) = 0

33

H a ( j 0) = H a ( j) = 1
o is called the notch frequency
If H a ( j 2 ) = H a ( j1 ) = 1 / 2 then
B = 2 1 is the 3-dB notch bandwidth
Copyright 2005, S. K. Mitra

Then
=

35

1+
1 2 z + z

2 1 2 (1 + ) z 1 + z 2

1 + o2 B 1 tan( Bw / 2)
=
1 + o2 + B 1 + tan( Bw / 2)
1 o2
=
= cos o
Copyright 2005, S. K. Mitra
1 + o2

34

IIR Digital Filter Design Using


Bilinear Transformation
Thus

0.954965 1.1226287 z 1 + 0.954965 z 2


1 1.1226287 z 1 + 0.90993 z 2
The gain and phase responses are shown below

G( z) =

2
0
-10
-20
-30

= 0.587785
Copyright 2005, S. K. Mitra

where =

Gain, dB

= 0.90993

G ( z ) = H a ( s ) s =1 z

1+ z 1
2
2
(1 + o ) 2(1 o ) z 1 + (1 + o2 ) z 2
(1 + o2 + B) 2(1 o2 ) z 1 + (1 + o2 B ) z 2
1
2

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
Thus o = 2(60 / 400) = 0.3
Bw = 2(6 / 400) = 0.03
From the above values we get

1 c 1 tan(c / 2)
=
1 + c 1 + tan(c / 2)

Phase, radians

G ( z ) = H a ( s ) s =1 z 1

1
G ( z ) = 1 1 + z 1
2 1 z

36

-40
0

50

100
150
Frequency, Hz

200

1
0
-1
-2
0

50

100
150
Frequency, Hz

200

Copyright 2005, S. K. Mitra

IIR Lowpass Digital Filter Design


Using Bilinear Transformation

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 dB, and s 15 dB
Thus
A2 = 31.622777
2 = 0.1220185

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

If G (e j 0 ) = 1 this implies
20 log10 G (e j 0.25 ) 0.5
20 log10 G (e j 0.55 ) 15
37

Copyright 2005, S. K. Mitra

38

N=

3rd-order lowpass Butterworth transfer


function for c = 1 is
1
Han ( s ) =
( s + 1)( s 2 + s + 1)

We choose N = 3
To determine c we use
2

1
1
=
2N
1 + ( p / c )
1 + 2

39

Copyright 2005, S. K. Mitra

Denormalizing to get c = 0.588148 we


arrive at
s

Ha ( s ) = Han

0.588148
40

Copyright 2005, S. K. Mitra

IIR Lowpass Digital Filter Design


Using Bilinear Transformation

Design of IIR Highpass,


Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters

Applying bilinear transformation to H a (s )


we get the desired digital transfer function
G ( z ) = H a ( s ) s =1 z

First Approach (1) Prewarp digital frequency specifications


of desired digital filter GD (z ) to arrive at
frequency specifications of analog filter H D (s )
of same type
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
H LP (s )

1+ z 1

0
-10
Gain, dB

Magnitude

Magnitude and gain responses of G(z) shown


below:
0.8
0.6
0.4

41

-20
-30

0.2
0

0.2

0.4

0.6
/

0.8

-40
0

0.2

0.4

0.6

Copyright 2005, S. K. Mitra

We then get
c = 1.419915 ( p ) = 0.588148

log10 (1 / k1 )
= 2.6586997
log10 (1 / k )

H a ( j p ) =

A2 1
= 15.841979

IIR Lowpass Digital Filter Design


Using Bilinear Transformation

IIR Lowpass Digital Filter Design


Using Bilinear Transformation
Thus

1
=
k1

0.8

Copyright
2005, S. K. Mitra
/

42

(3) Design analog lowpass filter H LP (s )


Copyright 2005, S. K. Mitra

Design of IIR Highpass,


Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters

Design of IIR Highpass,


Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters

(4) Convert H LP (s ) into H D (s ) using


inverse frequency transformation used in
Step 2
(5) Design desired digital filter GD (z ) by
applying bilinear transformation to H D (s )

43

Copyright 2005, S. K. Mitra

Second Approach (1) Prewarp digital frequency specifications


of desired digital filter GD (z ) to arrive at
frequency specifications of analog filter H D (s )
of same type
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
H LP (s )
44

IIR Highpass Digital Filter Design

Design of IIR Highpass,


Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters

Design of a Type 1 Chebyshev IIR digital


highpass filter
Specifications: Fp = 700 Hz, Fs = 500 Hz,
p = 1 dB, s = 32 dB, FT = 2 kHz
Normalized angular bandedge frequencies

(3) Design analog lowpass filter H LP (s )


(4) Convert H LP (s ) into an IIR digital
transfer function GLP (z ) using bilinear
transformation
(5) Transform GLP (z ) into the desired
digital transfer function GD (z )
We illustrate the first approach
45

Copyright 2005, S. K. Mitra

46

Copyright 2005, S. K. Mitra

IIR Highpass Digital Filter Design

Prewarping these frequencies we get


p = tan( p / 2) = 1.9626105

s = tan(s / 2) = 1.0

MATLAB code fragments used for the design


[N, Wn] = cheb1ord(1, 1.9626105, 1, 32, s)
[B, A] = cheby1(N, 1, Wn, s);
[BT, AT] = lp2hp(B, A, 1.9626105);
[num, den] = bilinear(BT, AT, 0.5);

For the prototype analog lowpass filter choose


p =1


Using = p p we get s = 1.962105

Analog lowpass filter specifications: p = 1,

0
Gain, dB

-10

s = 1.926105 , p = 1dB, s = 32 dB
Copyright 2005, S. K. Mitra

2 Fp

2 700
=
= 0.7
FT
2000
2 Fs 2 500
s =
=
= 0.5
FT
2000

p =

IIR Highpass Digital Filter Design

47

Copyright 2005, S. K. Mitra

-20
-30
-40

48

-50
0

0.2

0.4

0.6
/

0.8

1
Copyright 2005, S. K. Mitra

IIR Bandpass Digital Filter Design

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 = 1 dB, s = 40 dB
Prewarping we get
p1 = tan( p1 / 2) = 0.8540807

p 2 = tan( p 2 / 2) = 1.6318517

p2
p1 = 0.777771
Width of passband Bw =
o2 =
p1
p 2 = 1.393733

s1
s 2 = 1.23010325
o2

s1and

We therefore modify s1 so that

exhibit
geometric
symmetry
with
s2
o2
respect to
s1 = 0.5773031
We set
For the prototype analog lowpass filter we
choose p = 1

s1 = tan(s1 / 2) = 0.5095254

s 2 = tan(s 2 / 2) = 2.41421356

49

Copyright 2005, S. K. Mitra

50

IIR Bandpass Digital Filter Design

IIR Bandpass Digital Filter Design

MATLAB code fragments used for the design

2 2
Using = p o we get
Bw

s =

[N, Wn] = buttord(1, 2.3617627, 1, 40, s)


[B, A] = butter(N, Wn, s);
[BT, AT] = lp2bp(B, A, 1.1805647, 0.777771);
[num, den] = bilinear(BT, AT, 0.5);

1.393733 0.3332788
= 2.3617627
0.5773031 0.777771

Specifications of prototype analog


Butterworth lowpass filter:
p = 1 , s = 2.3617627 , p = 1 dB,
s = 40 dB
51

Copyright 2005, S. K. Mitra

Copyright 2005, S. K. Mitra

0
Gain, dB

-10
-20
-30
-40
-50

52

0.2

0.4

0.6

0.8

/
Copyright 2005, S. K. Mitra

IIR Bandstop Digital Filter Design

IIR Bandstop Digital Filter Design

Design of an elliptic IIR digital bandstop filter


Specifications: s1 = 0.45 , s 2 = 0.65 ,
p1 = 0.3, p 2 = 0.75 , p = 1 dB, s = 40 dB
Prewarping we get
s 2 = 1.6318517,
s1 = 0.8540806,

p 2 = 2.4142136
p1 = 0.5095254,

s2
s1 = 0.777771
Width of stopband Bw =

p1and
p2
p1so that
We therefore modify
exhibit geometric symmetry with respect to
o2

53

o2 =
s 2
s1 = 1.393733

o2
p 2 p1 = 1.230103
Copyright 2005, S. K. Mitra

p1 = 0.577303
We set
For the prototype analog lowpass filter we
choose s = 1
B

Using = s 2 w 2 we get
o

0.5095254 0.777771
p =
= 0.4234126
1.393733 0.3332787
54

Copyright 2005, S. K. Mitra

IIR Bandstop Digital Filter Design


MATLAB code fragments used for the design
[N, Wn] = ellipord(0.4234126, 1, 1, 40, s);
[B, A] = ellip(N, 1, 40, Wn, s);
[BT, AT] = lp2bs(B, A, 1.1805647, 0.777771);
[num, den] = bilinear(BT, AT, 0.5);
0
Gain, dB

-10
-20
-30
-40
-50
0

55

0.2

0.4

0.6

0.8

/
Copyright 2005, S. K. Mitra

10

You might also like