Object Recognition

advertisement
FIR and IIR Filter Design
Techniques
FIR 與 IIR 濾波器設計技巧





Speaker: Wen-Fu Wang 王文阜
Advisor: Jian-Jiun Ding 丁建均 教授
E-mail: r96942061@ntu.edu.tw
Graduate Institute of Communication Engineering
National Taiwan University, Taipei, Taiwan, ROC
Feb.2008
DISP Lab
1
Outline
 Introduction
 IIR Filter Design by Impulse
invariance method
 IIR Filter Design by Bilinear
transformation method
 FIR Filter Design by Window function
technique
Feb.2008
DISP Lab
2
Outline
 FIR Filter Design by Frequency
sampling technique
 FIR Filter Design by MSE
 Conclusions
 References
Feb.2008
DISP Lab
3
Introduction
 Basic filter classification
 We put emphasis on the digital filter
now, and will introduce to the design
method of the FIR filter and IIR filter
respectively.
Analog Filter
Filter
FIR Filter
Digital Filter
Feb.2008
DISP Lab
IIR Filter
4
Introduction
 IIR is the infinite impulse response
abbreviation.
 Digital filters by the accumulator, the
multiplier, and it constitutes IIR filter
the way, generally may divide into
three kinds, respectively is Direct
form, Cascade form, and Parallel
form.
Feb.2008
DISP Lab
5
Introduction
 IIR filter design methods include the
impulse invariance, bilinear
transformation, and step invariance.
 We must emphasize at impulse
invariance and bilinear
transformation.
Feb.2008
DISP Lab
6
Introduction
 IIR filter design methods
Normalized analog
lowpass filter
Continuous frequency
band transformation
Impulse
Invariance
method
Bilinear
transformation
method
Step invariance
method
IIR filter
Feb.2008
DISP Lab
7
Introduction
 The structures of IIR filter
Direct
form 1
Direct form2
x(n)
Y(n)
z 1
b0
-a1
b0
x(n)
z 1
-a1
Y(n)
z 1
b1
b1
z
1
-a2
z 1
-a2
b2
b2
Feb.2008
z 1
DISP Lab
8
Introduction
 The structures of IIR filter
Parallel form
Cascade form
E
b0
x(n)
Y(n)
-a1
z 1
b1
-a2
z 1
b2
-c1
z 1
d1
-c2
z 1
d2
d0
-c1
z 1
d1
-c2
z 1
b0
x(n)
-a1
-a2
Feb.2008
DISP Lab
z
Y(n)
1
b1
z 1
9
Introduction
 FIR is the finite impulse response
abbreviation, because its design
construction has not returned to the
part which gives.
 Its construction generally uses Direct
form and Cascade form.
Feb.2008
DISP Lab
10
Introduction
 FIR filter design methods include the
window function, frequency sampling,
minimize the maximal error, and MSE.
 We must emphasize at window function,
frequency sampling, and MSE.
Window function
technique
Frequency
sampling technique
Minimize the
maximal error
Mean square
error
FIR filter
Feb.2008
DISP Lab
11
Introduction
 The structures of FIR filter
Direct form
Cascade form
b0
x(n)
b0
Y(n)
z 1
z 1
x(n)
Y(n)
b1
z 1 b1
z 1 d1
b2
z 1 b2
z 1 d2
z 1
b3
z 1
Feb.2008
b4
DISP Lab
12
IIR Filter Design by Impulse
invariance method
 The most straightforward of these is
the impulse invariance transformation
 Let hc (t ) be the impulse response
corresponding to H c ( s) , and define the
continuous to discrete time
transformation by setting h(n)  hc (nT )
 We sample the continuous time
impulse response to produce the
discrete time filter
Feb.2008
DISP Lab
13
IIR Filter Design by Impulse
invariance method
 The frequency response H '( ) is the
Fourier transform of the continuous
time function
hc (t ) 
*

 h (nT ) (t  nT )
n 
c
and hence
1 
2 

H '( )   H c  j (  k
)
T k 
T 

Feb.2008
DISP Lab
14
IIR Filter Design by Impulse
invariance method
 The system function is
1 
2 

H ( z ) |z esT   H c  s  jk
)
T k 
T 

 It is the many-to-one transformation
from the s plane to the z plane.
Feb.2008
DISP Lab
15
IIR Filter Design by Impulse
invariance method
 The impulse invariance
transformation does map the j -axis
and the left-half s plane into the unit
circle and its interior, respectively
j
Im(Z)
e sT

Re(Z)
1
S domain
Feb.2008
Z domain
DISP Lab
16
IIR Filter Design by Impulse
invariance method
 H '( ) is an aliased version of H c ( j )
H '( )

 The stop-band characteristics are
maintained adequately in the discrete time
frequency response only if the aliased tails
of H c ( j ) are sufficiently small.
0
Feb.2008
 /T
DISP Lab
2 / T
17
IIR Filter Design by Impulse
invariance method
 The Butterworth and Chebyshev-I
lowpass designs are more appropriate
for impulse invariant transformation
than are the Chebyshev-II and elliptic
designs.
 This transformation cannot be applied
directly to highpass and bandstop
designs.
Feb.2008
DISP Lab
18
IIR Filter Design by Impulse
invariance method
 H c ( s ) is expanded a partial fraction
expansion to produce
A
H ( s)  
ss
 We have assumed that there are no
multiple poles
N
k
c
k 1
N
hc (t )   Ak e u (t )
k
N
h(n)   Ak e sk nT u (n)
sk t
k 1
 And thus
k 1
N
Ak
H ( z)  
sk T 1
1

e
z
k 1
Feb.2008
DISP Lab
19
IIR Filter Design by Impulse
invariance method
 Example:
H c ( s) 
sa
( s  a)2  b 2
Expanding in a partial fraction
1/ 2
expansion, it produce H c (s) 
1/ 2

s  a  jb s  a  jb
The impulse invariant transformation
yields a discrete time design with the
1/ 2
1/ 2

system function H ( z ) 
(  a  jb )T 1
(  a  jb )T
Feb.2008
1 e
DISP Lab
z
1 e
z 1
20
IIR Filter Design by Bilinear
transformation method
 The most generally useful is the
bilinear transformation.
 To avoid aliasing of the frequency
response as encountered with the
impulse invariance transformation.
 We need a one-to-one mapping from
the s plane to the z plane.
 The problem with the transformation
is z  e sT many-to-one.
Feb.2008
DISP Lab
21
IIR Filter Design by Bilinear
transformation method
 We could first use a one-to-one
transformation from s to s ' , which
compresses the entire s plane into




Im(
s
')

the strip T

T
j
j
 /T

'
s’ domain
s domain
 / T
 Then s ' could be transformed to z by
s 'T with no effect from aliasing.
ze
Feb.2008
DISP Lab
22
IIR Filter Design by Bilinear
transformation method
 The transformation from
given by s '  2 tanh 1 ( sT )
T
s
to s ' is
2
 The characteristic of this
transformation is seen most readily
from its effect on the j axis.
 Substituting s  j and s '  j ', we
obtain  '  2 tan 1 ( T )
T
Feb.2008
2
DISP Lab
23
IIR Filter Design by Bilinear
transformation method
 The  axis is compressed into the
 
(

, ) for  ' in a one-tointerval
T T
one method
 The relationship between  and  '
is nonlinear, but it is approximately
linear at small  '  '.
 /T

Feb.2008
 / T
DISP Lab
24
IIR Filter Design by Bilinear
transformation method
 The desired transformation s to z is
now obtained by inverting s '  2 tanh 1 ( sT )
T
2
2
s
'
T
to produce s  tanh( )
T 1
2
 And setting s '  ( ) ln z , which yields
T
2
ln z
s  tanh(
)
T
2
2 1  z 1
 (
)
1
T 1 z
j
Im(Z)
Re(Z)

1
S domain
Feb.2008
T
1 s
2
z
T
1 s
2
DISP Lab
Z domain
25
IIR Filter Design by Bilinear
transformation method
 The discrete-time filter design is
obtained from the continuous-time
design by means of the bilinear
transformation
H ( z )  H c ( s) |s (2/T )(1 z 1 )/(1 z 1 )
 Unlike the impulse invariant
transformation, the bilinear
transformation is one-to-one, and
invertible.
Feb.2008
DISP Lab
26
FIR Filter Design by Window
function technique
 Simplest FIR the filter design is
window function technique
 A supposition ideal frequency
response may express
H d (e j ) 


n 
hd [n]e  jn
1
where hd [n] 
2
Feb.2008

H

DISP Lab
j
d
(e )e
j n
d
27
FIR Filter Design by Window
function technique
 To get this kind of systematic causal
FIR to be approximate, the most
direct method intercepts its ideal
impulse response!
h[n]  w[n] hd [n]
H ( )  W ( )  H d ( )
Feb.2008
DISP Lab
28
FIR Filter Design by Window
function technique
 Truncation of the Fourier series
produces the familiar Gibbs
phenomenon
 It will be manifested in H ( ) ,
especially if H d ( ) is discontinuous.
Feb.2008
DISP Lab
29
FIR Filter Design by Window
function technique
 1.Rectangular window
1, 0  n  M
w[n]  
0, otherwise
 2.Triangular window (Bartett window)
 2n , 0  n  M
2
 M

w[n]  2  2n , M  n  M
M
2

0, otherwise
Feb.2008
DISP Lab
30
FIR Filter Design by Window
function technique
 1.Rectangular window
 2.Triangular window (Bartett window)
60
Frequency response T(jw)(dB)
60
Frequency response T(jw)(dB)
Rectangular window
T(n)
1
0.5
0
0
10
20
30
sequence (n)
Bartlett window
40
50
T(n)
1
0.5
0
0
Feb.2008
10
20
30
sequence (n)
40
50
Rectangular window
100
50
0
-50
-100
0.6
0.5
pi units
Bartlett window
0.7
0.8
0.9
1
0.6
0.7
0.8
0.9
1
0
0.1
0.2
0.3
0.4
0
0.1
0.2
0.3
0.4
100
50
0
-50
-100
DISP Lab
0.5
pi units
31
FIR Filter Design by Window
function technique
 3.HANN window
1 
2 n 
, 0nM
 1  cos

w[n]   2 
M 
0, otherwise

 4.Hamming window
2 n

, 0nM
0.54  0.46cos
w[n]  
M
0, otherwise
Feb.2008
DISP Lab
32
FIR Filter Design by Window
function technique
 3.HANN window
 4.Hamming window
60
Frequency response T(jw)(dB)
60
Frequency response T(jw)(dB)
Hanning window
T(n)
1
0.5
0
0
10
20
30
sequence (n)
Hamming window
40
50
T(n)
1
0.5
0
0
Feb.2008
10
20
30
sequence (n)
40
50
Hanning window
100
50
0
-50
-100
0.6
0.5
pi units
Hamming window
0.7
0.8
0.9
1
0.6
0.7
0.8
0.9
1
0
0.1
0.2
0.3
0.4
0
0.1
0.2
0.3
0.4
100
50
0
-50
-100
DISP Lab
0.5
pi units
33
FIR Filter Design by Window
function technique
 5.Kaiser’s window
w[n] 
I 0 [  1  (1 
I0[ ]
2n 2
) ]
M
, n  0,1,..., M
 6.Blackman window
2 n
4 n

 0.08cos
, 0nM
0.42  0.5cos
w[n]  
M
M
0, otherwise
Feb.2008
DISP Lab
34
FIR Filter Design by Window
function technique
 5.Kaiser’s window
 6.Blackman window
60
Frequency response T(jw)(dB)
60
Frequency response T(jw)(dB)
Blackman window
T(n)
1
0.5
0
0
10
20
30
sequence (n)
Kaiser window
40
50
T(n)
1
0.5
0
0
Feb.2008
10
20
30
sequence (n)
40
50
Blackman window
100
50
0
-50
-100
0.6
0.5
pi units
Kaiser window
0.7
0.8
0.9
1
0.6
0.7
0.8
0.9
1
0
0.1
0.2
0.3
0.4
0
0.1
0.2
0.3
0.4
100
50
0
-50
-100
-150
DISP Lab
0.5
pi units
35
FIR Filter Design by Window
function technique
Window
Peak sidelobe level
(dB)
Transition
bandwidth
(s / M )
Max. stopband
ripple(dB)
Rectangular
-13
0.9
-21
Hann
-31
3.1
-44
Hamming
-41
3.3
-53
Blackman
-57
5.5
-74
Feb.2008
DISP Lab
36
FIR Filter Design by Frequency
sampling technique
 For arbitrary, non-classical
specifications of H 'd () , the calculation
of hd (n) ,n=0,1,…,M, via an appropriate
approximation can be a substantial
computation task.
 It may be preferable to employ a
design technique that utilizes
specified values of H 'd () directly,
without the necessity of determining hd (n)
Feb.2008
DISP Lab
37
FIR Filter Design by Frequency
sampling technique
 We wish to derive a linear phase IIR
filter with real nonzero h(n) . The
impulse response must be symmetric
h(n)  A0 
[ M /2]

k 1
2 k (n  1/ 2)
2 Ak cos(
)
M 1
n  0,1,..., M
where Ak are real and [ M / 2] denotes
the integer part
Feb.2008
DISP Lab
38
FIR Filter Design by Frequency
sampling technique
 It can be rewritten as
h( n) 
N 1

k 0
k N /2
Ak e j k / N e j 2 kn / N n  0,1,..., N  1
where N  M 1 and Ak  AN k
 Therefore, it may write
h( n) 
N 1

k 0
k N /2
hk ( n)
where hk (n)  Ak e j k / N e j 2 kn / N n  0,1,..., N  1
Feb.2008
DISP Lab
39
FIR Filter Design by Frequency
sampling technique
 with corresponding transform
H ( z) 
N 1

k 0
k N /2
where
H k ( z)
Ak e j k / N (1  z  N )
H k ( z) 
1  e j 2 k / N z 1
sin TN / 2
sin[( k / N  T / 2)]
 Hence H ( )  Ak e
which has a linear phase
'
k
Feb.2008
 jT ( N 1)/2
DISP Lab
40
FIR Filter Design by Frequency
sampling technique
 The magnitude response
sin TN / 2
H ( )  Ak
sin[( k / N  T / 2)]
'
k
which has a maximum value N Ak
at k  ks / N where s  2 / T
Feb.2008
DISP Lab
41
FIR Filter Design by Frequency
sampling technique
 The only nonzero contribution to H '( )
at   k is from H k' ( ) , and hence
that H '(k )  N Ak
 Therefore, by specifying the DFT
samples of the desired magnitude
H ( ) response at the frequencies  ,
k
and setting Ak   H d' (k ) / N
'
d
Feb.2008
DISP Lab
42
FIR Filter Design by Frequency
sampling technique
 We produce a filter design from
equation (5.1) for which
H '(k )  H d' (k )
 The desired and actual magnitude
responses are equal at the N
frequencies k
Feb.2008
DISP Lab
43
FIR Filter Design by Frequency
sampling technique
 In between these frequencies, H '( ) is
interpolated as the sum of the
responses H k' ( ), and its magnitude
'
H
does not, equal that of d ( )
Feb.2008
DISP Lab
44
FIR Filter Design by Frequency
sampling technique
 Example: For an ideal lowpass filter
1, k  0,1,..., P
H (k )  
0, k  P  1,...,[ M / 2]
'
d
'
A


H
d (k ) / N
from k
, we would
choose
(1)k / ( M  1), k  0,1,..., P
Ak  
0, k  P  1,...,[ M / 2]
'
 The frequency samples H (k ) are
indeed equal to the desired H d' (k )
Feb.2008
DISP Lab
45
FIR Filter Design by Frequency
sampling technique
 The response is very similar to the
result form using the rectangular
window, and the stopband is similarly
disappointing.
 We can try to search for the optimum
value of the transition sample would
quickly lead us to a value of
approximately Ap  0.38(1) p /(M  1) , k  p
Feb.2008
DISP Lab
46
FIR Filter Design by MSE
 H ( f ) : The spectrum of the filter we
obtain
 H d ( f ): The spectrum of the desired
filter
1.5
1
0.5
0
-0.5
 MSE=
Feb.2008
0
0.1
1 f s / 2
fs
 fs / 2

0.2
0.3
0.4
0.5
H  f   H d  f  df
2
DISP Lab
47
FIR Filter Design by MSE
 Larger MSE, but smaller maximal
H(F) - H (F)
H(F)
error
1.5
0.5
d
1
0.5
0
0
-0.5
0
0.1
0.2
0.3
0.4
-0.5
0
0.1
0.2
0.3
0.4
0.2
0.3
0.4
 Smaller MSE, but larger maximal
error
H(F) - H (F)
1.5
0.5
d
H(F)
1
0.5
0
0
-0.5
Feb.2008
0
0.1
0.2
0.3
0.4
DISP Lab
-0.5
0
0.1
48
FIR Filter Design by MSE
 1.
MSE 
1 f s / 2
fs
 fs / 2

R f   H d  f  df  
2
1/ 2
1 / 2
RF   H d F  dF
2
k
|
s[n] cos2 n F   H d F  |2 dF

1 / 2
1/ 2

n 0
 k
 k

    s[n] cos2 n F   H d F   s[n] cos2 n F   H d F  dF
1 / 2
 n 0
 n0

1/ 2

1/2
1/2
 2
k
 s[n]cos  2 n F  s[ ]cos  2  F  dF
1/2
1/2
Feb.2008
k
n 0
0
k
 s[n]cos  2 n F H d  F  dF  
1/2
1/2
n 0
DISP Lab
H d2  F  dF
49
FIR Filter Design by MSE
 2.
1/ 2 cos2 n F  cos2  F  dF  0
1/ 2
when n  ,
1/ 2 cos2 n F  cos2  F  dF  1 / 2 when n = , n  0,
1/ 2
1/ 2 cos2 n F  cos2  F  dF  1
1/ 2
when n = , n = 0,
 3. The formula can be repressed as:
k
MSE  s [0]   s [n] / 2  2
2
n 1
Feb.2008
2
1/ 2
1 / 2
k
 s[n] cos2 n F H d F  dF  
1/ 2
1 / 2
n 0
DISP Lab
H d2 F  dF
50
FIR Filter Design by MSE
 4. Doing the partial differentiation:
1/ 2
 MSE
 2s[0]  2 H d F dF
1 / 2
 s[0]
 5. Minimize
1/ 2
s[0]  
1 / 2
H d F  dF
1/ 2
 MSE
 s[n]  2 cos2 n F H d F dF
1 / 2
 s[n]
 MSE
MSE:  s[n]  0 for
1/ 2
s[n]  2 cos2 n F H d F  dF
1 / 2
h[k ]  s[0]
h[k  n]  s[n] / 2
for n=1,2,...,k
h[k  n]  s[n] / 2
for n=1,2,...,k
all n’s
h[n]  0 for n<0 and n  N
Feb.2008
DISP Lab
51
Conclusions

1.
2.
3.
4.

1.
FIR advantage:
Finite impulse response
It is easy to optimalize
Linear phase
Stable
FIR disadvantage:
It is hard to implementation than IIR
Feb.2008
DISP Lab
52
Conclusions

1.
2.

1.
2.
3.
IIR advantage:
It is easy to design
It is easy to implementation
IIR disadvantage:
Infinite impulse response
It is hard to optimalize than FIR
Non-stable
Feb.2008
DISP Lab
53
References
 [1]B. Jackson, Digital Filters and Signal
Processing, Kluwer Academic Publishers 1986
 [2]Dr. DePiero, Filter Design by Frequency
Sampling, CalPoly State University
 [3]W.James MacLean, FIR Filter Design
Using Frequency Sampling
 [4]蒙以正,數位信號處理,旗標2005
 [5]Maurice G.Bellanger, Adaptive Digital
Filters second edition, Marcel dekker 2001
Feb.2008
DISP Lab
54
References
 [6] Lawrence R. Rabiner, Linear Program
Design of Finite Impulse Response Digital
Filters, IEEE 1972
 [7] Terrence J mc Creary, On Frequency
Sampling Digital Filters, IEEE 1972
Feb.2008
DISP Lab
55
Download