Vous êtes sur la page 1sur 28

# Infinite Impulse Response (IIR) Filters

Recursive Filters:
y n a y n a y n N b x n b x n N
N N
( ) ( ) ... ( ) ( ) ... ( ) + + + = + +
1 0
1
with constant coefficients.
a b
i j
, ... ,
Advantages: very selective filters with a few parameters;
Disadvantages: a) in general nonlinear phase,
b) can be unstable.
Design Techniques: discretization of analog filters
s-plane
z-plane

analog digital
H s
a
( )

H z
d
( )
Problem: we need to map
the derivative operator s into the time shift operator z,
and make sure that the resulting system is still stable.

Two major techniques
Euler Approximation (easiest),
Bilinear Transformation (best).
| |
Z y nT
Y z z Y z
T
z
T
Y z ( )
( ) ( )
( ) =

=
|
\

|
.
|
1 1
1
Euler Approximation of the differential operator:
take the z-Transform of both sides:
( )
( ) ( )
y nT
y nT y nT T
T
~

approximation of s
s
z
T
=

1
1
Example:
take the analog filter with transfer function and discretize it
with a sampling frequency .
By Eulers approximation
H s
s
a
( ) =
+
2
1
F Hz
s
= 5
H z
z
z
z
d
( )
.
.
.
=
|
\

|
.
| +
=

2
1
02
1
0333
0833
1
The filter is implemented by the difference equation
y n y n x n ( ) . ( ) . ( ) = + 0833 1 0333
s-plane
z-plane

analog digital

## Problem with Euler Approximation:

it maps the whole stable region of the s-plane into a subset of the stable region in the z-plane
s-plane z-plane
since
|
|
|
|
.
|

\
|

+
=

=
T
s
T
s
sT
z
1
1
2
1
2
1
1
1
2
1
1
T

1
T
-
s
z <
1
2
1
2

if Re[s]<0.
Bilinear Transformation. It is based on the relationship
| |
y nT y nT T y t dt y nT y nT T
T
nT T
nT
area ABCD
( ) ( ) ( ) ( ) ( ) = ~ +

}
2

nT-T nT
A
B
C
D
Take the z-Transform of both sides:
| |
Y z z Y z
T
Y z z Y z ( ) ( ) ( ) ( ) = +
1
1
1
1
2
which yields the bilinear transformation:
s
T
z
z
z
s
T
s
T
=

+
=
+

2 1
1
2
2
1
1
Main Property of the Bilinear Transformation: it preserves the stability regions.
s-plane z-plane
| | z
s
T
s
T
=
+

s
2
2
1
2
T
2
T

-
s since:
Mapping of Frequency with the Bilinear Transformation.
| | e
j
T
j
T
je
=
+

=
O
O
2
2
1
2
T

2
T
-
jO
2
phase ( ) 2
2
j
T
j
T
e u u u
| |
O+
|
= = =
|
|
O+
\ .
jO
jO
2
T
u
u
Magnitude:
Phase:
where
u =
|
\

|
.
|

tg
T
1
2
O
O =
|
\

|
.
|
2
2 T
tg
e
e =
|
\

|
.
|

2
2
1
tg
T O

O =
|
\

|
.
|
2
2 T
tg
e
e =
|
\

|
.
|

2
2
1
tg
T O

## it is a frequency mapping between analog frequency and digital freqiency.

O
c
0
e
t t
0
+
O
O
c
e
c
e
c
Example: we want to design a digital low pass filter with a bandwith
and a sampling frequency . Use the Bilinear Transformation.
F kHz
o
= 8
F kHz
s
= 24
Step 1: specs in the digital freq. domain
Step 2: specs of the analog filter to be digitized:
e t t
c
rad = = ( )(8/ ) / 2 24 2 3
Solution:
O
c s
c
F tg tg rad =
|
\

|
.
| = = 2
2
2 24 10 3 8313 10
3 3
e
t ( )( ) ( / ) . / sec
or equivalently
F kHz
c
=1323 .
Step 3: design an analog low pass filter (more later) with a bandwith ;
Step 4: apply Bilinear Transformation to obtain desired digital filter.
F kHz
c
=1323 .
Design of Analog Filters
Specifications:
O
O
p
O
c
O
s
1
1
2
+ c
1
2
o
2
2
| ( )| H O
2
pass
band
transition
band
stop
band
Two Major Techniques: Butterworth, Chebychev
Butterworth:
| ( )| H
c
N
p
N
O
O
O
O
O
2
2
2
2
1
1
1
1
=
+
|
\

|
.
|
=
+
|
\

|
.
|
c
Specify from passband, determine N from stopband:
c , O
p
| ( )| H
s
s
p
N
O
O
O
2
2
2 2
2
1
1
=
+
|
\

|
.
|
=
c
o
N
s
p
=

|
\

|
.
|
|
\

|
.
|
log
log
1
2
2
2
2
2
2
o
c o
O
O
Poles of Butterworth Filter:
| ( )| ( ) ( ) H H s H s
s j
O
O
2
=
=

H s H s
c
N
s
j
( ) ( ) =
+
|
\

|
.
|
=
1
1
2
O
O
O
=
+

|
\

|
.
|
1
1
2
2
s
c
N
O
which yields the poles as solutions
( )

=
s
c
N
2
2
1
1
O

s j e e e
c
j
k
N
c
j j k
N
= =
+
+
O O
t t t t 2
2 2
2 1
2
( )
, ,..., k N = 0 2 1
and choose the N poles in the stable region.
s-plane
+ +
+ +
N=2
poles
Example: design a low pass filter, Butterworth, with 3dB bandwith of 500Hz and 40dB
attenuation at 1000Hz.
Solution: O O
c s
= = 1000 2000 t t ; ,
solve for N from the expression

1
1
1
1 2
001
2 2
2
+
|
\

|
.
|
=
+
=
O
O
s
c
N N
.
N N =

= =
log( )
log( )
.
10 1
2 2
6 64 7
4
poles at
s e k
k
j k
= =
+ +
1000 0 6
2 2 1 14
t
t t ( / ( ) / )
, ,...,
| ( )| H
dB
O
O
Chebychev Filters.
Based on Chebychev Polynomials:
T x Nt
N
x t
( ) cos( )
cos( )
=
=
T x
T x t x
T x t t x
T x xT x T x
x t
x t
N N N
0
1
2
2 2
1 1
0 1
2 2 1 2 1
2
( ) cos( ) ,
( ) cos( ) ,
( ) cos( ) cos ( ) ,
( ) ( ) ( )
cos( )
cos( )
= =
= =
= = =
=
=
=
+

T x
3
( )
x
Property of Chenychev Polynomials:
within the interval Chebychev polynomials have least maximum deviation
from 0 compared to polynomials of the same degree and same highest order coefficient
s s + 1 1 x
T x x x
3
3
4 3 ( ) =
P x x ax bx c ( ) = + + + 4
3 2
x
Why? Suppose there exists with smaller deviation then
P x x ax bx c ( ) = + + + 4
3 2
T x
3
( )
T x
3
( )
P x ( )
P x T x ( ) ( )
3
P T > =
3
1
P T < = +
3
1
P T > =
3
1
A
B
P T < = +
3
1
D
A
B
C
C
D
+
+

root
root
root
But: has degree 2

and it cannot have three roots!!!
P x T x x ax bx c x x ( ) ( ) = + + + +
3
3 2 3
4 4 3
So: you cannot find a P(x) which does better (in terms of deviation from 0) then the
Chebychev polynomial.
Chebychev Filter:
| ( )| H
T
N
p
O
O
O
2
2 2
1
1
=
+
|
\

|
.
|
c
Since (easy to show from the definition), then
T
N
( ) 1 1 =
| ( )| H
p
O
2
2
1
1
=
+c
O
O
p
| ( )| H O
2
1
1
2
+c
Design of Chebychev Filters:
Formulas are tedious to derive. Just give the results:
Given: the passband, and
which determines the ripple in the passband,
compute the poles from the formulae
O
p
c
|
c
c
=
+ +
|
\

|
.
|
|
1 1
2
1
N
r
1 2
2
1
2
,
=
|
|
s-plane
|
t t
k
k
N
k N = + + =
2
2 1
2
0 1 ( ) , ,...,
Example: design a Chebychev low pass filter with the following specs:
passband with a 1dB ripple,
stopband with attenuation of at least 40dB.
F Hz
p
= 500 ,
F Hz
s
=1000 ,
Step 1: determine . The passband frequency
For 1dB ripple,
c , O
p
20
1
1
10 1 1
2
1
2
2
log log( )
+
|
\

|
.
| = + =
c
c dB

c = 05088 .
O
p
= 1000t
Step 2: determine the order N. Use the formula
( )
| |
| |
N
s p s p
=
+ +
+
log ( /
log ( / ) ( / )
1 1 1
1
2
2
2
2 2
2
2
o o c c o
O O O O
with , to obtain
o
2
001 = . N =4
| ( )| H O
O
O
p
Frequency Transformations
We can design high pass, bandpass, bandstop filters from transformations of low pass filters.
Low Pass to High Pass:
O
O
| ( )| H O
H
j
c
O
O
2
|
\

|
.
|
O
c
O
c O
c
O
c
same value at
O
c
H
j
H
j
H j
c
c
c
c
O
O
O
O
2
|
\

|
.
| =
|
\

|
.
| = ( )
s
s
c

O
2
Low Pass to Band Pass:
O
c
O
c
O
u
O
l O
l
O
u
s
s
s
c
l u
u l

O
O O
O O
2
( )
The tranformation
maps
s j
j
j
s j
j
j
l c
l l u
l u l
c
u c
u l u
u u l
c
=
+

=
=
+

= +
O O
O O O
O O O
O
O O
O O O
O O O
O
2
2
( )
( )
Low Pass to Band Stop
O
c
O
c
O
l
O
u
O
l
O
u
s
s
s
c
u l
c l

+
O
O O
O O
( )
2
How to make the transformation:
Consider the transfer function
H s
K s z s z s z
s p s p s p
m n
m
n
( )
( )( )...( )
( )( )...( )
, =

<
1 2
1 2
then with we obtain
s F s ( )
( )
( ) ( )
( ) ( )
H s H F s
K F s z F s z
F s p F s p
T
m
n
( ) ( )
( ) ... ( )
( ) ... ( )
= =

1
1
with zeros and poles solutions of
F s z k m
F s p j n
k
j
( ) , ,...,
( ) , ,...,
= =
= =
1
1

## also n-m extra zeros at s where F s ( ) =

IIR filter design using Matlab
In Matlab there are three functions for each class of filters (Butterworth, Chebytchev1, Chebytchev2):
BUTTAP CHEB1AP CHEB2AP Poles and Zeros of Analog Prototype Filter
BUTTER CHEBY1 CHEBY2 Numerator and Denominator from N and
BUTTORD CHEBY1ORD CHEBY2ORD N and from specifications

c
O
c
O
Example. We want to design an IIR Digital Filter with the following specifications:
Pass Band 0 to 4kHz, with 1dB ripple;
Stop Band > 8kHz with at least 40 dB attenuation
Sampling frequency 40kHz
Type of Filter: Butterworth.
Using Matlab:
>> [N, fc]=butterord(fp, fs, Rp, Rs); % fp, fs=passband and stopband freq relative to Fs/2
>> [B, A]=butter(N, fc); % B, A vectors of numerator and denominator coefficients.
In our case:
[N, fc]=butterord(4/20, 8/20, 1, 40), would yield N=7, fc=0.2291;
[B, A]=butter(7, 0.2291), would yield the transfer function B(z)/A(z).
Lets verify these numbers:
Step 1: specifications in the digital frequency domain:
e t
t
e t
t
p
s
rad
rad
= =
= =
2
4
40 5
2
8
40
2
5
band pass freq
stop band freq
Step 2: specifications for analog filter from the transformation O =
|
\

|
.
| 2
2
F
s
tan
e
O
O
p
s
rad
rad
=
|
\

|
.
| =
=
|
\

|
.
| =
2 40 10
10
26 10
2 40 10
5
58 10
3 3
3 3
( ) tan / sec
( ) tan / sec
t
t
Step 3: choose (say) Butterworh Filter
H
p
N
( ) O
O
O
2
2
2
1
1
=
+
|
\

|
.
|
c
with and from the ripple specification O
p
rad = 26 10
3
/ sec
c
20
1
1
1 05
10 2
1
2
log .
+
|
\

|
.
| = =
c
c
Step 4: determine order N from attenuation of 40dB
40
5 . 0 1
1
log 10
2
2
10
=
|
|
.
|

\
|
O
O
+
N
p
s
with yields N=7
O
O
s
p
=
58
26
Step 5: finally the cutoff frequency, from the equation
H
c
c
( )
.
O
O
2
2
3
14
1
1 05
26 10
1
2
=
+

|
\

|
.
|
=
Which yields , corresponding to a digital frequency
O
c
rad = 28 7 10
3
. / sec
e
c
=

|
\

|
.
| = 2
28 7
2 40
0 6889 atan radians
.
.
Step 6: the desired Filter is obtained by the function
[num, den] = butter( 7 , 0.6889/t)
Magnitude and Phase Plots: