Вы находитесь на странице: 1из 47

Lecture 06: Design of Recursive Digital Filters

John Chiverton
School of Information Technology
Mae Fah Luang University

1st Semester 2009/ 2552

Lecture Contents

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

Outline

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

What is a Digital Filter?

( )

|H ( ) |

Often used to remove some frequencies from a signal X() and to


allow other frequencies to pass through to the output Y ().

H(
Inv ), Line
aria
a
nt S r Tim
e
yst
em

|H ( ) |

Low Frequencies

Ou

tpu

t, Y

Low Pass

Band Pass

X(

|H ( ) |

Middle Frequencies

High Frequencies

Inp

ut,

High Pass

Recursive digital filters


Input, x[n]

Linear Time
Invariant System

Output, y[n]

What is a Recursive digital filter?


I

Recursive comes from the word to recur


Meaning: to repeat

A recursive filter uses past output values (y[n i]) for the
calculation of the current output y[n]:
I

Recursive Filter Example


y[n] = 0.5y[n 1] + 0.5x[n].

A non-recursive filter only uses input values x[n i]:


I

Non-recursive Filter Example


y[n] = 0.5x[n 1] + 0.5x[n].

Generalised Difference Equation


Recall the generalised difference equation for causal LTI systems
(see Lecture 02):
N
X

a[k]y[n k] =

k=0

M
X

b[k]x[n k]

k=0

If a[0] = 1, this can then be changed to:


y[n] =

M
X

b[k]x[n k]

k=0

N
X

a[k]y[n k].

k=1

The Frequency Response (see Lecture 03) of such a system can be


described by:
M
P

H() =

M
P

b[k] exp(jk)

k=0

exp(0) +

N
P
k=1

=
a[k] exp(jk)

b[k] exp(jk)

k=0
N
P

1+

k=1

.
a[k] exp(jk)

z-transform Representation
Fourier based frequency representation:
M
P

H() =

b[k] exp(jk)

k=0
N
P

1+

.
a[k] exp(jk)

k=1

Can also be represented in the z-domain (z-transform):


M
P

H(z) =

b[k]z k

k=0
N
P

1+

.
a[k]z k

k=1

Both describe a type of frequency response of the system.

Comparison of IIR and FIR System Structures


The system structure of an IIR filter demonstrates the feedback of
the output into the input again.
IIR Filter

FIR Filter
x[n]

x[n1]
T

x1/4

x[n2]
T

x[n3]

x[n]

x1/4

x1/4

x1/4

x1/4

x[n1]
T

y[n]

y[n] =
1
(x[n] + x[n 1] + x[n 2] + x[n 3])
4

y[n1]

x[n3]
T

x1/4

x1/4

x(1/10)

x[n2]
T

x1/4

+
T

y[n]

y[n] =
(x[n] + x[n 1] + x[n 2] + x[n 3])

1
y[n 1]
10

Unit Delay in the z-plane


A single z1 is the same as a unit delay, T in a system diagram.
x[n]

x[n1]
T

x1/4

x[n2]
T
x1/4

x1/4

x(1/10)

y[n1]

x[n3]
T
x1/4

+
T

y[n]

Unit Delay in the z-plane


A single z1 is the same as a unit delay, T in a system diagram.
x[n]

z1

x1/4

x[n1]

x[n2]

z1
x1/4

x1/4

x(1/10)

y[n1]

z1

x1/4

z1

x[n3]

y[n]

Recursive Digital Filters


Recursive digital filters are often known as
I

Infinite Impulse Response (IIR) Filters

as the impulse response of an IIR filter often has an infinite


number of coefficients.
IIR Filters
I

Require fewer calculations than FIR filters.

Faster response to the input signal,

and shorter frequency response transition width.

However!
I

IIR filters can become unstable.

Need to think carefully about stability when designing IIR


Filters.

Outline

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

IIR Filter Design Overview

1. Filter specification
2. Coefficient calculations
3. Convert transfer function to suitable filter structure
4. Error analysis
5. Implementation

Filter Specification
Frequency domain parameters - for filter description.
1+ p
passband ripple
1
1 p

I Stop band - high

attenuation
I Pass band - low

attenuation (gain1)

s1

p1

Pass Band

Tr
a
W nsit
idt ion
h

Stop Band

Tr
an
W sitio
idt
h n

p2

s2

Stop Band

Filter Specification
Frequency domain parameters - for filter description.
1+ p
passband ripple
1

I p passband ripple

1 p

I s stopband ripple
I s1 lower stop band

edge frequency
I p1 lower pass band

edge frequency
I p2 upper pass band

edge frequency

s1

p1

Pass Band

Tr
a
W nsit
idt ion
h

Stop Band

Tr
an
W sitio
idt
h n

I s2 upper stop band

p2

s2

Stop Band

edge frequency

Outline

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

Pole-Zero Placement Method


A filter can be described in the z-plane with Poles and Zeros
(Lecture 04):
H(z) =

K(z z1 )(z z2 )(z z3 )...


zeros
Y (z)
=
=
X(z)
(z p1 )(z p2 )(z p3 )...
poles

Poles located at:


z1 , z2 , z3 , ...

Zeros located at:


p1 , p2 , p3 , ...

Pole-Zero Placement Method

A filter can be described in the z-plane with Poles and Zeros


(Lecture 04):
H(z) =

Poles (X) close to unit circle


I

K(z z1 )(z z2 )(z z3 )...


zeros
Y (z)
=
=
X(z)
(z p1 )(z p2 )(z p3 )...
poles

make large peaks

Zeros (O) close to unit circle


I

make troughs or minima

Pole-Zero Placement Method


Angle of poles and zeros on z-plane correspond to frequencies that can be used
for filter specification.
I A bandpass filter, with centre frequency 0 radians can have two poles at

0 radians in the z-plane1 .


I Complete attenuation at two frequencies, r1 = 0 radians and r2 =

radians can have two zeros at 0 and radians.

calculated with:
r
= 1 cf

|H ( ) |

I The radius of the poles can be

or

bw
r
=1
2
where bw = 2cf is the -3dB
bandwidth of the filter.
1

Band Pass

0
(DC)

0cf

0+cf
0

Complex conjugate pair to make real filter coefficients, when 0 6=0 or


0 6= radians (on the real line).

Pole-Zero Placement Method: Example


Q. Design a bandpass filter using the Pole-zero placement method with:
I centre frequency at 0 = /2;
I a bandwidth of bw = /8;
I complete attenuation at r1 = 0 and r2 = ;
I and peak unity pass band gain.
A. Bandpass filter has x2 poles at 0 = /2 radians.
H(z) = K

zeros
(z r exp(j/2))(z r exp(j/2))

The radii of the poles are given by:


bw
/8
r
=1
= 0.80365;
=1
2
2
and the zeros are at r1 = 0 and r2 = , so that
H(z) = K

(z exp(jr1 ))(z exp(jr2 ))


.
(z 0.80365 exp(j/2))(z 0.80365 exp(j/2))

Pole-Zero Placement Method: Example contd.


As
I exp(r1 ) = exp(j0) = cos(0) + j sin(0) = 1 j0 = 1
I exp(r2 ) = exp(j) = cos() + j sin() = 1 + j0 = 1,
then the transfer function becomes:
H(z) = K

(z 1)(z + 1)
.
(z 0.80365 exp(j/2))(z 0.80365 exp(j/2))

Using Eulers identity,


I exp(j/2) =
cos(/2) + j sin(/2) = +j
I and exp(j/2) =
cos(/2) j sin(/2) = j,
so that
H(z) = K

(z 1)(z + 1)
.
(z 0.80365j)(z + 0.80365j)

the pole zero diagram can then be


plotted.

Pole-Zero Placement Method: Example contd.


Recall that H(z) =

H(z) =

Y (z)
,
X(z)

Y (z)
(z 1)(z + 1)
z2 1
=K
=K 2
.
X(z)
(z 0.80365j)(z + 0.80365j)
z + 0.64585

Then
Y (z)(z 2 + 0.64585) = X(z)K(z 2 1).
Remembering that each z 1 is a unit delay, so that each z is a unit advance, then
the difference equation is:
y[n + 2] + 0.64585y[n] = K(x[n + 2] x[n])
which can be made causal by making n = n 2 so that
y[n] + 0.64585y[n 2] = K(x[n] x[n 2]).
K is not known, but can be used to make the peak pass band gain to be unity.

Pole-Zero Placement Method: Example contd.


The frequency response of the filter can be determined from the difference equation:
y[n] + 0.64585y[n 2] = K(x[n] x[n 2]),
in combination with:
M
P

H() =

Magnitude Frequency Response

b[k] exp(jk)

k=0
N
P

1+

.
a[k] exp(jk)

k=1

So that (using Eulers identity):


H() =

K(1 cos(2) + j sin(2))


1 + 0.64585(cos(2) j sin(2))

which has magnitude frequency


response:
Mag(H())2 =

K((1 cos(2))2 + sin2 (2))


.
(1 + 0.64585 cos(2))2 + sin2 (2)

where K = 0.17708.

Pole-Zero Placement Method: Example contd.

Relating the digital frequencies for previous example to


actual frequencies...
If the sampling frequency is fs = 500Hz, the sampling frequency
corresponds to = 2, therefore the filter parameters become:
I

centre frequency at 0 = /2, so actual centre frequency


f0 = /2
2 fs = 125Hz;

a bandwidth of bw = /8, so actual bandwidth


fbw = 31.25Hz;

complete attenuation at r1 = 0 and r2 = , with actual

frequencies fr1 = 0Hz and fr2 = 2


500 = 250Hz.

Pole-Zero Placement Method,


Example 2: Band Stop Filter

|H ( ) |

Q. Design digital bandstop filter using pole-zero placement


method with the following parameters:
I Centre frequency, 0 = /10 radians (complete attenuation)
I Band stop width, w = 2cf = /20 radians

tion

No

ua
tten

Band Stop

atio

No

nu
Atte

Attenuation
0
(DC)

0cf

0+cf
0

Pole-Zero Placement Method,


Example 2: Band Stop Filter
I Complete attenuation at 0 = /10, x2 zeros (complex-conjugate pair)

at 0 = /10:
H(z) = K

(z exp(j/10))(z exp(j/10))
poles

I Centre frequency at 0 = /10 radians, x2 poles (complex-conjugate

pair) at 0 = /10,
H(z) = K

(z exp(j/10))(z exp(j/10))
(z r exp(j/10))(z r exp(j/10))

I The poles are scaled with radius r to control the width of the band

stop,
/20
w
r
=1
= 0.92146
=1
2
2
I resulting in:

H(z) = K

(z exp(j/10))(z exp(j/10))
(z 0.92146 exp(j/10))(z 0.92146 exp(j/10))

Pole-Zero Placement Method,


Example 2: Band Stop Filter contd.
I Transfer function is then (using Eulers identity like before):

H(z) = K

z 2 1.9021z + 1
z 2 1.7527z + 0.84909

I As before, each z is a unit advance, so

y[n+2]1.7527y[n+1]+0.84909y[n] = K(x[n+2]1.9021x[n+1]+x[n])
letting n = n 2, making it causal:
y[n]1.7527y[n1]+0.84909y[n2] = K(x[n]1.9021x[n1]+x[n2]).
I With frequency response:
M
P

H() =

b[k] exp(jk)

k=0
N
P

1+

k=1

=
a[k] exp(jk)

K(1 1.9021 exp(j) + exp(j2))


.
1 1.7527 exp(j) + 0.84909 exp(j2)

Pole-Zero Placement Method,


Example 2: Band Stop Filter contd.
Using Eulers identity:
H(z) =

K(1 1.9021(cos j sin ) + cos 2 j sin 2)


.
1 1.7527(cos j sin ) + 0.84909(cos 2 j sin 2)

Magnitude Frequency response is then:


Mag(H(z))2 =
K((1 1.9021 cos + cos 2)2 + (1.9021 sin sin 2)2 )
.
(1 1.7527 cos + 0.84909 cos 2)2 + (1.7527 sin 0.84909 sin 2)2 )

Magnitude frequency
response of the notch or
bandstop filter:

Outline

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

Converting Analogue Filters to Digital Filters

Most common approach for IIR filter design.


I

Use well-established analogue filter specifications to design


digital IIR filters

Two common approaches:


I

Impulse invariant method

Bilinear transformation

Laplace Transform
I

Analogue filter transfer function h(t) can be specified in the


s-plane with the Laplace transform L(h(t)) = H(s)

Hence, the s-plane is for analogue instead of the z-plane (for


digital).
Can be used to analyse stability of analogue filters,

Similar to the z-transform for digital filters.

Discrete (z-plane)
Imaginary Axis

ON
GI
RE
BL
E

EG
I

ON

UN

ST
A

ER

I
EG

ON

UN

ER
BL

Real Axis

E
BL

A
ST

ST

Analogue (s-plane)

UN
ST
AB
L

ON

ON

GI

RE

GI

ST
UN

LE
AB

RE

ON
GI
RE
E
L

AB

L
AB
ST

N
IO
EG
ER
T

S
UN

Laplace Transform

Analogue filter transfer function h(t) can be specified in the


s-plane with the Laplace transform L(h(t)) = H(s)

Hence, the s-plane is for analogue instead of the z-plane (for


digital).
Can be used to analyse stability of analogue filters,

Similar to the z-transform for digital filters.

Discrete
z-transform Z(h[n])
z-plane H[z]
Difference equation, h[n]

Analogue
Laplace transform L(h(t))
s-plane H(s)
Differential equation h(t)

How to Convert Analogue Frequency to Digital?

Problem!
I

Analogue frequency, = 0....

But digital frequency, = 0...2.

So how to convert analogue frequency to digital?


Need to swap analogue frequencies with digital frequencies...
I

If 2 then Very high analogue frequencies ( )

If 0 then Very low analogue frequencies ( 0).

Bilinear Transformation IIR Filter Design


Bilinear Transformation method replaces analog frequency s or
j with digital frequency using:
 

2
.
s = j = j tan
Ts
2
where is analogue frequency, is digital frequency and
Ts = 1/fs is the sampling period.
OR
to find the z-transform H(z):

s = j = 2fs

1 z 1
1 + z 1


.

Bilinear Transformation IIR Filter Design


Example:
Given an analog filter with:
H() = H(s)|s=j =

K(j z1 )(j z2 )...


(j p1 )(j p2 )...

Then bilinear transformation gives


H() = H(s)|s=j2fs tan( )
2


K(j2fs tan 2 z1 )(j2fs tan 2 z2 )...




=
(j2fs tan 2 p1 )(j2fs tan 2 p2 )...
or...
H(z) = H(s)|s=2f 1z1
s
1+z 1
 1 
 1 
1z
K(2fs 1z

z
)(2f
1
s 1+z 1 z2 )...
1+z 1




=
1
1z 1
(2fs 1z

p
)(2f
p2 )...
1
s
1
1
1+z
1+z

Bilinear Transformation Example


Q. Convert the single pole low pass analog filter:
H(s) =

cf
s + cf

into a digital filter (z-plane form) with digital cut-off frequency cf = 0.2
using the bilinear transformation.
A.
1. Calculate analogue cut-off frequency cf from digital cut-off frequency
cf = 0.2:
cf = 2fs tan(cf /2) = 2fs tan(0.1) = 2fs A
2. Therefore analogue transfer function:
H(s) =

2fs A
s + 2fs A
1

3. Apply bilinear transformation: s = 2fs 1z


:
1+z 1
H(z) =

2fs A
1
2fs 1z
1+z 1

+ 2fs A

2fs
2fs

A(1 + z 1 )
(1
+ A(1 + z 1 )
z 1 )

Bilinear Transformation Example contd.

The z-transform transfer function of the filter is then:


H(z) =

Y (z)
A + Az 1
=
X(z)
1 + A + (A 1)z 1

Stability Analysis
Rearranging to determine the poles for stability analysis gives:
H(z) =

I So there is 1 pole at z +

A1
1+A

z+1
A
.
1 + A z + A1
1+A
= 0 or z = A1
.
1+A

I Remember A = tan(0.1), so the pole is: z = 0.50953,


I the magnitude is less than 1, so the filter is stable.

(1)

Bilinear Transformation Example contd.


Difference Equation
The difference equation can now be found.
Multiplying both sides by both denominators of equation (1) results in

Y (z) 1 + A + (A 1)z 1 = X(z) A + Az 1


Remembering that each z 1 is a unit delay, so that
(1 + A)y[n] + (A 1)y[n 1] = Ax[n] + Ax[n 1]
Dividing through by (1 + A) and rearranging gives
y[n] =

A1
A
(x[n] + x[n 1])
y[n 1],
1+A
1+A

where A = tan(0.1).
This is now a difference equation we can use to filter a signal.

Bilinear Transformation Example contd.


Frequency Response
The frequency response can be found directly using the bilinear transformation
or from the z-transform transfer function. We will compare both approaches.

Bilinear Transformation
The analogue transfer function from step 2 in earlier slide was:
H(s) =

2fs A
s + 2fs A

The s-plane variable s can be replaced by the Fourier complex frequency


variable j,

2fs A

=
H() = H(s)
.
j + 2fs A
s=j
The Fourier `frequency
can then be converted to the digitial frequency using

= 2fs tan 2 (see earlier slide):

H() = H()

=2fs tan(

2fs A
A
`
`
=
j2fs tan 2 + 2fs A
j tan 2 + A

Bilinear Transformation Example contd.


So the magnitude frequency response calculated directly from the Bilinear
transformation is:
s
s
(tan(0.1))2
A2
= `
|H()| = `
` 2
` 2
2
+A
+ (tan(0.1))2
tan 2
tan 2

The designed cut-off frequency cf = 0.2 is confirmed by this plot.

Bilinear Transformation Example contd.


Frequency Response from z-Transform Transfer Function
Remember the z-transform transfer function calculated earlier (equation (1)):
H(z) =

Y (z)
A + Az 1
.
=
X(z)
1 + A + (A 1)z 1

This can be converted to the frequency response using (see earlier slides and
lecture 04)
M
P

H() = H(z)

=
z=exp(jk)

k=0
N
P

b[k] exp(jk)
a[k] exp(jk)

k=0

So:
I b[0] = b[1] = A,
I a[0] = 1 + A,
I a[1] = A 1.

So the frequency response is given by (using Eulers identity):


H() =

A + A(cos() j sin())
(1 + A) + (A 1)(cos() j sin()).

Bilinear Transformation Example contd.


So the magnitude is given by:
s
|H()| =

(A + A cos())2 + (A sin())2
((1 + A) + (A 1) cos())2 + ((A 1) sin()))2 .

which is the same as the frequency response calculated directly from the
bilinear transformation. The Bilinear transformation is more quicker here.

Famous Analogue Filters


Butterworth
I

Magnitude frequency response: |H()| =

1
2n ff1/2

1+
cf

Chebyshev
Magnitude frequency response: |H()| =

|H ( ) |
magnitude response

2
1+2 Cn

Ideal

1.0 1/2
2
(1+ )

Chebyshev

0.707

Butterworth

cf

frequency

cf

o1/2

Butterworth and Chebyshev Analog Filters

Bilinear transformation: j = j2fs tan(/2), therefore:


Magnitude Frequency Response
(Analogue)
(Digital)
|H()|
|H()|
Butterworth

2n 1/2
1+
cf

Chebyshev

2
1+2 Cn

1

2n 1/2
tan(/2)
1+ tan( /2)
cf

cf

i1/2

2
1+2 Cn

tan(/2)
tan(cf /2)

i1/2

Comparison of IIR and FIR filters

Characteristic
Multiplications
Coefficient quantification sensitivity
Overflow errors
Stability
Linear phase
Simulate analog filter
Coefficient memory
Design complexity

IIR
least
can be high

FIR
most
very low

can be high
by design
no
yes

very low
always
always
no

least
moderate

most
simple

adapted from Understanding digital signal processing by R. G. Lyons

Outline

Introduction

IIR Filter Design

Pole-Zero Placement Method

IIR Filter Design from Analogue Filters

Summary

Lecture Summary

This lecture has covered:


I

Introduction to IIR filters.

Frequency domain parameters.

Pole-zero placement method for IIR filter design

Band stop filter design

IIR filter design from analog filters using bilinear


transformation method

Вам также может понравиться