Transcript 9-IIR
Infinite Impulse Response (IIR) Filters
Recursive Filters:
y(n) a1 y(n 1) ...a N y(n N ) b0 x(n) ...bN x(n N )
with ai , ... , b j
Advantages:
Disadvantages:
constant coefficients.
very selective filters with a few parameters;
a) in general nonlinear phase,
b) can be unstable.
Design Techniques: discretization of analog filters
analog
digital
s-plane
z-plane
Ha ( s)
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).
Euler Approximation of the differential operator:
y (nT ) y (nT T )
y (nT )
T
take the z-Transform of both sides:
approximation of “s”
Y ( z) z 1Y ( z) 1 z 1
Z y (nT )
Y ( z)
T
T
1 z 1
s
T
Example:
take the analog filter with transfer function
H a ( s)
with a sampling frequency Fs 5Hz .
2
s 1
and discretize it
By Euler’s approximation
Hd ( z)
2
0.333 z
z 0.833
1 z 1
1
0.2
The filter is implemented by the difference equation
y (n) 0.833 y (n 1) 0.333x (n)
analog
digital
s-plane
z-plane
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
s
since
1
s
1
1
1 1
T
z
2 1 sT 2 2 s 1
T
1
1
z
2
2
if Re[s]<0.
1
T
1
T
Bilinear Transformation. It is based on the relationship
T
y(nT ) y(nT T )
y (t )dt y (nT ) y (nT T )
nT T
2
nT
area ABCD
C
Take the z-Transform of both sides:
T
Y ( z ) z Y ( z ) Y1 ( z ) z 1Y1 ( z )
2
1
B
A
nT-T
which yields the bilinear transformation:
2 1 z 1
s
T 1 z 1
2
s
T
z
2
s
T
D
nT
Main Property of the Bilinear Transformation: it preserves the stability regions.
s-plane
z-plane
s
since:
2
T
2
s
T
s
| z|
1
2
T
2
T
Mapping of Frequency with the Bilinear Transformation.
Magnitude:
| e j |
2
j
T
2
j
T
j
1
2
T
2
T
Phase:
2
j
T
phase
( ) 2
2
j
T
1 T
where
tg
2
T
2tg
2
1
j
2
T
j
2
tg
T 2
See the meaning of this:
T
2tg
2
1
2
tg
T
2
it is a frequency mapping between analog frequency and digital freqiency.
c
c
0
c
0
c
Example: we want to design a digital low pass filter with a bandwith Fo 8kHz
and a sampling frequency
Fs 24kHz . Use the Bilinear Transformation.
Solution:
• Step 1: specs in the digital freq. domain
c (2 )(8 / 24) 2 / 3 rad
• Step 2: specs of the analog filter to be digitized:
c
c 2 Fs tg
. 103 rad / sec
(2)(24 103 ) tg ( / 3) 8313
2
or equivalently
Fc 13.23kHz
• Step 3: design an analog low pass filter (more later) with a bandwith Fc 13.23kHz ;
• Step 4: apply Bilinear Transformation to obtain desired digital filter.
Design of Analog Filters
| H()|2
Specifications:
1
1
2
1
2
2 2
p
pass
band
c
transition
band
s
stop
band
Two Major Techniques: Butterworth, Chebychev
Butterworth:
| H ()|
2
1
1
c
2N
Specify , p from passband, determine
| H ( s )|
2
1
2 s
1
p
2N
2 2
1
2
1
p
2N
N from stopband:
1 2 2
log 2 2
2
N
s
2 log
p
Poles of Butterworth Filter:
| H ()| H ( s) H ( s) s j
2
H ( s) H ( s)
1
1
c
2N
s
j
1
s
1 2
c
2
N
which yields the poles as solutions
1
s2
N
2 1
c
s jce
j
k 2
2N
j
c e 2 e
j ( 2 k 1)
2N
, k 0,...,2 N 1
N=2
and choose the N poles in the stable region.
+
+
+
+
poles
s-plane
Example: design a low pass filter, Butterworth, with 3dB bandwith of 500Hz and 40dB
attenuation at 1000Hz.
c 1000 ; s 2000 ,
Solution:
solve for N from the expression
1
s
1
c
2N
1
2
2 N 0.01
1 2
| H ()|dB
log(104 1)
N
6.64 N 7
2 log(2)
poles at
sk 1000 e j ( / 2( 2 k 1) /14) , k 0,...,6
Chebychev Filters.
Based on Chebychev Polynomials:
TN ( x ) cos( Nt ) x cos( t )
T0 ( x ) cos(0) 1,
T3 ( x )
T1 ( x ) cos(t ) x cos( t ) x ,
T2 ( x ) cos(2t ) 2 cos2 (t ) 1 x cos( t ) 2 x 2 1,
TN 1 ( x ) 2 xTN ( x ) TN 1 ( x )
x
Property of Chenychev Polynomials:
within the interval 1 x 1 Chebychev polynomials have least maximum deviation
from 0 compared to polynomials of the same degree and same highest order coefficient
P( x) 4 x 3 ax 2 bx c
T3 ( x) 4 x 3 3x
x
Why? Suppose there exists
P T3 1
T3 ( x )
P( x) 4 x3 ax2 bx c
with smaller deviation then
P T3 1
B
D
P( x ) T3 ( x )
A
P( x)
T3 ( x )
C
A
P T3 1
C
root B
P T3 1
But: P( x) T3 ( x) 4 x 3 ax 2 bx c 4 x 3 3x
…
root
root
has degree 2 …
and it cannot have three roots!!!
So: you cannot find a P(x) which does better (in terms of deviation from 0) then the
Chebychev polynomial.
D
Chebychev Filter:
| H ()|
1
2
1 TN
p
2
2
Since TN (1) 1 (easy to show from the definition), then | H ( p )|2
| H()|2
1
1
p
2
1
1 2
Design of Chebychev Filters:
Formulas are tedious to derive. Just give the results:
Given: p
the passband, and
which determines the ripple in the passband,
compute the poles from the formulae
1 1
2
1
N
2 1
r1,2
2
k
s-plane
2
(2 k 1)
2N
, k 0,..., N 1
Example: design a Chebychev low pass filter with the following specs:
• passband Fp 500Hz,
with a 1dB ripple,
Fs 1000Hz,
• stopband
Step 1: determine
For 1dB ripple,
, p
with attenuation of at least 40dB.
. The passband frequency p 1000
1
2
1
2
20 log
10
log(
1
) 1dB
1 2
| H ()|
Step 2: determine the order N. Use the formula
N
0.5088
1 1 (1 /
log( / ) ( / ) 1
2
log
2
2
2
2
2
2
s
p
with 2 0.01, to obtain N 4
s
p
p
Frequency Transformations
We can design high pass, bandpass, bandstop filters from transformations of low pass filters.
Low Pass to High Pass:
s
| H ()|
c
c
c2
s
c2
H
j
same value at
c
c
c 2
c
H H ( jc )
H
j
jc
c
Low Pass to Band Pass:
c
u
l
l
The tranformation
maps
c
s2 l u
s c
s(u l )
s j l
l 2 l u
c
j c
j l ( u l )
s j u
u 2 l u
c
j c
j u ( u l )
u
Low Pass to Band Stop
c
u
l
c
l
s(u l )
s c 2
s cl
u
How to make the transformation:
Consider the transfer function
K ( s z1 )( s z2 )...( s zm )
H ( s)
, mn
( s p1 )( s p2 )...( s pn )
then with s F ( s)
we obtain
HT ( s) H F ( s)
K F ( s) z1 ... F ( s) zm
F ( s) p ... F ( s) p
1
with zeros and poles solutions of
F ( s) zk , k 1,..., m
F ( s) p j , j 1,..., n
also n-m extra zeros at s where F ( s)
n
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 c
BUTTORD
CHEBY1ORD
CHEBY2ORD
N and c from specifications
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);
>> [B, A]=butter(N, fc);
% fp, fs=passband and stopband freq relative to Fs/2
% 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).
Let’s verify these numbers:
Step 1: specifications in the digital frequency domain:
4
p 2 rad
40 5
8 2
s 2
rad
40 5
band pass freq
stop band freq
2
Step 2: specifications for analog filter from the transformation 2 Fs tan
p 2(40 10 ) tan 26 103 rad / sec
10
3
s 2(40 103 ) tan 58 103 rad / sec
5
1
2
H ( )
Step 3: choose (say) Butterworh Filter
with
p 26 103 rad / sec
and
2
1
p
from the ripple specification
1
2
1
20 log10
0.5
2 1
1
Step 4: determine order N from attenuation of 40dB
10 log10
1
s
1 0.5
p
2
with
s 58
p 26
yields
N=7
2N
2N
40
Step 5: finally the cutoff frequency, from the equation
1
2
H ( c )
Which yields
c
2
1 0.5
26 103
c 28.7 103 rad / sec
14
1
2
, corresponding to a digital frequency
28.7
c 2atan
0.6889 radians
2 40
Step 6: the desired Filter is obtained by the function
[num, den] = butter( 7 , 0.6889/)
Magnitude and Phase Plots: