IIR Filters

36

Click here to load reader

description

IIR_Filters

Transcript of IIR Filters

Page 1: IIR Filters

1

1Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter Filter SpecificationsSpecifications

• Typical magnitude response of an analog lowpass filter may be given as indicated below

)( ΩjHa

2Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter Filter SpecificationsSpecifications

• In the passband, defined by , we require

i.e., approximates unity within an error of

)( ΩjHa

pΩ≤Ω≤0

ppap jH Ω≤Ωδ+≤Ω≤δ− ,1)(1

)( ΩjHa

∞<Ω≤Ωs

∞<Ω≤Ωδ≤Ω ssa jH ,)(

• In the stopband, defined by , we require

i.e., approximates zero within an error of

pδ±

3Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter Filter SpecificationsSpecifications

• - passband edge frequency• - stopband edge frequency• - peak ripple value in the passband• - peak ripple value in the stopband• Peak passband ripple

dB• Minimum stopband attenuation

dB

sδpδ

)1(log20 10 pp δ−−=α

)(log20 10 ss δ−=α4

Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter Filter SpecificationsSpecifications

• Magnitude specifications may alternately be given in a normalized form as indicated below

5Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter Filter SpecificationsSpecifications

• Here, the maximum value of the magnitude in the passband assumed to be unity

• - Maximum passband deviation, given by the minimum value of the magnitude in the passband

• - Maximum stopband magnitude

21/1 ε+

A1

6Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter DesignFilter Design• Two additional parameters are defined -

(1) Transition ratio

For a lowpass filter

(2) Discrimination parameterUsually

s

pkΩΩ

=

121 −=

Ak ε

1<k

11 <<k

Page 2: IIR Filters

2

7Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation

• The magnitude-square response of an N-thorder analog lowpass Butterworth filteris given by

• First derivatives of atare equal to zero

• The Butterworth lowpass filter thus is said to have a maximally-flat magnitude at

12 −N 2)( ΩjHa

Nc

a jH 22

)/(11)(ΩΩ+

0=Ω

0=Ω8

Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation

• Gain in dB is

• As and dB

is called the 3-dB cutoff frequency

210 )(log10)( Ω=Ω jHaG

0)0( =G30103.3)5.0(log10)( 10 −≅−==ΩcG

9Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation

• Typical magnitude responses with 1=Ωc

0 1 2 30

0.2

0.4

0.6

0.8

1

Ω

Mag

nitu

de

Butterworth Filter

N = 2N = 4N = 10

10Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation

• Two parameters completely characterizing a Butterworth lowpass filter are and N

• These are determined from the specified bandedges and , and minimum passband magnitude , and maximum stopband ripple

pΩ sΩ21/1 ε+A/1

11Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation• and N are thus determined from

• Solving the above we get

222 1

)/(11)(

AjH N

cssa =

ΩΩ+=Ω

222

11

)/(11)(

ε+=

ΩΩ+=Ω N

cppa jH

)/1(log)/1(log

)/(log]/)1[(log

21

10

110

10

2210

kkAN

ps=

ΩΩ−⋅= ε

12Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation• Since order N must be an integer, value

obtained is rounded up to the next highest integer

• This value of N is used next to determine by satisfying either the stopband edge or the passband edge specification exactly

• If the stopband edge specification is satisfied, then the passband edge specification is exceeded providing a safety margin

Page 3: IIR Filters

3

13Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation• Transfer function of an analog Butterworth

lowpass filter is given by

where

• Denominator is known as the Butterworth polynomial of order N

∏ −Ω=

∑+Ω==

=−=

N

Nc

NN

Nc

Na pssdssD

CsH1

10 )()()(

l lll

l

Nep NNjc ≤≤Ω= −+ ll

l 1,]2/)12([π

)(sDN

14Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation• Example - Determine the lowest order of a

Butterworth lowpass filter with a 1-dB cutoff frequency at 1 kHz and a minimum attenuation of 40dB at 5 kHz

• Now

which yieldsand

which yields

11

1log10 210 −=⎟⎠⎞

⎜⎝⎛+ ε

25895.02 =ε

401log10 210 −=⎟⎠⎞

⎜⎝⎛

A000,102 =A

15Copyright © 2005, S. K. Mitra

Butterworth ApproximationButterworth Approximation• Therefore

and

• Hence

• We choose N = 4

51334.19611 2

1=−= ε

Ak

51 =ΩΩ

=p

sk

2811.3)/1(log)/1(log

10

110 ==kkN

16Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation• The magnitude-square response of an N-th

order analog lowpass Type 1 Chebyshev filteris given by

where is the Chebyshev polynomialof order N:

)/(11)( 22

2

pNa T

sHΩΩ+

⎩⎨⎧

>ΩΩ≤ΩΩ

=Ω −

1),coshcosh(1),coscos(

)( 1

1

NN

TN

)(ΩNT

17Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation

• Typical magnitude response plots of the analog lowpass Type 1 Chebyshev filter are shown below

0 1 2 30

0.2

0.4

0.6

0.8

1

Ω

Mag

nitu

de

Type 1 Chebyshev Filter

N = 2N = 3N = 8

18Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation• If at the magnitude is equal to 1/A,

then

• Solving the above we get

• Order N is chosen as the nearest integer greater than or equal to the above value

sΩ=Ω

2222 1

)/(11)(

ATjH

psNsa =

ΩΩ+=Ω

ε

)/1(cosh)/1(cosh

)/(cosh)/1(cosh

11

1

1

21

kkAN

ps−

=ΩΩ−= ε

Page 4: IIR Filters

4

19Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation• The magnitude-square response of an N-th

order analog lowpass Type 2 Chebyshev(also called inverse Chebyshev) filter is given by

where is the Chebyshev polynomialof order N

22

2

)/()/(

1

1)(

⎥⎦

⎤⎢⎣

⎡ΩΩΩΩ

+

sN

psNa

TT

jH

ε

)(ΩNT

20Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation• Typical magnitude response plots of the

analog lowpass Type 2 Chebyshev filter are shown below

0 1 2 30

0.2

0.4

0.6

0.8

1

Ω

Mag

nitu

de

Type 2 Chebyshev Filter

N = 3N = 5N = 7

21Copyright © 2005, S. K. Mitra

ChebyshevChebyshev ApproximationApproximation• The order N of the Type 2 Chebyshev filter

is determined from given , , and Ausing

• Example - Determine the lowest order of a Chebyshev lowpass filter with a 1-dB cutoff frequency at 1 kHz and a minimum attenuation of 40 dB at 5 kHz -

)/1(cosh)/1(cosh

)/(cosh)/1(cosh

11

1

1

21

kkAN

ps−

=ΩΩ−= ε

ε sΩ

6059.2)/1(cosh)/1(cosh

11

1== −

kkN

22Copyright © 2005, S. K. Mitra

Elliptic ApproximationElliptic Approximation• The square-magnitude response of an

elliptic lowpass filter is given by

where is a rational function of order N satisfying , with the roots of its numerator lying in the interval

and the roots of its denominator lying in the interval

)/(11)( 22

2

pNa R

jHΩΩ+

=Ωε

)(ΩNR)(/1)/1( Ω=Ω NN RR

10 <Ω<∞<Ω<1

23Copyright © 2005, S. K. Mitra

Elliptic ApproximationElliptic Approximation• For given , , , and A, the filter order

can be estimated using

where

)/1(log)/4(log2

10

110ρkN ≅

εpΩ sΩ

21' kk −=

)'1(2'1

0 kk

+−=ρ

130

90

500 )(150)(15)(2 ρρρρρ +++=

24Copyright © 2005, S. K. Mitra

Elliptic ApproximationElliptic Approximation• Example - Determine the lowest order of a elliptic

lowpass filter with a 1-dB cutoff frequency at 1kHz and a minimum attenuation of 40 dB at 5 kHzNote: k = 0.2 and

• Substituting these values we get

• and hence N = 2.23308• Choose N = 3

5134.196/1 1 =k

,979796.0'=k ,00255135.00 =ρ0025513525.0=ρ

Page 5: IIR Filters

5

25Copyright © 2005, S. K. Mitra

Elliptic ApproximationElliptic Approximation

• Typical magnitude response plots with are shown below

1=Ω p

0 1 2 30

0.2

0.4

0.6

0.8

1

Ω

Mag

nitu

de

Elliptic Filter

N = 3N = 4

26Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter DesignFilter Design• Example - Design an elliptic lowpass filter

of lowest order with a 1-dB cutoff frequency at 1 kHz and a minimum attenuation of 40 dB at 5 kHz

• Code fragments used[N, Wn] = ellipord(Wp, Ws, Rp, Rs, ‘s’);[b, a] = ellip(N, Rp, Rs, Wn, ‘s’);with Wp = 2*pi*1000;

Ws = 2*pi*5000;Rp = 1;Rs = 40;

27Copyright © 2005, S. K. Mitra

Analog Analog LowpassLowpass Filter DesignFilter Design

• Gain plot

0 2000 4000 6000-60

-40

-20

0

Frequency, Hz

Gai

n, d

B

Lowpass Elliptic Filter

28Copyright © 2005, S. K. Mitra

Design of Analog Design of Analog HighpassHighpass, , BandpassBandpass and and BandstopBandstop FiltersFilters

• Steps involved in the design process:Step 1 - Develop of specifications of a prototype analog lowpass filter from specifications of desired analog filter

using a frequency transformationStep 2 - Design the prototype analog lowpass filterStep 3 - Determine the transfer function of desired analog filter by applying the inverse frequency transformation to

)(sHLP

)(sHD

)(sHD

)(sHLP

29Copyright © 2005, S. K. Mitra

Design of Analog Design of Analog HighpassHighpass, , BandpassBandpass and and BandstopBandstop FiltersFilters• Let s denote the Laplace transform variable

of prototype analog lowpass filter and denote the Laplace transform variable of desired analog filter

• The mapping from s-domain to -domain is given by the invertible transformation

• Then

s

s)ˆ(sHD

)ˆ()()ˆ( sFsLPD sHsH ==

)(ˆ 1)ˆ()( sFsDLP sHsH −==

)ˆ(sFs =

)(sHLP

30Copyright © 2005, S. K. Mitra

Analog Analog HighpassHighpass Filter DesignFilter Design• Spectral Transformation:

where is the passband edge frequency of and is the passband edge

frequency of• On the imaginary axis the transformation is

ss ppˆΩΩ

=

pΩpΩ

ΩΩΩ

−=Ω ˆˆ pp

)(sHLP)ˆ(sHHP

Page 6: IIR Filters

6

31Copyright © 2005, S. K. Mitra

Analog Analog HighpassHighpass Filter DesignFilter Design

ΩΩΩ

−=Ω ˆˆ pp

Ω

sΩ− ˆpΩsΩpΩ− ˆ

HighpassPassbandPassband Stopband

sΩ− pΩ sΩpΩ−Lowpass

Passband

Stopband StopbandΩ

Ω

0

0

32Copyright © 2005, S. K. Mitra

Analog Analog HighpassHighpass Filter DesignFilter Design• Example - Design an analog Butterworth

highpass filter with the specifications: kHz, kHz, dB, dB

• Choose• Then

• Analog lowpass filter specifications: ,, dB, dB

4ˆ =pF 1ˆ =sF40=αs

1.0=α p

1=Ω p

1=Ω p

410004000

ˆˆ

ˆ2

ˆ2===

ππ

=Ωs

p

s

ps F

FFF

1.0=α p 40=αs4=Ωs

33Copyright © 2005, S. K. Mitra

Analog Analog HighpassHighpass Filter DesignFilter Design• Code fragments used

[N, Wn] = buttord(1, 4, 0.1, 40, ‘s’);[B, A] = butter(N, Wn, ‘s’);[num, den] = lp2hp(B, A, 2*pi*4000);

• Gain plots

0 2 4 6 8 10-80

-60

-40

-20

0

Ω

Gai

n, d

B

Prototype Lowpass Filter

0 2 4 6 8 10-80

-60

-40

-20

0

Frequency, kHz

Gai

n, d

B

Highpass Filter

34Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Spectral Transformation

where is the passband edge frequency of , and and are the lower and upper passband edge frequencies of desired bandpass filter

)ˆˆ(ˆˆˆ

12

22

pp

op s

ssΩ−ΩΩ+

Ω=

pΩ1ˆ pΩ 2ˆ pΩ

)ˆ(sHBP

)(sHLP

35Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• On the imaginary axis the transformation is

where is the width of passband and is the passband center frequency of the bandpass filter

• Passband edge frequency is mapped into and , lower and upper passband edge frequencies

w

op BΩ

Ω−ΩΩ−=Ω ˆˆˆ 22

12 ˆˆ ppwB Ω−Ω=oΩ

1ˆ pΩm 2ˆ pΩ±pΩ±

36Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

w

op BΩ

Ω−ΩΩ−=Ω ˆˆˆ 22

1ˆ sΩ− oΩ1ˆ sΩ1ˆ pΩ−

BandpassPassbandPassband Stopband

sΩ− pΩ sΩpΩ−Lowpass

Passband

Stopband StopbandΩ

ΩStopband Stopband

0

02ˆ sΩ

2ˆ pΩ− 1ˆ pΩ 2ˆ pΩoΩ− ˆ↓ ↓ ↓ ↓2ˆ sΩ−

Page 7: IIR Filters

7

37Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Stopband edge frequency is mapped into and , lower and upper stopband edge frequencies

• Also,

• If bandedge frequencies do not satisfy the above condition, then one of the frequencies needs to be changed to a new value so that the condition is satisfied

sΩ±1ˆ sΩm 2ˆ sΩ±

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

38Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Case 1:To make we can either increase any one of the stopband edges or decrease any one of the passband edges as shown below

2121 ˆˆˆˆ sspp ΩΩ>ΩΩ

1ˆ pΩ 2ˆ pΩ1ˆ sΩ 2ˆ sΩ

→ →

←←

Ω

2121 ˆˆˆˆ sspp ΩΩ=ΩΩ

Passband

Stopband Stopband

39Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

(1) Decrease tolarger passband and shorter

leftmost transition band(2) Increase to

No change in passband and shorter leftmost transition band

1ˆ pΩ

1ˆ sΩ

221 ˆ/ˆˆ pss ΩΩΩ

221 ˆ/ˆˆ spp ΩΩΩ

40Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Note: The condition can also be satisfied by decreasing which is not acceptable as the passband is reduced from the desired value

• Alternately, the condition can be satisfied by increasing which is not acceptable as the upper stop band is reduced from the desired value

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

2ˆ pΩ

2ˆ sΩ

41Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Case 2:To make we can either decrease any one of the stopband edges or increase any one of the passband edges as shown below

2121 ˆˆˆˆ sspp ΩΩ<ΩΩ

1ˆ pΩ 2ˆ pΩ1ˆ sΩ 2ˆ sΩ

→ →

←←

Ω

2121 ˆˆˆˆ sspp ΩΩ=ΩΩ

Passband

Stopband Stopband

42Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

(1) Increase tolarger passband and shorter

rightmost transition band(2) Decrease to

No change in passband and shorter rightmost transition band

2ˆ pΩ

2ˆ sΩ

121 ˆ/ˆˆ pss ΩΩΩ

121 ˆ/ˆˆ spp ΩΩΩ

Page 8: IIR Filters

8

43Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Note: The condition can also be satisfied by increasing which is not acceptable as the passband is reduced from the desired value

• Alternately, the condition can be satisfied by decreasing which is not acceptable as the lower stopband is reduced from the desired value

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

1ˆ pΩ

1ˆ sΩ

44Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Example - Design an analog elliptic bandpass filter with the specifications:

kHz, kHz, kHzkHz, dB, dB

• Now and• Since we choose

kHz

4ˆ 1 =pF 7ˆ 2 =pF8ˆ 2 =sF

3ˆ 1 =sF1=pα 22=sα

621 1028ˆˆ ×=pp FF 6

21 1024ˆˆ ×=ss FF

2121 ˆˆˆˆ sspp FFFF >571428.3ˆ/ˆˆˆ 2211 == pssp FFFF

45Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• We choose• Hence

• Analog lowpass filter specifications: ,, dB, dB

1=Ω p

4.13)7/25(

924 =×

−=Ωs

1=Ω p

4.1=Ωs 1=pα 22=sα

46Copyright © 2005, S. K. Mitra

Analog Analog BandpassBandpass Filter Filter DesignDesign

• Code fragments used[N, Wn] = ellipord(1, 1.4, 1, 22, ‘s’);[B, A] = ellip(N, 1, 22, Wn, ‘s’);[num, den]

= lp2bp(B, A, 2*pi*4.8989795, 2*pi*25/7);• Gain plot

0 2 4 6 8-60

-40

-20

0

Ω

Gai

n, d

B

Prototype Lowpass Filter

0 5 10 15-60

-40

-20

0

Frequency, kHz

Gai

n, d

B

Bandpass Filter

47Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design

• Spectral Transformation

where is the stopband edge frequency of , and and are the lower and upper stopband edge frequencies of the desired bandstop filter

sΩ)(sHLP

2212

ˆˆ

)ˆˆ(ˆ

os

ss ss

sΩ+Ω−Ω

Ω=

)ˆ(sHBS

1ˆ sΩ 2ˆ sΩ

48Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• On the imaginary axis the transformation is

where is the width of stopband and is the stopband center frequency of the bandstop filter

• Stopband edge frequency is mapped into and , lower and upper stopband edge frequencies

22 ˆˆˆ

Ω−ΩΩΩ=Ωo

ws

B

12 ˆˆ sswB Ω−Ω=oΩ

1ˆ sΩm 2ˆ sΩ±sΩ±

Page 9: IIR Filters

9

49Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• Passband edge frequency is mapped

into and , lower and upper passband edge frequencies

pΩ±1ˆ pΩm 2ˆ pΩ±

1ˆ sΩ−oΩ

1ˆ sΩ1ˆ pΩ−

BandpassPassbandPassband

sΩ− pΩ sΩpΩ−Lowpass

Passband

Stopband StopbandΩ

ΩStopband Stopband

0

0

2ˆ sΩ2ˆ pΩ− 1ˆ pΩ 2ˆ pΩoΩ− ˆ↓ ↓ ↓ ↓

2ˆ sΩ−

Passband

50Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• Also,

• If bandedge frequencies do not satisfy the above condition, then one of the frequencies needs to be changed to a new value so that the condition is satisfied

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

51Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• Case 1:• To make we can either

increase any one of the stopband edges or decrease any one of the passband edges as shown below

2121 ˆˆˆˆ sspp ΩΩ>ΩΩ

1ˆ pΩ 2ˆ pΩ1ˆ sΩ 2ˆ sΩΩ

2121 ˆˆˆˆ sspp ΩΩ=ΩΩ

Stopband

PassbandPassband

52Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design

(1) Decrease tolarger high-frequency passband

and shorter rightmost transition band(2) Increase to

No change in passbands andshorter rightmost transition band

2ˆ pΩ

2ˆ sΩ

221 ˆ/ˆˆ pss ΩΩΩ

221 ˆ/ˆˆ spp ΩΩΩ

53Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• Note: The condition

can also be satisfied by decreasing which is not acceptable as the low-frequency passband is reduced from the desired value

• Alternately, the condition can be satisfied by increasing which is not acceptable as the stopband is reduced from the desired value

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

1ˆ pΩ

1ˆ sΩ

54Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design• Case 1:• To make we can either

decrease any one of the stopband edges or increase any one of the passband edges as shown below

2121 ˆˆˆˆ sspp ΩΩ<ΩΩ

2121 ˆˆˆˆ sspp ΩΩ=ΩΩ

1ˆ pΩ 2ˆ pΩ1ˆ sΩ 2ˆ sΩΩ

Stopband

PassbandPassband

Page 10: IIR Filters

10

55Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design

(1) Increase tolarger passband and shorter

leftmost transition band(2) Decrease to

No change in passbands andshorter leftmost transition band

1ˆ pΩ

1ˆ sΩ

121 ˆ/ˆˆ pss ΩΩΩ

121 ˆ/ˆˆ spp ΩΩΩ

56Copyright © 2005, S. K. Mitra

Analog Analog BandstopBandstop Filter DesignFilter Design

• Note: The condition can also be satisfied by increasing which is not acceptable as the high-frequency passband is decreased from the desired value

• Alternately, the condition can be satisfied by decreasing which is not acceptable as the stopband is decreased

21212 ˆˆˆˆˆ ssppo ΩΩ=ΩΩ=Ω

2ˆ pΩ

2ˆ sΩ

Page 11: IIR Filters

1

1Copyright © 2005, S. K. Mitra

Digital Filter DesignDigital Filter Design

• Objective - Determination of a realizable transfer function G(z) approximating a given frequency response specification is an important step in the development of a digital filter

• If an IIR filter is desired, G(z) should be a stable real rational function

• Digital filter design is the process of deriving the transfer function G(z)

2Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• Usually, either the magnitude and/or the

phase (delay) response is specified for the design of digital filter for most applications

• In some situations, the unit sample responseor the step response may be specified

• In most practical applications, the problem of interest is the development of a realizable approximation to a given magnitude response specification

3Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• We discuss in this course only the

magnitude approximation problem• There are four basic types of ideal filters

with magnitude responses as shown below

1

0 c – c

HLP(e j )

0 c – c

1

HHP(e j )

11–

– c1 c1 – c2 c2

HBP (e j )

1

– c1 c1 – c2 c2

HBS(e j )

4Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• As the impulse response corresponding to

each of these ideal filters is noncausal and of infinite length, these filters are not realizable

• In practice, the magnitude response specifications of a digital filter in the passband and in the stopband are given with some acceptable tolerances

• In addition, a transition band is specified between the passband and stopband

5Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• For example, the magnitude response

of a digital lowpass filter may be given as indicated below

)( ωjeG

6Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• As indicated in the figure, in the passband,

defined by , we require that with an error , i.e.,

• In the stopband, defined by , we require that with an error , i.e.,

1)( ≅ωjeG

0)( ≅ωjeG sδ

pδ±pω≤ω≤0

π≤ω≤ωs

ppj

p eG ω≤ωδ+≤≤δ− ω ,1)(1

π≤ω≤ωδ≤ωss

jeG ,)(

Page 12: IIR Filters

2

7Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• - passband edge frequency• - stopband edge frequency• - peak ripple value in the passband• - peak ripple value in the stopband• Since is a periodic function of ω,

and of a real-coefficient digital filter is an even function of ω

• As a result, filter specifications are given only for the frequency range

sδpδ

)( ωjeG)( ωjeG

π≤ω≤08

Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications

• Specifications are often given in terms of loss function A in dB

• Peak passband rippledB

• Minimum stopband attenuationdB

)(log20)( 10ω−=ω jeG

)1(log20 10 pp δ−−=α

)(log20 10 ss δ−=α

9Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• Magnitude specifications may alternately be

given in a normalized form as indicated below

10Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• Here, the maximum value of the magnitude

in the passband is assumed to be unity

• - Maximum passband deviation, given by the minimum value of the magnitude in the passband

• - Maximum stopband magnitudeA1

21/1 ε+

11Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications

• For the normalized specification, maximum value of the gain function or the minimum value of the loss function is 0 dB

• Maximum passband attenuation -dB

• For , it can be shown thatdB

( )210max 1log20 ε+=α

1<<δ p)21(log20 10max pδ−−≅α

12Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications• In practice, passband edge frequency

and stopband edge frequency are specified in Hz

• For digital filter design, normalized bandedge frequencies need to be computed from specifications in Hz using

TFF

FF p

T

p

T

pp π=

π=

Ω=ω 2

2

TFF

FF s

T

s

T

ss π=π=Ω=ω 22

sFpF

Page 13: IIR Filters

3

13Copyright © 2005, S. K. Mitra

Digital Filter SpecificationsDigital Filter Specifications

• Example - Let kHz, kHz, and kHz

• Then

7=pF 3=sF25=TF

π=××π=ω 56.01025

)107(23

3

p

π=××π=ω 24.01025

)103(23

3

s

14Copyright © 2005, S. K. Mitra

• The transfer function H(z) meeting the frequency response specifications should be a causal transfer function

• For IIR digital filter design, the IIR transfer function is a real rational function of :

• H(z) must be a stable transfer function and must be of lowest order N for reduced computational complexity

Selection of Filter TypeSelection of Filter Type

1−z

NMzdzdzddzpzpzppzH N

N

MM ≤

++++++++= −−−

−−−,)( 2

21

10

22

110

L

L

15Copyright © 2005, S. K. Mitra

Selection of Filter TypeSelection of Filter Type• For FIR digital filter design, the FIR

transfer function is a polynomial in with real coefficients:

• For reduced computational complexity, degree N of H(z) must be as small as possible

• If a linear phase is desired, the filter coefficients must satisfy the constraint:

∑==

−N

n

nznhzH0

][)(

][][ nNhnh −±=

1−z

16Copyright © 2005, S. K. Mitra

Selection of Filter TypeSelection of Filter Type• Advantages in using an FIR filter -

(1) Can be designed with exact linear phase,(2) Filter structure always stable with quantized coefficients

• Disadvantages in using an FIR filter - Order of an FIR filter, in most cases, is considerably higher than the order of an equivalent IIR filter meeting the same specifications, and FIR filter has thus higher computational complexity

17Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• Most common approach to IIR filter design -(1) Convert the digital filter specifications into an analog prototype lowpass filter specifications

• (2) Determine the analog lowpass filter transfer function

• (3) Transform into the desired digital transfer function

)(sHa

)(zG)(sHa

18Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• This approach has been widely used for the following reasons:(1) Analog approximation techniques are highly advanced(2) They usually yield closed-form solutions(3) Extensive tables are available for analog filter design(4) Many applications require digital simulation of analog systems

Page 14: IIR Filters

4

19Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• An analog transfer function to be denoted as

where the subscript “a” specifically indicates the analog domain

• A digital transfer function derived from shall be denoted as

)()()( sD

sPsHa

aa =

)()()( zD

zPzG =

)(sHa

20Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• Basic idea behind the conversion of into is to apply a mapping from the s-domain to the z-domain so that essential properties of the analog frequency response are preserved

• Thus mapping function should be such that– Imaginary ( ) axis in the s-plane be

mapped onto the unit circle of the z-plane– A stable analog transfer function be mapped

into a stable digital transfer function

)(sHa)(zG

Ωj

21Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• FIR filter design is based on a direct approximation of the specified magnitude response, with the often added requirement that the phase be linear

• The design of an FIR filter of order N may be accomplished by finding either the length-(N+1) impulse response samplesor the (N+1) samples of its frequency response

][nh

)( ωjeH22

Copyright © 2005, S. K. Mitra

Digital Filter Design: Digital Filter Design: Basic ApproachesBasic Approaches

• Three commonly used approaches to FIR filter design -(1) Windowed Fourier series approach(2) Frequency sampling approach(3) Computer-based optimization methods

23Copyright © 2005, S. K. Mitra

IIR Digital Filter Design: Bilinear IIR Digital Filter Design: Bilinear Transformation MethodTransformation Method

• Bilinear transformation -

• Above transformation maps a single point in the s-plane to a unique point in the z-plane and vice-versa

• Relation between G(z) and is then given by

⎟⎟⎠

⎞⎜⎜⎝

⎛+−= −

1

1

112

zz

Ts

)(sHa

⎟⎟

⎜⎜

−+

−−=

=11

112)()(z

zTsa sHzG

24Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• Digital filter design consists of 3 steps:

(1) Develop the specifications of by applying the inverse bilinear transformation to specifications of G(z)(2) Design(3) Determine G(z) by applying bilinear transformation to

• As a result, the parameter T has no effect on G(z) and T = 2 is chosen for convenience

)(sHa

)(sHa

)(sHa

Page 15: IIR Filters

5

25Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• Inverse bilinear transformation for T = 2 is

• For

• Thus,

ssz −

+= 11

oo js Ω+σ=

22

222

)1()1(

)1()1(

oo

oo

oo

oo zjjz

Ω+σ−Ω+σ+

=⇒Ω−σ−Ω+σ+

=

10 =→=σ zo

10 <→<σ zo

10 >→>σ zo 26Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation

• Mapping of s-plane into the z-plane

27Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• For with T = 2 we have

or

)()(

11

2/2/2/

2/2/2/

ω−ωω−

ω−ωω−

ω−

ω−

+−=

+−=Ω jjj

jjj

j

j

eeeeee

eej

ω= jez

)2/tan(ω=Ω)2/tan(

)2/cos(2)2/sin(2 ω=

ωω= jj

28Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• Mapping is highly nonlinear • Complete negative imaginary axis in the s-

plane from to is mapped into the lower half of the unit circle in the z-plane from to

• Complete positive imaginary axis in the s-plane from to is mapped into the upper half of the unit circle in the z-plane from to

−∞=Ω 0=Ω

0=Ω ∞=Ω

1−=z 1=z

1=z 1−=z

29Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• Nonlinear mapping introduces a distortion

in the frequency axis called frequency warping

• Effect of warping shown belowΩ Ω = tan(ω/2)

30Copyright © 2005, S. K. Mitra

Bilinear TransformationBilinear Transformation• Steps in the design of a digital filter -

(1) Prewarp to find their analog equivalents(2) Design the analog filter(3) Design the digital filter G(z) by applying bilinear transformation to

• Transformation can be used only to design digital filters with prescribed magnitude response with piecewise constant values

• Transformation does not preserve phase response of analog filter

),( sp ωω),( sp ΩΩ

)(sHa

)(sHa

Page 16: IIR Filters

6

31Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Example - Consider

• Applying bilinear transformation to the above we get the transfer function of a first-order digital lowpass Butterworth filter

c

ca s

sHΩ+

Ω=)(

)1()1()1()()( 11

1

11

11 −−

−+

−−= +Ω+−+Ω

==zz

zsHzGc

c

zzsa

32Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Rearranging terms we get

where

1

1

11

21)( −

−+⋅−=

zzzG

αα

)2/tan(1)2/tan(1

11

c

c

c

cω+ω−=

Ω+Ω−=α

33Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Example - Consider the second-order analog notch transfer function

for which

• is called the notch frequency• If then

is the 3-dB notch bandwidth

22

22)(

o

oa sBs

ssHΩ++

Ω+=

0)( =Ωoa jH1)()0( =∞= jHjH aa

oΩ2/1)()( 12 =Ω=Ω jHjH aa

12 Ω−Ω=B34

Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Then

where

1

1

11)()(

+−=

=zzsa sHzG

22122

22122

)1()1(2)1()1()1(2)1(

−−

−−

−Ω++Ω−−+Ω+Ω++Ω−−Ω+=

zBzBzz

ooo

ooo

21

21

)1(2121

21

−−

−−

++−+−⋅+=

zzzz

ααββα

oo

o ω=Ω+Ω−

=β cos11

2

2)2/tan(1)2/tan(1

11

2

2

w

w

o

oBB

BB

+−

=+Ω+−Ω+

35Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Example - Design a 2nd-order digital notch filter operating at a sampling rate of 400 Hzwith a notch frequency at 60 Hz, 3-dB notch bandwidth of 6 Hz

• Thus

• From the above values we get

π=π=ω 3.0)400/60(2oπ=π= 03.0)400/6(2wB

90993.0=α

587785.0=β36

Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using Bilinear TransformationBilinear Transformation

• Thus

• The gain and phase responses are shown below

21

21

90993.01226287.11954965.01226287.1954965.0)( −−

−−

+−+−

=zz

zzzG

0 50 100 150 200-40

-30

-20

-10

0

Frequency, Hz

Gai

n, d

B

0 50 100 150 200-2

-1

0

1

2

Frequency, Hz

Pha

se, r

adia

ns

Page 17: IIR Filters

7

37Copyright © 2005, S. K. Mitra

IIR IIR LowpassLowpass Digital Filter Design Digital Filter Design Using Bilinear TransformationUsing Bilinear Transformation

• Example - Design a lowpass Butterworth digital filter with , ,

dB, and dB• Thus

• If this implies

π=ω 25.0p π=ω 55.0s15≥αs5.0≤α p

5.0)(log20 25.010 −≥πjeG

15)(log20 55.010 −≤πjeG

1)( 0 =jeG1220185.02 =ε 622777.312 =A

38Copyright © 2005, S. K. Mitra

IIR IIR LowpassLowpass Digital Filter Design Digital Filter Design Using Bilinear TransformationUsing Bilinear Transformation

• Prewarping we get

• The inverse transition ratio is

• The inverse discrimination ratio is

4142136.0)2/25.0tan()2/tan( =π=ω=Ω pp

1708496.1)2/55.0tan()2/tan( =π=ω=Ω ss

8266809.21=

ΩΩ

=p

sk

841979.1511 2

1=

ε−= A

k

39Copyright © 2005, S. K. Mitra

IIR IIR LowpassLowpass Digital Filter Design Digital Filter Design Using Bilinear TransformationUsing Bilinear Transformation

• Thus

• We choose N = 3• To determine we use

6586997.2)/1(log)/1(log

10

110 ==kkN

222

11

)/(11)(

ε+=

ΩΩ+=Ω N

cppa jH

40Copyright © 2005, S. K. Mitra

IIR IIR LowpassLowpass Digital Filter Design Digital Filter Design Using Bilinear TransformationUsing Bilinear Transformation

• We then get

• 3rd-order lowpass Butterworth transfer function for is

• Denormalizing to get we arrive at

588148.0)(419915.1 =Ω=Ω pc

1=Ωc

)1)(1(1)( 2 +++

=sss

sHan

⎟⎠⎞

⎜⎝⎛=

588148.0)( sHsH ana

588148.0=Ωc

41Copyright © 2005, S. K. Mitra

IIR IIR LowpassLowpass Digital Filter Design Digital Filter Design Using Bilinear TransformationUsing Bilinear Transformation

• Applying bilinear transformation to we get the desired digital transfer function

• Magnitude and gain responses of G(z) shown below:

)(sHa

1

1

11)()(

+−=

=zzsa sHzG

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

ω/π

Mag

nitu

de

0 0.2 0.4 0.6 0.8 1-40

-30

-20

-10

0

ω/π

Gai

n, d

B

42Copyright © 2005, S. K. Mitra

Design of IIR Design of IIR HighpassHighpass, , BandpassBandpass, , and and BandstopBandstop Digital FiltersDigital Filters

• First Approach -(1) Prewarp digital frequency specifications of desired digital filter to arrive at frequency specifications of analog filter of same type(2) Convert frequency specifications of into that of prototype analog lowpass filter

(3) Design analog lowpass filter

)(zGD)(sHD

)(sHD

)(sHLP

)(sHLP

Page 18: IIR Filters

8

43Copyright © 2005, S. K. Mitra

Design of IIR Design of IIR HighpassHighpass, , BandpassBandpass, , and and BandstopBandstop Digital FiltersDigital Filters

(4) Convert into using inverse frequency transformation used in Step 2(5) Design desired digital filter by applying bilinear transformation to

)(sHLP )(sHD

)(zGD)(sHD

44Copyright © 2005, S. K. Mitra

Design of IIR Design of IIR HighpassHighpass, , BandpassBandpass, , and and BandstopBandstop Digital FiltersDigital Filters

• Second Approach -(1) Prewarp digital frequency specifications of desired digital filter to arrive at frequency specifications of analog filter of same type(2) Convert frequency specifications of into that of prototype analog lowpass filter

)(zGD)(sHD

)(sHLP

)(sHD

45Copyright © 2005, S. K. Mitra

Design of IIR Design of IIR HighpassHighpass, , BandpassBandpass, , and and BandstopBandstop Digital FiltersDigital Filters

(3) Design analog lowpass filter(4) Convert into an IIR digital transfer function using bilinear transformation(5) Transform into the desired digital transfer function

• We illustrate the first approach

)(sHLP

)(sHLP)(zGLP

)(zGLP)(zGD

46Copyright © 2005, S. K. Mitra

IIR IIR HighpassHighpass Digital Filter DesignDigital Filter Design• Design of a Type 1 Chebyshev IIR digital

highpass filter• Specifications: Hz, Hz,

dB, dB, kHz• Normalized angular bandedge frequencies

700=pF 500=sF2=TF1=α p 32=αs

π=×π=π

=ω 7.02000

70022

T

pp F

F

π=×π=π=ω 5.02000

50022T

ss F

F

47Copyright © 2005, S. K. Mitra

IIR IIR HighpassHighpass Digital Filter DesignDigital Filter Design• Prewarping these frequencies we get

• For the prototype analog lowpass filter choose

• Using we get• Analog lowpass filter specifications: ,

, dB, dB

ΩΩΩ

−=Ω ˆˆ pp

1=Ω p

962105.1=Ωs

9626105.1)2/tan(ˆ =ω=Ω pp

0.1)2/tan(ˆ =ω=Ω ss

1=Ω p

926105.1=Ωs 1=α p 32=αs

48Copyright © 2005, S. K. Mitra

IIR IIR HighpassHighpass Digital Filter DesignDigital Filter Design• MATLAB code fragments used for the design

[N, Wn] = cheb1ord(1, 1.9626105, 1, 32, ’s’)[B, A] = cheby1(N, 1, Wn, ’s’);[BT, AT] = lp2hp(B, A, 1.9626105);[num, den] = bilinear(BT, AT, 0.5);

0 0.2 0.4 0.6 0.8 1-50

-40

-30

-20

-10

0

ω/π

Gai

n, d

B

Page 19: IIR Filters

9

49Copyright © 2005, S. K. Mitra

IIR IIR BandpassBandpass Digital Filter DesignDigital Filter Design• Design of a Butterworth IIR digital bandpass

filter• Specifications: , ,

, , dB, dB• Prewarping we get

π=ω 45.01p π=ω 65.02p

π=ω 75.02sπ=ω 3.01s 1=α p 40=αs

8540807.0)2/tan(ˆ 11 =ω=Ω pp

6318517.1)2/tan(ˆ 22 =ω=Ω pp

41421356.2)2/tan(ˆ 22 =ω=Ω ss

5095254.0)2/tan(ˆ 11 =ω=Ω ss

50Copyright © 2005, S. K. Mitra

IIR IIR BandpassBandpass Digital Filter DesignDigital Filter Design

• Width of passband

• We therefore modify so that and exhibit geometric symmetry with

respect to• We set• For the prototype analog lowpass filter we

choose

777771.0ˆˆ 12 =Ω−Ω= ppwB393733.1ˆˆˆ 21

2 =ΩΩ=Ω ppo2

21 ˆ23010325.1ˆˆ oss Ω≠=ΩΩ1ˆ sΩ

2ˆ sΩ1ˆ sΩ

2ˆ oΩ5773031.0ˆ 1 =Ωs

1=Ω p

51Copyright © 2005, S. K. Mitra

IIR IIR BandpassBandpass Digital Filter DesignDigital Filter Design

• Using we get

• Specifications of prototype analog Butterworth lowpass filter:

, , dB,dB

w

op BΩ

Ω−ΩΩ−=Ω ˆ

ˆˆ 22

3617627.2777771.05773031.0

3332788.0393733.1 =×

−=Ωs

1=Ω p 3617627.2=Ωs 1=α p40=αs

52Copyright © 2005, S. K. Mitra

IIR IIR BandpassBandpass Digital Filter DesignDigital Filter Design• MATLAB code fragments used for the design

[N, Wn] = buttord(1, 2.3617627, 1, 40, ’s’)[B, A] = butter(N, Wn, ’s’);[BT, AT] = lp2bp(B, A, 1.1805647, 0.777771);[num, den] = bilinear(BT, AT, 0.5);

0 0.2 0.4 0.6 0.8 1-50

-40

-30

-20

-10

0

ω/π

Gai

n, d

B

53Copyright © 2005, S. K. Mitra

IIR IIR BandstopBandstop Digital Filter DesignDigital Filter Design• Design of an elliptic IIR digital bandstop filter• Specifications: , ,

, , dB, dB• Prewarping we get

• Width of stopband

π=ω 45.01s π=ω 65.02sπ=ω 75.02pπ=ω 3.01p 1=α p 40=αs

,8540806.0ˆ 1 =Ωs ,6318517.1ˆ 2 =Ωs

,5095254.0ˆ 1 =Ω p 4142136.2ˆ 2 =Ω p777771.0ˆˆ 12 =Ω−Ω= sswB

393733.1ˆˆˆ 122 =ΩΩ=Ω sso

212 ˆ230103.1ˆˆ opp Ω≠=ΩΩ

54Copyright © 2005, S. K. Mitra

IIR IIR BandstopBandstop Digital Filter DesignDigital Filter Design• We therefore modify so that and

exhibit geometric symmetry with respect to

• We set• For the prototype analog lowpass filter we

choose• Using we get

1ˆ pΩ 1ˆ pΩ 2ˆ pΩ

2ˆ oΩ

577303.0ˆ 1 =Ω p

1=Ωs

22 ˆˆˆ

Ω−ΩΩΩ=Ωo

ws

B

0.42341263332787.0393733.1

777771.05095254.0 =−

×=Ω p

Page 20: IIR Filters

10

55Copyright © 2005, S. K. Mitra

IIR IIR BandstopBandstop Digital Filter DesignDigital Filter Design• MATLAB code fragments used for the design

[N, Wn] = ellipord(0.4234126, 1, 1, 40, ’s’);[B, A] = ellip(N, 1, 40, Wn, ’s’);[BT, AT] = lp2bs(B, A, 1.1805647, 0.777771);[num, den] = bilinear(BT, AT, 0.5);

0 0.2 0.4 0.6 0.8 1-50

-40

-30

-20

-10

0

ω/π

Gai

n, d

B

Page 21: IIR Filters

1

1Copyright © 2005, S. K. Mitra

Least IntegralLeast Integral--Squared Error Squared Error Design of FIR FiltersDesign of FIR Filters

• Let denote the desired frequency response

• Since is a periodic function of with a period , it can be expressed as a Fourier series

where

)( ωjd eH

)( ωjd eH ω

π2

∫ ∞≤≤∞−ωπ

π−

ωω ndeeHnh njjdd ,)(

21][

∑=∞

−∞=

ω−ω

n

njd

jd enheH ][)(

2Copyright © 2005, S. K. Mitra

Least IntegralLeast Integral--Squared Error Squared Error Design of FIR FiltersDesign of FIR Filters

• In general, is piecewise constant with sharp transitions between bands

• In which case, is of infinite length and noncausal

• Objective - Find a finite-duration of length 2M+1 whose DTFT approximates the desired DTFT in some sense

)( ωjd eH

)( ωjd eH

)( ωjt eH ][nht

][nhd

3Copyright © 2005, S. K. Mitra

Least IntegralLeast Integral--Squared Error Squared Error Design of FIR FiltersDesign of FIR Filters

• Commonly used approximation criterion -Minimize the integral-squared error

where

ω∫ −π

=Φπ

π−

ωω deHeH jd

jt

2)()(

21

∑=−=

ω−ω M

Mn

njt

jt enheH ][)(

4Copyright © 2005, S. K. Mitra

Least IntegralLeast Integral--Squared Error Squared Error Design of FIR FiltersDesign of FIR Filters

• Using Parseval’s relation we can write

• It follows from the above that is minimum when for

• Best finite-length approximation to ideal infinite-length impulse response in the mean-square sense is obtained by truncation

∑ −=Φ∞

−∞=ndt nhnh 2][][

∑ ∑++∑ −=−−

−∞=

+=−=

1

1

222 ][][][][M

n Mndd

M

Mndt nhnhnhnh

Φ][][ nhnh dt = MnM ≤≤−

5Copyright © 2005, S. K. Mitra

Least IntegralLeast Integral--Squared Error Squared Error Design of FIR FiltersDesign of FIR Filters

• A causal FIR filter with an impulse response h[n] can be derived from by delaying:

• The causal FIR filter h[n] has the same magnitude response as and its phase response has a linear phase shift of radians with respect to that of

][nht

][nht

][nht

][][ Mnhnh t −=

6Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal lowpass filter -

• Ideal highpass filter -

∞≤≤∞−πω= nn

nnh cLP ,sin][

1

0 c – c

HLP(e j )

0 c – c

1

HHP(e j )

⎪⎩

⎪⎨

≠πω−

=πω−

=0,)sin(

0,1][

nnn

nnh

c

c

HP

Page 22: IIR Filters

2

7Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal bandpass filter -

⎪⎩

⎪⎨

=πω−π

ω

≠πω−π

ω

=0,

0,)sin()sin(

][12

12

n

nnn

nn

nhcc

cc

BP

11–

– c1 c1 – c2 c2

HBP (e j )

8Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal bandstop filter -

1

– c1 c1 – c2 c2

HBS(e j )

⎪⎩

⎪⎨

≠πω−π

ω

=πω−ω−

=0,)sin()sin(

0,)(1][

21

12

nnn

nn

nnh

cc

cc

BS

9Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal multiband filter -

0

1 2 3 4

HML(e j )

A5

A 4

A3

A2

A1

,)( kj

ML AeH =ω

,1 kk ω≤ω≤ω −

Lk ,,2,1 K=

∑=

+ πω⋅−=

LL

ML nnAAnh

11

)sin()(][l

ll

10Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal discrete-time Hilbert transformer -

⎩⎨⎧

π<ω<−<ω<π−

0,0,

)(j

jeH j

HT

⎩⎨⎧

π=

oddforn,2/evenfor,0

][nn

nhHT

11Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal FiltersFilters

• Ideal discrete-time differentiator -

π≤ω≤ω=ω 0,)( jeH jDIF

⎪⎩

⎪⎨⎧

≠π=

= 0,cos0,0

][ nnn

nnhDIF

12Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Gibbs phenomenon - Oscillatory behavior in

the magnitude responses of causal FIR filters obtained by truncating the impulse response coefficients of ideal filters

0 0.2 0.4 0.6 0.8 10

0.5

1

1.5

ω/π

Mag

nitu

de

N = 20N = 60

Page 23: IIR Filters

3

13Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• As can be seen, as the length of the lowpass

filter is increased, the number of ripples in both passband and stopband increases, with a corresponding decrease in the ripple widths

• Height of the largest ripples remain the same independent of length

• Similar oscillatory behavior observed in the magnitude responses of the truncated versions of other types of ideal filters 14

Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Gibbs phenomenon can be explained by

treating the truncation operation as an windowing operation:

• In the frequency domain

• where and are the DTFTsof and , respectively

][][][ nwnhnh dt ⋅=

∫ ϕΨ=π

π−

ϕ−ωϕπ

ω deeHeH jjd

jt )()()( )(

21

)( ωjt eH )( ωΨ je

][nht ][nw

15Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Thus is obtained by a periodic

continuous convolution of with)( ωj

t eH

)( ωΨ je)( ωj

d eH

16Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon

• If is a very narrow pulse centered at (ideally a delta function) compared to

variations in , then will approximate very closely

• Length 2M+1 of w[n] should be very large• On the other hand, length 2M+1 of

should be as small as possible to reduce computational complexity

)( ωΨ je

)( ωjd eH

)( ωjd eH

)( ωjt eH

][nht

0=ω

17Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• A rectangular window is used to achieve

simple truncation:

• Presence of oscillatory behavior in is basically due to:– 1) is infinitely long and not absolutely

summable, and hence filter is unstable– 2) Rectangular window has an abrupt transition

to zero

⎩⎨⎧ ≤≤

=otherwise,00,1

][Mn

nwR

)( ωjt eH

][nhd

18Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Oscillatory behavior can be explained by

examining the DTFT of :

• has a main lobe centered at• Other ripples are called sidelobes

][nwR)( ωΨ jR e

)( ωΨ jR e 0=ω

-1 -0.5 0 0.5 1-10

0

10

20

30

ω/π

Am

plitu

de

Rectangular window

M = 4

M = 10 main lobe

side lobe

Page 24: IIR Filters

4

19Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Main lobe of characterized by its

width defined by first zero crossings on both sides of

• As M increases, width of main lobe decreases as desired

• Area under each lobe remains constant while width of each lobe decreases with an increase in M

• Ripples in around the point of discontinuity occur more closely but with no decrease in amplitude as M increases

)( ωΨ jR e

0=ω)12/(4 +π M

)( ωjt eH

20Copyright © 2005, S. K. Mitra

Gibbs PhenomenonGibbs Phenomenon• Rectangular window has an abrupt transition

to zero outside the range , which results in Gibbs phenomenon in

• Gibbs phenomenon can be reduced either:(1) Using a window that tapers smoothly to zero at each end, or(2) Providing a smooth transition from passband to stopband in the magnitude specifications

MnM ≤≤−)( ωj

t eH

Page 25: IIR Filters

1

1Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions• Using a tapered window causes the height

of the sidelobes to diminish, with a corresponding increase in the main lobe width resulting in a wider transition at the discontinuity

• Hann:

• Hamming:

• Blackman:)12

4cos(08.0)122cos(5.042.0][ +

π++π+= M

nM

nnw

),122cos(46.054.0][ ++= M

nnw π

),122cos(5.05.0][ ++= M

nnw π MnM ≤≤−

MnM ≤≤−

2Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions• Plots of magnitudes of the DTFTs of these

windows for M = 25 are shown below:

0 0.2 0.4 0.6 0.8 1-100

-80

-60

-40

-20

0

ω/π0 0.2 0.4 0.6 0.8 1

-100

-80

-60

-40

-20

0

ω/π

0 0.2 0.4 0.6 0.8 1-100

-80

-60

-40

-20

0

ω/π0 0.2 0.4 0.6 0.8 1

-100

-80

-60

-40

-20

0

ω/π

Hann window

Gai

n, d

B

Gai

n, d

B

Gai

n, d

B

Gai

n, d

B

Rectangular window

Hamming window Blackman window

3Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions• Magnitude spectrum of each window

characterized by a main lobe centered at ω = 0 followed by a series of sidelobes with decreasing amplitudes

• Parameters predicting the performance of a window in filter design are:

• Main lobe width• Relative sidelobe level

4Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions

• Main lobe width - given by the distance between zero crossings on both sides of main lobe

• Relative sidelobe level - given by the difference in dB between amplitudes of largest sidelobe and main lobe

ML∆

lsA

5Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions

• Observe• Thus,• Passband and stopband ripples are the same

1)()( )()( ≅+ ω∆−ωω∆+ω cc jt

jt eHeH

5.0)( ≅cjt eH ω

6Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions

• Distance between the locations of the maximum passband deviation and minimum stopband value

• Width of transition band

ML∆≅

MLps ∆<−=∆ ωωω

Page 26: IIR Filters

2

7Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions

• To ensure a fast transition from passband to stopband, window should have a very small main lobe width

• To reduce the passband and stopband ripple δ, the area under the sidelobes should be very small

• Unfortunately, these two requirements are contradictory

8Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions

• In the case of rectangular, Hann, Hamming, and Blackman windows, the value of ripple does not depend on filter length or cutoff frequency , and is essentially constant

• In addition,

where c is a constant for most practical purposes

Mc≈ω∆

9Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions• Rectangular window -

dB, dB,• Hann window -

dB, dB,• Hamming window -

dB, dB,• Blackman window -

dB, dB,

)12/(4 +π=∆ MML

)12/(8 +π=∆ MML

)12/(8 +π=∆ MML

)12/(12 +π=∆ MML

3.13=lsA

5.31=lsA

7.42=lsA

1.58=lsA

9.20=αs

9.43=αs

5.54=αs

3.75=αs

M/92.0 π=ω∆

M/11.3 π=ω∆

M/32.3 π=ω∆

M/56.5 π=ω∆

10Copyright © 2005, S. K. Mitra

Fixed Window FunctionsFixed Window Functions• Filter Design Steps -

(1) Set

(2) Choose window based on specified(3) Estimate M using

Mc≈ω∆

2/)( spc ω+ω=ω

11Copyright © 2005, S. K. Mitra

FIR Filter Design ExampleFIR Filter Design Example• Lowpass filter of length 51 and 2/π=ωc

0 0.2 0.4 0.6 0.8 1

-100

-50

0

ω/π

Gai

n, d

B

Lowpass Filter Designed Using Blackman window

0 0.2 0.4 0.6 0.8 1

-100

-50

0

ω/π

Gai

n, d

B

Lowpass Filter Designed Using Hann window

0 0.2 0.4 0.6 0.8 1

-100

-50

0

ω/π

Gai

n, d

B

Lowpass Filter Designed Using Hamming window

12Copyright © 2005, S. K. Mitra

FIR Filter Design ExampleFIR Filter Design Example

• An increase in the main lobe width is associated with an increase in the width of the transition band

• A decrease in the sidelobe amplitude results in an increase in the stopband attenuation

Page 27: IIR Filters

3

13Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window Functions• Dolph-Chebyshev Window -

where

and

],122cos)12cos(21[12

1][1

∑ +π

+β+γ+==

M

kk M

nkM

kTMnw

MnM ≤≤−

amplitude lobemain sidelobeofamplitude=γ

)1cosh21cosh( 1

γ=β −M

⎩⎨⎧

>≤

= −

1),coshcosh(1),coscos(

)( 1

1

xxxx

xTl

ll

14Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window Functions• Dolph-Chebyshev window can be designed

with any specified relative sidelobe level while the main lobe width adjusted by choosing length appropriately

• Filter order is estimated using

where is the normalized transition bandwidth, e.g, for a lowpass filter

)(85.24.16056.2

ω∆−α= sN

ps ω−ω=ω∆

ω∆

15Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window Functions• Gain response of a Dolph-Chebyshev

window of length 51 and relative sidelobelevel of 50 dB is shown below

0 0.2 0.4 0.6 0.8 1-80

-60

-40

-20

0

ω/π

Gai

n, d

B

Dolph-Chebyshev Window

16Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window FunctionsProperties of Dolph-Chebyshev window:• All sidelobes are of equal height• Stopband approximation error of filters

designed have essentially equiripplebehavior

• For a given window length, it has the smallest main lobe width compared to other windows resulting in filters with the smallest transition band

17Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window Functions• Kaiser Window -

where is an adjustable parameter and is the modified zeroth-order Bessel function of the first kind:

• Note for u > 0• In practice

MnMI

MnInw ≤≤−β

−β= ,)(

)/(1][0

20

β

∑+=∞

=1

20 ]!

)2/([1)(r

r

ruuI

0)(0 >uI∑+≅=

20

1

20 ]!

)2/([1)(r

r

ruuI

)(0 uI

18Copyright © 2005, S. K. Mitra

Adjustable Window FunctionsAdjustable Window Functions• controls the minimum stopband

attenuation of the windowed filter response• is estimated using

• Filter order is estimated using

where is the normalized transition bandwidth

β

β

⎪⎩

⎪⎨⎧

−α+−α

−α

=β,0

),21(07886.04.0)21(5842.0

),7.8(1102.0

ss

s

21for5021for

50for

<≤≤

>

s

s

s

αα

α

)(285.28ω∆

−α= sN

ω∆

Page 28: IIR Filters

4

19Copyright © 2005, S. K. Mitra

FIR Filter Design ExampleFIR Filter Design Example• Specifications: , ,

dB• Thus

• Choose N = 24 implying M =12

01.010 20/ ==δ α− ss

40=αs

π=ω 3.0p π=ω 5.0s

π=ω+ω=ω 4.02/)( spc

3953.31907886.0)19(5842.0 4.0 =×+=β

2886.22)2.0(285.2

32 =π

=N

20Copyright © 2005, S. K. Mitra

FIR Filter Design ExampleFIR Filter Design Example• Hence

where w[n] is the n-th coefficient of a length-25 Kaiser window with

1212],[)4.0sin(][ ≤≤−⋅ππ= nnwn

nnht

3953.3=β

0 0.2 0.4 0.6 0.8 1-80

-60

-40

-20

0

ω/π

Gai

n, d

B

Kaiser Window

0 0.2 0.4 0.6 0.8 1-80

-60

-40

-20

0

ω/π

Gai

n, d

B

Lowpass filter designed with Kaiser window

21Copyright © 2005, S. K. Mitra

Impulse Responses of FIR Filters Impulse Responses of FIR Filters with a Smooth Transitionwith a Smooth Transition

• First-order spline passband-to-stopbandtransition

⎪⎩

⎪⎨⎧

>πω⋅

ω∆ω∆

=πω= 0)sin()2/sin(2

0,/][ nn

nnn

nnh c

cLP

2/)( spc ω+ω=ω

ps ω−ω=ω∆

22Copyright © 2005, S. K. Mitra

Impulse Responses of FIR Filters Impulse Responses of FIR Filters with a Smooth Transitionwith a Smooth Transition

• Pth-order spline passband-to-stopbandtransition

⎪⎩

⎪⎨⎧

>πω

⋅⎟⎠⎞

⎜⎝⎛

ω∆ω∆

=πω=

0)sin(2/

)2/sin(20,/

][nn

nPn

Pnn

nh cP

c

LP

23Copyright © 2005, S. K. Mitra

LowpassLowpass FIR Filter Design FIR Filter Design ExampleExample

• Example

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

ω/π

Mag

nitu

de

P = 1, N = 40P = 2, N = 60

Page 29: IIR Filters

[dsp TIPS&TRICKS]Greg Berchin

Precise Filter Design

You have just been assignedto a new project at work,in which the objective isto replace an existing ana-log system with a func-

tionally equivalent digital system. Yourjob is to design a digital filter thatmatches the magnitude and phaseresponse of the existing system’s analogfilter over a broad frequency range. Youare running out of ideas. The bilineartransform and impulse invariancemethods provide poor matches to theanalog filter response, particularly athigh frequencies. Fast convolutionrequires more computational resourcesthan you have and creates moreinput/output latency than you can toler-ate. What will you do?

In this article, we describe an obscurebut simple and powerful method fordesigning a digital filter that approxi-mates an arbitrary magnitude and phaseresponse. If applied to the problemabove, it can create a filter roughly com-parable in computational burden andlatency to that created by the bilineartransform method, with fidelityapproaching that of fast convolution. Inaddition, the method described here canalso be applied to a wide variety of othersystem identification tasks.

The filter design method we presentis called frequency-domain least-squares(FDLS) [1]–[3]. The FDLS algorithmproduces a transfer function that approx-imates an arbitrary frequency response.The input to the algorithm is a set ofmagnitude and phase values at a largenumber (typically thousands) of arbitraryfrequencies between 0 Hz and half thesampling rate. The algorithm’s output isa set of transfer function coefficients.The FDLS algorithm is quite flexible inthat it can create transfer functions con-

taining poles and zeros (infinite responsefilters), only zeros (finite response fil-ters), or only poles (autoregressive net-works). The algorithm uses nothingmore esoteric than basic linear algebra.Before we can see how the techniqueworks, we need to review some basic lin-ear algebra and matrix concepts.

BACKGROUND First let us recall that, in order touniquely solve a system of equations, weneed as many equations as unknowns.For example, the single equation withone unknown 5x = 7 has the uniquesolution x = 7/5. But the single equa-tion with two unknowns 5x + 2y = 7has multiple solutions x = (7 − 2y)/5that depend on the unspecified y-value. Ifanother equation, −6x + 4y = 9, isadded to the equation above, there areunique solutions for both x and y thatcan be found algebraically or by matrixinversion (denoted in the following by a“−1” superscript):

[5 2

−6 4

] [xy

]=

[79

][

xy

]=

[5 2

−6 4

]−1 [79

]

=[ 1

8 − 116

316

532

] [79

]

=[ (

78 − 9

16

)(

2116 + 45

32

)].

Let us consider what happens if weadd another equation, x + y = 5, to thepair that we already have above (we willsee later why we might want to do this).There are no values of x and y that satis-fy all three equations simultaneously. Toaddress this case, matrix algebra providesthe “pseudoinverse,” which determinesthe values of x and y that come, in the

least-squares sense, as close as possibleto satisfying all three equations. Thesolution is then given by

5 2−6 41 1

[

xy

]=

7

95

or

[xy

]≈

5 2

−6 41 1

T 5 2

−6 41 1

−1

× 5 2

−6 41 1

T 7

95

≈[

0.37162.8491

],

where T denotes the matrix transpose. Ofcourse, the mathematical derivation ofthe matrix inverse and pseudoinverse,and the definition of least-squares, canbe found in any basic linear algebra text[1]. And while our more mathematicallyinclined readers will point out that thereare better ways than this to compute thepseudoinverse, this method is adequatefor our example.

You may also remember that filterspecifications are commonly expressed interms of passband width and flatness,transition band width, and stopbandattenuation. There may also be some gen-eral specifications about phase response

“DSP Tips and Tricks” introduces prac-tical design and implementation sig-nal processing algorithms that youmay wish to incorporate into yourdesigns. We encourage readers tosubmit their contributions toAssociate Editors Rick Lyons([email protected]) or Britt Rorabaugh([email protected]).

IEEE SIGNAL PROCESSING MAGAZINE [137] JANUARY 2007 1053-5888/07/$25.00©2007IEEE

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Text Box
for THIS case: p_inv(X) = [inv(X'X)][X']
gianni
Highlight
Page 30: IIR Filters

or time-domain performance, but theexact magnitude and phase responses areusually left to the designer’s discretion.However, an important exception occurswhen a digital filter is to be used to emu-late an analog filter. This is traditionally avery difficult problem, because analogsystems are described by Laplace trans-forms using integration and differentia-tion, whereas digital systems aredescribed by z-transforms using delay.Since the conversion between them isnonlinear, the response of an analog sys-tem can only be approximated by a digitalsystem and vice-versa.

Let us assume that the transfer func-tion of our digital filter (i.e., the mathe-matical description of the relationshipbetween the filter’s input and output) isin a standard textbook form [2] given by

Y(z )

U(z )= b0 + b1 z−1 + · · · + bN z−N

1 + a1 z−1 + · · · + aDz−D ,

where U(z ) is the z-transform of the inputsignal, Y(z ) is the z-transform of the out-put signal, and the a and b factors are real-valued coefficients. Furthermore, weassume that the filter is causal, meaningthat its response to an input does not beginuntil after the input is applied. Under theseassumptions, the time-domain differenceequation that implements our filter is

y(k) = − a1 y(k − 1) − · · · − aDy(k − D)

+ b0u(k) + · · · + bN u(k − N ),

where the a and b coefficients are exactlythe same as in the transfer functionabove, k is the time index, u(k) and y(k)are the current values of the input andoutput (respectively), u(k − N ) was theinput value N samples in the past, andy(k − D) was the output value D samplesin the past. We can write the equationabove in matrix form as

y(k) = [−y(k − 1) . . . − y(k − D)

u(k) . . . u(k − N )]

a1...

aD

b0...

bN

.

Let us conclude our background sec-tion with a comment on what a frequen-cy response value means. In a simpleexample, if the frequency response of asystem at a frequency ω1 is given inmagnitude/phase form as A1 φ1 , theoutput amplitude will be A1 times theinput amplitude and the output phasewill be shifted an angle φ1 relative to theinput phase when a steady-state sinewave of frequency ω1 is applied to thesystem. For instance, if the input to thesystem described above at time k isu1(k) = cos(kω1 ts), where ts is the sam-pling period (equal to one over the sam-pling frequency), then the output will bey1(k) = A1 cos(kω1 ts + φ1) . The inputand output values at any sample timecan be determined in a similar manner.For example, the input sample value Nsamples in the past wasu1(k − N) = cos ((k − N )ω1 ts) and theoutput sample value D samples in thepast was y1(k − D) = A1 cos ((k − D)

ω1 ts + φ1). For our purposes, since krepresents the current sample time, itsvalue can conveniently be set to zero.

FDLS FILTER APPROXIMATIONBased on our review of the pseudoin-verse, transfer function, and frequencyresponse, we know that the output is acombination of present and past inputand output values, each scaled by a set ofb or a coefficients (respectively), the val-

ues of which are not yet known. We alsoknow that the relationship betweeninput u and output y at any sample timecan be inferred from the frequencyresponse value A φ at frequency ω .Combining these two ideas, we obtainone equation in D + N + 1 unknowns

y1(0) = [−y1(−1) . . . − y1(−D)

u1(0) . . . u1(−N )]

a1...

aD

b0...

bN

.

(Note that the current-sample index khas been set to zero.) If we repeat usingA2 φ2 at a different frequency ω2, weobtain a second equation in D + N + 1unknowns as shown in (a) at the bottomof the page. And if we repeat at manymore different frequencies M than wehave unknowns D + N + 1, we knowfrom our review of linear algebra that thepseudoinverse will compute values forthe set of coefficients a1 . . . aD andb0 . . . bN that come as close as possibleto solving all of the equations, which isexactly what we need to design our filter.So now we can write (b), shown at thebottom of the page. We can denote they1(0) . . . yM(0) column vector above asY, the matrix as X, and the a1 . . . bN col-

[dsp TIPS&TRICKS] continued

IEEE SIGNAL PROCESSING MAGAZINE [138] JANUARY 2007

[y1(0)

y2(0)

]=

[−y1(−1) . . . −y1(−D) u1(0) . . . u1(−N)

−y2(−1) . . . −y2(−D) u2(0) . . . u2(−N)

]

a1...

aD

b0...

bN

. (a)

y1(0)

y2(0)...

yM(0)

=

−y1(−1) . . . −y1(−D) u1(0) . . . u1(−N)

−y2(−1) . . . −y2(−D) u2(0) . . . u2(−N)...

......

...

−yM(−1) . . . −yM(−D) uM(0) . . . uM(−N)

a1...

aD

b0...

bN

.

(b)

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 31: IIR Filters

IEEE SIGNAL PROCESSING MAGAZINE [139] JANUARY 2007

umn vector as . With these notations,Y = X, and the pseudoinverse solvesfor the vector that contains thedesired filter coefficients

(X TX )−1 X TY ≈ .

We can now summarize our filterdesign trick as follows:

1) Select the numerator order N andthe denominator order D, where Nand D do not have to be equal andeither one (but not both) may be zero.(We have found no “rule of thumb”for defining N and D; they are bestdetermined experimentally.)2) Define the M separate input um

cosine sequences, each of length(N + 1).3) Compute the M separate output ym

cosine sequences, each of length D(based on Am φm).4) Fill the X matrix with the input um

and output ym cosine sequences. 5) Fill the Y vector with the M outputcosine values, ym(0) = Am cos(φm). 6) Compute the pseudoinverse; theresulting vector contains the filtercoefficients.A numerical example is shown in

Figures 1 and 2, which illustrate themagnitude and phase, respectively, of areal-world example analog system (black)and of the associated bilinear transform(blue), impulse invariance (green), andFDLS (red) approximations. The sam-pling rate is equal to 240 Hz andD = N = 12. The red FDLS graphs arealmost completely obscured by the blackanalog system graphs. In this example,the FDLS errors are often three to fourorders of magnitude smaller than thoseof the other methods. (In Figure 2, thebilinear transform curve is obscured bythe FDLS and analog curves at low fre-quencies and by the impulse invariancecurve at high frequencies.)

In terms of the computational com-plexity of an FDIS-designed filter, thenumber of feedback and feed-forwardcoefficients is determined by the vari-ables D and N, respectively. As such, anFDIS-designed filter requires(N + D + 1) multiplies and (N + D)additions per filter output sample.

CONCLUSIONFDLS is a powerful method for design-ing digital filters. As is the case with allapproximation techniques, there arecircumstances in which the FDLSmethod works well and others in whichit does not. The FDLS method does notreplace other filter design methods; itprovides one more method from whichto choose. FDLS is most useful in caseswhere a specified frequency responsemust be duplicated to within tight tol-erances over a wide frequency range orwhen the frequency response of anexisting system is known but the coef-ficients of the system’s transfer func-tion are unknown. It is up to thedesigner to determine whether to useit in any given situation. Detailedexamples and a MATLAB code imple-mentation of the FDLS algorithm areavailable at http://apollo.ee.columbia.edu/spm/?i=external/tipsandtricks.

ACKNOWLEDGMENTSMy thanks to Jaime Andrés ArangurenCardona for providing the exampleshown in Figures 1 and 2, originallyposted on the comp.dsp Newsgroup on9 January 2005, which ultimately led tothis article.

AUTHORGreg Berchin ([email protected]) is a sig-nal processing algorithm engineer whoprovides contract engineering servicesfrom Naperville, Illinois.

REFERENCES[1] G. Strang, Linear Algebra and Its Applications,2nd ed., Orlando, FL: Academic, pp. 103–152, 1980.

[2] R. Lyons, Understanding Digital SignalProcessing, 2nd ed., Upper Saddle River, NJ:Prentice-Hall, pp. 232–240, 2004.

[3] G. Berchin, “A new algorithm for system identifi-cation from frequency response information,” mas-ter’s thesis, University of California-Davis, 1988 .

[4] G. Berchin and M.A. Soderstrand, “A transform-domain least-squares beamforming technique,” inProc. IEEE Oceans ‘90 Conf., Arlington, VA, Sept.1990.

[FIG1] Magnitude responses of the filter designed using the bilinear transform, impulseinvariance, and FDLS methods.

Black: Analog (Desired)Blue: Bilinear TransformGreen: Impulse InvarianceRed: FDLS

0

−10

−20

−30

−40

−50

10−2 10−1 100 101 102

Frequency (Hz)

Mag

nitu

de (

dB)

[FIG2] Phase responses of the filter designed using the bilinear transform, impulseinvariance, and FDLS methods.

Black: Analog (Desired)Blue: Bilinear TransformGreen: Impulse InvarianceRed: FDLS

150

100

50

0−50

−100

−150

Pha

se (

degr

ees)

10−2 10−1 100 101 102

Frequency (Hz)

[SP]

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 32: IIR Filters

FDLS Examples by Greg Berchin and Richard Lyons [January 2007]

The following material provides additional examples of the FDLS algorithm described in the January 2007 IEEE Signal Processing magazine DSP Tips & Tricks column article "Precise Filter Design" by Greg Berchin. Algebraic Example Recall the FDLS matrix expression

,

⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥

⎢⎢⎢⎢

−−−−−

−−−−−−−−−−

=

⎥⎥⎥⎥

⎢⎢⎢⎢

N

D

MMMMM

b

ba

a

NuuDyy

NuuDyyNuuDyy

y

yy

M

M

KK

MMMM

KK

KK

M 0

1

2222

1111

2

1

)()0()()1(

)()0()()1()()0()()1(

)0(

)0()0(

which we wrote as Y = XΘ.

Each individual element in the Y column vector is of the form Amcos(φm), and each

element in the X matrix is of the form A1cos(kω1ts + φ1) or cos(kω1ts). Because all of these

elements are of the form of a product (Amplitude)[cos(angle)], each element in Y and X is equal

to a constant.

Now if, say, D = 10 and N = 9, then:

y1(0) = A1cos(φ1)

is the first element of the Y column vector and

[–y1(–1) ... –y1(–10) u1(0) ... u1(–9)]

is the top row of the X matrix expression where

–y1(–1) = –A1cos[(–1)ω1ts + φ1] = –A1cos(–ω1ts + φ1)

–y1(–2) = –A1cos[(–2)ω1ts + φ1] = –A1cos(–2ω1ts + φ1)

...

–y1(–10) = –A1cos[(–10)ω1ts + φ1] = –A1cos(–10ω1ts + φ1)

and

u1(0) = cos[(0)ω1ts] = 1

u1(–1) = cos[(–1)ω1ts] = cos(–ω1ts)

u1(–2) = cos[(–2)ω1ts] = cos(–2ω1ts)

...

u1(–9) = cos[(–9)ω1ts] = cos(–9ω1ts).

IEEE Copyright © All Rights Reserved Page 1 of 5

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 33: IIR Filters

So the top row of the X matrix looks like:

[–A1cos(–ω1ts + φ1) –A1cos(–2ω1ts + φ1) ... –A1cos(–10ω1ts + φ1) 1 cos(–ω1ts)

cos(–2ω1ts) ... cos(–9ω1ts)].

The second row of the X matrix looks like:

[–A2cos(–ω2ts + φ2) –A2cos(–2ω2ts + φ2) ... –A2cos(–10ω2ts + φ2) 1 cos(–ω2ts)

cos(–2ω2ts) ... cos(–9ω2ts)].

And so on.

Numerical Example

Here’s an example of the above expressions using actual numbers. Suppose we

need to approximate the transfer function coefficients for the system whose frequency

magnitude and phase response is that shown in Figure E1. Assume that our discrete-

system sample rate is 1000 Hz, thus ts = 10–3 seconds, and N = D = 2. Also assume

M = 8 and we have the eight A1 -to- A8 magnitude sample values and the eight φ1 -to- φ8

phase samples, shown as dots in Figure E1, available to us as input values to the FDLS

algorithm.

M = 8

0 100 200 300 400 5000

0.5

1

1.5

Line

ar

0 100 200 300 400 500–2

0

2

4

A1

A5

A8

Desired magnitude response

φ1

φ5

φ8

Desired phase response

f1 = 0 Hz

f4 = 51.18 Hz

f7 = 106.3 Hz f8 = 389.76 Hz

(a)

(b)

Frequency

Frequency

Pha

se (r

adia

ns)

ωm = 2π fm :

ω1 = 2π(0.0)ω2 = 2π(19.69)ω3 = 2π(35.43)ω4 = 2π(51.18)ω5 = 2π(59.05)ω6 = 2π(66.93)ω7 = 2π(106.30)ω8 = 2π(389.76)

.

Fig E1

IEEE Copyright © All Rights Reserved Page 2 of 5

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 34: IIR Filters

In matrix form, the target analog system parameters are

0.0 0.0 0.2172 0.0 19.6850 0.1237 0.2065 –0.0156 35.4331 0.2226 0.1696 –0.0383 fm = 51.1811 ωmts = 0.3216 Am = 0.0164 φm = 3.0125 59.0551 0.3711 1.3959 2.3087 66.9291 0.4205 0.6734 0.955 106.299 0.6679 0.3490 0.0343 389.764 2.449 0.3095 0.0031

where the fm vector is in Hz, the ωmts vector is in radians, and 1 ≤ m ≤ 8. The first two

elements of the Y vector are:

y1(0) = A1cos(φ1) = 0.2172cos(0) = 0.2172.

y2(0) = A2cos(φ2) = 0.2065cos(–0.0156) = 0.2065.

The complete Y vector is:

A1cos(φ1) 0.2172 A2cos(φ2) 0.2065 A3cos(φ3) 0.1695 Y = A4cos(φ4) = –0.0162 A5cos(φ5) –0.9390 A6cos(φ6) 0.6605 A7cos(φ7) 0.3488 A8cos(φ8) 0.3095

The two elements of the "y1" part of the first row of the X vector are:

–y1(–1) = –A1cos(–ω1ts + φ1) = –0.2172cos(–0 + 0) = –0.2172.

–y1(–2) = –A1cos(–2ω1ts + φ1) = –0.2172cos(–0 + 0) = –0.2172.

The two elements of the "y8" part of the eighth row of the X vector are:

–y8(–1) = –A8cos(–ω8ts + φ8) = –0.3095cos(–2.449 + 0.0031) = 0.2376.

–y8(–2) = –A8cos(–2ω8ts + φ8) = –0.3095cos(–4.898 + 0.0031) = –0.562.

IEEE Copyright © All Rights Reserved Page 3 of 5

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 35: IIR Filters

The three elements of the "u1" part of the first row of the X matrix are:

u1(0) = cos(0) = 1

u1(–1) = cos(–ω1ts) = cos(–0) = 1

u1(–2) = cos(–2ω1ts) = cos(–0) = 1.

The three elements of the "u8" part of the eighth row of the X matrix are:

u8(0) = cos(0) = 1

u8(–1) = cos(–ω8ts) = cos(–2.449) = –0.7696

u8(–2) = cos(–2ω8ts) = cos(–4.898) = 0.1845.

The complete X matrix is:

–A1cos(–1ω1ts+φ1) –A1cos(–2ω1ts+φ1) cos(0) cos(–ω1ts) cos(–2ω1ts) –A2cos(–1ω2ts+φ2) –A2cos(–2ω2ts+φ2) cos(0) cos(–ω2ts) cos(–2ω2ts) –A3cos(–1ω3ts+φ3) –A3cos(–2ω3ts+φ3) cos(0) cos(–ω3ts) cos(–2ω3ts) X = –A4cos(–1ω4ts+φ4) –A4cos(–2ω4ts+φ4) cos(0) cos(–ω4ts) cos(–2ω4ts) –A5cos(–1ω5ts+φ5) –A5cos(–2ω5ts+φ5) cos(0) cos(–ω5ts) cos(–2ω5ts) –A6cos(–1ω6ts+φ6) –A6cos(–2ω6ts+φ6) cos(0) cos(–ω6ts) cos(–2ω6ts) –A7cos(–1ω7ts+φ7) –A7cos(–2ω7ts+φ7) cos(0) cos(–ω7ts) cos(–2ω7ts) –A8cos(–1ω8ts+φ8) –A8cos(–2ω8ts+φ8) cos(0) cos(–ω8ts) cos(–2ω8ts) –0.2172 –0.2172 1.00 1.0000 1.0000 –0.2045 –0.994 1.00 0.9924 0.9696 –0.1639 –0.1502 1.00 0.9753 0.9025 = 0.0147 0.0117 1.00 0.9487 0.8002 . 0.5007 –0.0059 1.00 0.939 0.7370 –0.6564 –0.5378 1.00 0.9129 0.6667 –0.2812 –0.0928 1.00 0.7851 0.2328 0.2376 –0.0562 1.00 –0.7696 0.1845

Given the above Y vector and the X matrix, the FDLS algorithm computes the 2nd-order

(N = D = 2) transfer function coefficients vector θM=8 as

–1.8439 0.9842 θM=8 = 0.3033 . –0.5762 0.3034

IEEE Copyright © All Rights Reserved Page 4 of 5

gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
gianni
Highlight
Page 36: IIR Filters

Treated as filter coefficients, we can write vector θM=8 as:

a0 = 1 a1 = –1.8439 a2 = 0.9842 b0 = 0.3033 b1 = –0.5762 b2 = 0.3034

implemented as the recursive filter network shown in Figure E2.

z –1

z –1

y(k)

–0.9842 0.3034

–0.5762

0.3033

1.8439

u(k)

Fig E2

The frequency-domain performance of the filter are the solid red curves shown in Figure E3. There we see that the θM=8 coefficients provide an accurate approximation to the desired frequency response in Figure E1.

0 100 200 300 400 500–40

–20

0

Mag

nitu

de (d

B)

0 100 200 300 400 500–2

0

2

4

Pha

se (r

adia

ns)

Desired phase responseActual phase response

Desired magnitude responseActual magnitude response

(a)

(b)

Frequency

Frequency

Fig E3

IEEE Copyright © All Rights Reserved Page 5 of 5

gianni
Highlight