Fir and iir filter_design

55
Feb.2008 DISP Lab 1 FIR and IIR Filter Design Techniques FIR 與 IIR 與與與與與與與 Speaker: Wen-Fu Wang 王王王 Advisor: Jian-Jiun Ding 王王王 王王 E-mail: [email protected] Graduate Institute of Communication Engineering National Taiwan University, Taipei, Taiwan, ROC

description

 

Transcript of Fir and iir filter_design

Page 1: Fir and iir filter_design

Feb.2008 DISP Lab 1

FIR and IIR Filter Design Techniques

FIR 與 IIR 濾波器設計技巧 Speaker: Wen-Fu Wang 王文阜 Advisor: Jian-Jiun Ding 丁建均 教授 E-mail: [email protected] Graduate Institute of Communication Engineering National Taiwan University, Taipei, Taiwan, ROC

Page 2: Fir and iir filter_design

Feb.2008 DISP Lab 2

Outline

Introduction IIR Filter Design by Impulse

invariance method IIR Filter Design by Bilinear

transformation method FIR Filter Design by Window function

technique

Page 3: Fir and iir filter_design

Feb.2008 DISP Lab 3

Outline

FIR Filter Design by Frequency sampling technique

FIR Filter Design by MSE Conclusions References

Page 4: Fir and iir filter_design

Feb.2008 DISP Lab 4

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.

Filter

Analog Filter

Digital Filter

IIR Filter

FIR Filter

Page 5: Fir and iir filter_design

Feb.2008 DISP Lab 5

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.

Page 6: Fir and iir filter_design

Feb.2008 DISP Lab 6

Introduction IIR filter design methods include the

impulse invariance, bilinear transformation, and step invariance.

We must emphasize at impulse invariance and bilinear transformation.

Page 7: Fir and iir filter_design

Feb.2008 DISP Lab 7

Introduction IIR filter design methods

Continuous frequency band transformation

Impulse Invariancemethod

Bilinear transformation method

Step invariance method

IIR filter

Normalized analog lowpass filter

Page 8: Fir and iir filter_design

Feb.2008 DISP Lab 8

Introduction

The structures of IIR filter

Direct form 1

Direct form2

b0

b1

b2 b2

b1

b0

-a1

-a2

-a1

-a2

x(n) x(n)Y(n) Y(n)

1z

1z

1z

1z

1z

1z

Page 9: Fir and iir filter_design

Feb.2008 DISP Lab 9

Introduction

The structures of IIR filter

Cascade form

x(n) Y(n)b0

b1

b2

-a1

-a2

-c1

-c2

d1

d2

Parallel form

Y(n)x(n)

b1

b0

d1

d0

E

-c1

-c2

-a1

-a2

1z

1z

1z

1z

1z

1z

1z

1z

Page 10: Fir and iir filter_design

Feb.2008 DISP Lab 10

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.

Page 11: Fir and iir filter_design

Feb.2008 DISP Lab 11

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

FIR filter

Mean square error

Page 12: Fir and iir filter_design

Feb.2008 DISP Lab 12

Introduction The structures of FIR filter

x(n) x(n)

b1

b2

b3

b4

b0Y(n) Y(n)

Direct form Cascade form

b1

b2

d1

d2

b0

1z

1z

1z

1z

1z

1z

1z

1z

Page 13: Fir and iir filter_design

Feb.2008 DISP Lab 13

IIR Filter Design by Impulse invariance method

The most straightforward of these is the impulse invariance transformation

Let be the impulse response corresponding to , and define the continuous to discrete time transformation by setting

We sample the continuous time impulse response to produce the discrete time filter

( )ch t( )cH s

( ) ( )ch n h nT

Page 14: Fir and iir filter_design

Feb.2008 DISP Lab 14

IIR Filter Design by Impulse invariance method

The frequency response is the Fourier transform of the continuous time function

and hence

'( )H

*( ) ( ) ( )c cn

h t h nT t nT

1 2'( ) ( )c

k

H H j kT T

Page 15: Fir and iir filter_design

Feb.2008 DISP Lab 15

IIR Filter Design by Impulse invariance method

The system function is

It is the many-to-one transformation from the s plane to the z plane.

1 2( ) | )sT cz e

k

H z H s jkT T

Page 16: Fir and iir filter_design

Feb.2008 DISP Lab 16

IIR Filter Design by Impulse invariance method

The impulse invariance transformation does map the -axis and the left-half s plane into the unit circle and its interior, respectively

j

Re(Z)

Im(Z)

1

S domain Z domain

sTe

j

Page 17: Fir and iir filter_design

Feb.2008 DISP Lab 17

IIR Filter Design by Impulse invariance method

is an aliased version of

The stop-band characteristics are maintained adequately in the discrete time frequency response only if the aliased tails of are sufficiently small.

'( )H ( )cH j

0

'( )H

/T 2 /T

( )cH j

Page 18: Fir and iir filter_design

Feb.2008 DISP Lab 18

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.

Page 19: Fir and iir filter_design

Feb.2008 DISP Lab 19

IIR Filter Design by Impulse invariance method

is expanded a partial fraction expansion to produce

We have assumed that there are no multiple poles

And thus

( )cH s

1

( )N

kc

k k

AH s

s s

1

( ) ( )k

Ns t

c kk

h t A e u t

1

( ) ( )k

Ns nT

kk

h n A e u n

11

( )1 k

Nks T

k

AH z

e z

Page 20: Fir and iir filter_design

Feb.2008 DISP Lab 20

IIR Filter Design by Impulse invariance method

Example:

Expanding in a partial fractionexpansion, it produce

The impulse invariant transformation yields a discrete time design with thesystem function

2 2( )

( )c

s aH s

s a b

1/ 2 1/ 2( )cH s

s a jb s a jb

( ) 1 ( ) 1

1/ 2 1/ 2( )

1 1a jb T a jb TH z

e z e z

Page 21: Fir and iir filter_design

Feb.2008 DISP Lab 21

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 many-to-one. sTz e

Page 22: Fir and iir filter_design

Feb.2008 DISP Lab 22

IIR Filter Design by Bilinear transformation method

We could first use a one-to-one transformation from to , which compresses the entire s plane into the strip

Then could be transformed to z by with no effect from aliasing.

s 's

Im( ')sT T

's's Tz e

j

'

j

/T

/T

s domain s’ domain

Page 23: Fir and iir filter_design

Feb.2008 DISP Lab 23

IIR Filter Design by Bilinear transformation method

The transformation from to is given by

The characteristic of this transformation is seen most readily from its effect on the axis.

Substituting and , we obtain

s 's12

' tanh ( )2

sTs

T

js j ' 's j

12' tan ( )

2

T

T

Page 24: Fir and iir filter_design

Feb.2008 DISP Lab 24

IIR Filter Design by Bilinear transformation method

The axis is compressed into the interval for in a one-to-one method

The relationship between and is nonlinear, but it is approximately linear at small .

( , )T T

'

'

'

-

'/T

/T

Page 25: Fir and iir filter_design

Feb.2008 DISP Lab 25

IIR Filter Design by Bilinear transformation method

The desired transformation to is now obtained by inverting to produce

And setting , which yields

12' tanh ( )

2

sTs

T

2 'tanh( )

2

s TsT

s z

1' ( ) lns zT

2 lntanh( )

2

zsT

1

1

2 1( )1

z

T z

Re(Z)

Im(Z)

1

S domain Z domain

12

12

Ts

zTs

j

Page 26: Fir and iir filter_design

Feb.2008 DISP Lab 26

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

Unlike the impulse invariant transformation, the bilinear transformation is one-to-one, and invertible.

1 1(2/ )(1 )/(1 )( ) ( ) |c s T z z

H z H s

Page 27: Fir and iir filter_design

Feb.2008 DISP Lab 27

FIR Filter Design by Window function technique

Simplest FIR the filter design is window function technique

A supposition ideal frequency response may express

where

( ) [ ]j j nd d

n

H e h n e

1[ ] ( )

2j j n

d dh n H e e d

Page 28: Fir and iir filter_design

Feb.2008 DISP Lab 28

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!

[ ] [ ] [ ]dh n w n h n

( ) ( ) ( )dH W H

Page 29: Fir and iir filter_design

Feb.2008 DISP Lab 29

FIR Filter Design by Window function technique

Truncation of the Fourier series produces the familiar Gibbs phenomenon

It will be manifested in , especially if is discontinuous.

( )H ( )dH

Page 30: Fir and iir filter_design

Feb.2008 DISP Lab 30

FIR Filter Design by Window function technique

1.Rectangular window

2.Triangular window (Bartett window)

1, 0[ ]

0,

n Mw n

otherwise

2 , 0 22[ ] 2 , 2

0,

n MnMn Mw n n MM

otherwise

Page 31: Fir and iir filter_design

Feb.2008 DISP Lab 31

FIR Filter Design by Window function technique

1.Rectangular window 2.Triangular window (Bartett window)

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n

)

Rectangular window

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n

)

Bartlett window

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

pi unitsF

requ

ency

res

pons

e T

(jw)(

dB) Rectangular window

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

pi units

Fre

quen

cy r

espo

nse

T(jw

)(dB

) Bartlett window

Page 32: Fir and iir filter_design

Feb.2008 DISP Lab 32

FIR Filter Design by Window function technique

3.HANN window

4.Hamming window

1 21 cos , 0

[ ] 2

0,

nn M

w n M

otherwise

20.54 0.46cos , 0

[ ]0,

nn M

w n Motherwise

Page 33: Fir and iir filter_design

Feb.2008 DISP Lab 33

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

pi unitsF

requ

ency

res

pons

e T

(jw)(

dB) Hanning window

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

pi units

Fre

quen

cy r

espo

nse

T(jw

)(dB

) Hamming window

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n)

Hanning window

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n)

Hamming window

FIR Filter Design by Window function technique

3.HANN window 4.Hamming window

Page 34: Fir and iir filter_design

Feb.2008 DISP Lab 34

FIR Filter Design by Window function technique

5.Kaiser’s window

6.Blackman window

20

0

2[ 1 (1 ) ]

[ ] , 0,1,...,[ ]

nI

Mw n n MI

2 40.42 0.5cos 0.08cos , 0

[ ]0,

n nn M

w n M Motherwise

Page 35: Fir and iir filter_design

Feb.2008 DISP Lab 35

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

pi unitsF

requ

ency

res

pons

e T

(jw)(

dB) Blackman window

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150

-100

-50

0

50

100

pi units

Fre

quen

cy r

espo

nse

T(jw

)(dB

) Kaiser window

5.Kaiser’s window 6.Blackman window

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n

)

Blackman window

0 10 20 30 40 50 600

0.5

1

sequence (n)

T(n

)

Kaiser window

FIR Filter Design by Window function technique

Page 36: Fir and iir filter_design

Feb.2008 DISP Lab 36

FIR Filter Design by Window function technique

( / )s M

Window Peak sidelobe level (dB)

Transition bandwidth

Max. stopband ripple(dB)

Rectangular -13 0.9 -21

Hann -31 3.1 -44

Hamming -41 3.3 -53

Blackman -57 5.5 -74

Page 37: Fir and iir filter_design

Feb.2008 DISP Lab 37

FIR Filter Design by Frequency sampling technique

For arbitrary, non-classical specifications of , the calculation

of ,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 directly, without the necessity of determining

' ( )dH

( )dh n

' ( )dH ( )dh n

Page 38: Fir and iir filter_design

Feb.2008 DISP Lab 38

FIR Filter Design by Frequency sampling technique

We wish to derive a linear phase IIR filter with real nonzero . The impulse response must be symmetric

where are real and denotes the integer part

( )h n

[ /2]

01

2 ( 1/ 2)( ) 2 cos( )

1

M

kk

k nh n A A

M

kA [ / 2]M

0,1,...,n M

Page 39: Fir and iir filter_design

Feb.2008 DISP Lab 39

FIR Filter Design by Frequency sampling technique

It can be rewritten as

where and Therefore, it may write

where

1/ 2 /

0/2

( )N

j k N j kn Nk

kk N

h n A e e

0,1,..., 1n N

1N M k N kA A

/ 2 /( ) j k N j kn Nk kh n A e e

1

0/2

( ) ( )N

kkk N

h n h n

0,1,..., 1n N

Page 40: Fir and iir filter_design

Feb.2008 DISP Lab 40

FIR Filter Design by Frequency sampling technique

with corresponding transform

where

Hence which has a linear phase

1

0/2

( ) ( )N

kkk N

H z H z

/

2 / 1

(1 )( )

1

j k N Nk

k j k N

A e zH z

e z

' ( 1)/2 sin / 2( )

sin[( / / 2)]j T N

k k

TNH A e

k N T

Page 41: Fir and iir filter_design

Feb.2008 DISP Lab 41

FIR Filter Design by Frequency sampling technique

The magnitude response

which has a maximum value at where

' sin / 2( )

sin[( / / 2)]k k

TNH A

k N T

kN A

/k sk N 2 /s T

Page 42: Fir and iir filter_design

Feb.2008 DISP Lab 42

FIR Filter Design by Frequency sampling technique

The only nonzero contribution to at is from , and hence that

Therefore, by specifying the DFT samples of the desired magnitude

response at the frequencies , and setting

'( )H

k ' ( )kH '( )k kH N A

' ( )dH k

' ( ) /k d kA H N

Page 43: Fir and iir filter_design

Feb.2008 DISP Lab 43

FIR Filter Design by Frequency sampling technique

We produce a filter design from equation (5.1) for which

The desired and actual magnitude responses are equal at the N frequencies

''( ) ( )k d kH H

k

Page 44: Fir and iir filter_design

Feb.2008 DISP Lab 44

FIR Filter Design by Frequency sampling technique

In between these frequencies, is interpolated as the sum of the responses , and its magnitude does not, equal that of

'( )H

' ( )kH ' ( )dH

Page 45: Fir and iir filter_design

Feb.2008 DISP Lab 45

FIR Filter Design by Frequency sampling technique

Example: For an ideal lowpass filter

from , we would choose

The frequency samples are indeed equal to the desired

' 1, 0,1,...,( )

0, 1,...,[ / 2]d k

k PH

k P M

' ( ) /k d kA H N

( 1) / ( 1), 0,1,...,

0, 1,...,[ / 2]

k

k

M k PA

k P M

' ( )kH

' ( )d kH

Page 46: Fir and iir filter_design

Feb.2008 DISP Lab 46

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 , k p0.38( 1) /( 1)p

pA M

Page 47: Fir and iir filter_design

Feb.2008 DISP Lab 47

FIR Filter Design by MSE

: The spectrum of the filter we obtain

: The spectrum of the desired filter

MSE=

( )H f

( )dH f

2/

2/

21 s

s

f

f ds dffHfHf

0 0.1 0.2 0.3 0.4 0.5-0.5

0

0.5

1

1.5

Page 48: Fir and iir filter_design

Feb.2008 DISP Lab 48

FIR Filter Design by MSE

Larger MSE, but smaller maximal error

Smaller MSE, but larger maximal error

0 0.1 0.2 0.3 0.4-0.5

0

0.5

1

1.5

0 0.1 0.2 0.3 0.4-0.5

0

0.5

H(F) H(F) - H (F)d

0 0.1 0.2 0.3 0.4-0.5

0

0.5

1

1.5

0 0.1 0.2 0.3 0.4-0.5

0

0.5

H(F) H(F) - H (F) d

Page 49: Fir and iir filter_design

Feb.2008 DISP Lab 49

FIR Filter Design by MSE

1.

2/1

2/1

22/

2/

21 dFFHFRdffHfRfMSE df

f dss

s

dFFHFnns d

k

n

2/1

2/1

2

0

|| 2cos][

dFFHFnnsFHFnns d

k

nd

k

n

2/1

2/100

2cos][2cos][

1/2

1/20 0

[ ]cos 2 [ ]cos 2k k

n

s n n F s F dF

1/2 1/2 2

1/2 1/20

2 [ ]cos 2k

d dn

s n n F H F dF H F dF

Page 50: Fir and iir filter_design

Feb.2008 DISP Lab 50

FIR Filter Design by MSE 2. when n ,

when n = , n 0,

when n = , n = 0,

3. The formula can be repressed as:

02cos2cos2/1

2/1 dFFFn

2/12cos2cos2/1

2/1 dFFFn

12cos2cos2/1

2/1 dFFFn

dFFHdFFHFnnsnssMSE dd

k

n

k

n

2/1

2/1

22/1

2/101

22 2cos][22/][]0[

Page 51: Fir and iir filter_design

Feb.2008 DISP Lab 51

FIR Filter Design by MSE

4. Doing the partial differentiation:

5. Minimize MSE: for all n’s

2/1

2/12]0[2

]0[dFFHs

s

MSEd

2/1

2/12cos2][

][dFFHFnns

ns

MSEd

0][

ns

MSE

2/1

2/1]0[ dFFHs d

2/1

2/12cos2][ dFFHFnns d

[ ] [0]

[ ] [ ] / 2 for n=1,2,...,k

[ ] [ ] / 2 for n=1,2,...,k

[ ] 0 for n<0 and n N

h k s

h k n s n

h k n s n

h n

Page 52: Fir and iir filter_design

Feb.2008 DISP Lab 52

Conclusions

FIR advantage:1. Finite impulse response2. It is easy to optimalize3. Linear phase4. Stable FIR disadvantage:1. It is hard to implementation than IIR

Page 53: Fir and iir filter_design

Feb.2008 DISP Lab 53

Conclusions

IIR advantage:1. It is easy to design2. It is easy to implementation IIR disadvantage:1. Infinite impulse response2. It is hard to optimalize than FIR3. Non-stable

Page 54: Fir and iir filter_design

Feb.2008 DISP Lab 54

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

Page 55: Fir and iir filter_design

Feb.2008 DISP Lab 55

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