Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse...

37
Copyrigh t © 2003 DSP C5000 DSP C5000 Chapter 15 Chapter 15 Infinite Impulse Response Infinite Impulse Response (IIR) (IIR) Filter Implementation Filter Implementation

Transcript of Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse...

Page 1: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

DSP C5000DSP C5000

Chapter 15Chapter 15

Infinite Impulse Response (IIR)Infinite Impulse Response (IIR)

Filter ImplementationFilter Implementation

Page 2: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 2

IIR FiltersIIR Filters

Rational Z transfer functionRational Z transfer function

Linear difference equationLinear difference equation

H zN z

D z

b z

a z

ii

i

Q

kk

k

P( )( )

( )

0

1

1

y b x a yn i n ii

Q

k n kk

P

0 1

Page 3: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 3

IIR Filters – Poles and ZerosIIR Filters – Poles and Zeros Roots of the nuRoots of the nummeratorerator

Roots of the denominatorRoots of the denominator

Q

ii

Q

i

ii zrbzb

0

10

0

1

Q

ii

Q

i

ii zrbzb

0

10

0

1

P

ii

P

i

ii zrza

0

1

1

11

P

ii

P

i

ii zrza

0

1

1

11

rrii are the roots of the are the roots of the zz polynomial with polynomial with bbi i coefficients. coefficients. HH(z) is null when(z) is null when

z z is equal to one of the values. They are called the zeroes of the filteris equal to one of the values. They are called the zeroes of the filter

and often noted by and often noted by zzi i ..

rrii are the roots of the are the roots of the zz polynomial with polynomial with aai i coefficientscoefficients.. HH(z) tends to infinity(z) tends to infinity

when when z z is close to one of these values. They are called the poles of the filtersis close to one of these values. They are called the poles of the filters

and often noted by and often noted by ppi i ..

Page 4: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 4

Z Transfer FunctionZ Transfer Function Define frequency behaviour of the filterDefine frequency behaviour of the filter

Consider a first order z rational filter:Consider a first order z rational filter:

DN

D

N

eTjeTj

eTj

jj

j

ezezez

eD

N

eD

eN

pz

zz

za

zbzH

1

11

1

11

1

1)(

DN

D

N

eTjeTj

eTj

jj

j

ezezez

eD

N

eD

eN

pz

zz

za

zbzH

1

11

1

11

1

1)(

HH(z) can be evaluated for each(z) can be evaluated for each

value value nn from 0 to 1 with 1 corres- from 0 to 1 with 1 corres-

ponding to sampling frequencyponding to sampling frequency

magnitudemagnitude phasephase

1p1z

)(N)(D

n ej Te

Page 5: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 5

Z Transfer FunctionZ Transfer Function We obtain the transfer function by evaluation We obtain the transfer function by evaluation

of the z transform on the unit circleof the z transform on the unit circle

We can see that it is a minimum phase filter We can see that it is a minimum phase filter (the phase comes back at 0 at F(the phase comes back at 0 at Fee/2) because the /2) because the zero of the filter is inside the unit circle.zero of the filter is inside the unit circle.

Page 6: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 6

Z Transfer FunctionZ Transfer Function If we change the zero If we change the zero zz11 to to 1/ z1/ z11 we get the same we get the same

magnitude transfer function (up to a scale magnitude transfer function (up to a scale factor) …factor) …

But a maximum phase filter (the phase goes to -But a maximum phase filter (the phase goes to - at F at Fee/2) because now, the zero lies outside the /2) because now, the zero lies outside the unit circle.unit circle.

Page 7: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 7

IIR Filter SynthesisIIR Filter Synthesis Starting from frequency specifications Starting from frequency specifications

(here low pass filter):(here low pass filter):

FFpasspass : passband end frequency,: passband end frequency, FFstopstop : stopband start frequency,: stopband start frequency, AApasspass : maximum passband ripple,: maximum passband ripple, AAstopstop : minimum stopband attenuation.: minimum stopband attenuation.

Page 8: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 8

IIR Filters SynthesisIIR Filters Synthesis

Analog prototype with analog to digital Analog prototype with analog to digital transformation (bilinear transform) :transformation (bilinear transform) : Digital to analog frequency specification Digital to analog frequency specification

transformation using prewarpingtransformation using prewarping Analog filter prototypeAnalog filter prototype Analog transfer function to digital transfer Analog transfer function to digital transfer

function transformation using bilinear function transformation using bilinear transform.transform.

Direct digital method : Yule WalkerDirect digital method : Yule Walker Try to find the recursive filter of order Try to find the recursive filter of order N N which which

is as close as possible to the frequency specifi-is as close as possible to the frequency specifi-cations using the least square optimization cations using the least square optimization method.method.

Page 9: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 9

IIR Filters SynthesisIIR Filters Synthesis

Bilinear transform :Bilinear transform : One to one map of analog frquencies to digital One to one map of analog frquencies to digital

frequencies.frequencies. Based on the approximation of the continuous Based on the approximation of the continuous

integral operator by the trapezoïdal method.integral operator by the trapezoïdal method.

t

duuxty )()(

t

duuxty )()(

n

k

kken

xxTy

21

n

k

kken

xxTy

21

)(1

)( sXs

sY )(1

)( sXs

sY )(1

1

2)(

1

1

zXz

zTzY e

)(1

1

2)(

1

1

zXz

zTzY e

LaplaceLaplace

transformtransform

Z Z

transformtransform

1

1

1

12

z

z

Ts

e1

1

1

12

z

z

Ts

e

Equating integral operators,Equating integral operators,

we get the bilinear transform.we get the bilinear transform.

Page 10: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 10

IIR Filters SynthesisIIR Filters Synthesis

Bilinear transformBilinear transform Maps the stability region of the Laplace plane inside Maps the stability region of the Laplace plane inside

the unit circle of the complex planethe unit circle of the complex plane

eTjezejs z

z

Ts

1

1

1

12

eTjezejs z

z

Ts

1

1

1

12

2tan

2 e

e

T

T

2tan

2 e

e

T

T

j

eTje

Page 11: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 11

IIR Filters SynthesisIIR Filters Synthesis Bilinear transform :Bilinear transform :

j

eTje

2tan

2 e

e

T

T

2tan

2 e

e

T

T

eT

The one to one mapping The one to one mapping achieved by this transform achieved by this transform prevents aliasing.prevents aliasing.

Page 12: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 12

IIR Filters SynthesisIIR Filters Synthesis

Characteristics frequencies (Characteristics frequencies (FFpp, F, Faa) of the ) of the target specifications have to be warped.target specifications have to be warped.

This warped specifications is used to compute This warped specifications is used to compute an analog prototype using approximation an analog prototype using approximation functions :functions :

ButterworthButterworth Chebyshev IChebyshev I Chebyshev IIChebyshev II EllipticElliptic

Then the analog prototype is tranformed into a Then the analog prototype is tranformed into a digital filter that matches target frequency digital filter that matches target frequency specification thanks to Bilinear Transform specification thanks to Bilinear Transform (BT) (this cancels the warping introduce at the (BT) (this cancels the warping introduce at the first step).first step).

Page 13: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 13

IIR CharacteristicsIIR Characteristics Butterworth filters :Butterworth filters :

N

pff

fH2

2

1

1)(

N

pff

fH2

2

1

1)(

• Defined by its order Defined by its order NN and its cut-off frequency and its cut-off frequency ffpp..

• Monotonic magnitude transfer function. Monotonic magnitude transfer function.

Matlab commands:Matlab commands:

• buttord buttord : estimate the needed order: estimate the needed order

• butterbutter : compute the digital filter from : compute the digital filter from

analog prototype using warping and BT,analog prototype using warping and BT,

given the order and cut-off frequency.given the order and cut-off frequency.

Sample Matlab code

Page 14: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 14

IIR CharacteristicsIIR Characteristics Chebyshev I filters :Chebyshev I filters :

pN f

fT

fH22

2

1

1)(

pN f

fT

fH22

2

1

1)(

• Defined by its order Defined by its order NN, its passband corner, its passband corner

frequency frequency ffpp and its passband ripple and its passband ripple ..

• Ripple in passband and monotonic in stopbandRipple in passband and monotonic in stopband..

Matlab commands:Matlab commands:

• cheb1ord cheb1ord : estimate the needed order: estimate the needed order

• cheby1cheby1 : compute the digital filter from : compute the digital filter from

analog prototype using warping and BT,analog prototype using warping and BT,

Given the order and passband ripple andGiven the order and passband ripple and

Corner frequency.Corner frequency.

Sample Matlab code

TTNN( ) is a Chebyshev polynomial of order ( ) is a Chebyshev polynomial of order NN

Page 15: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 15

IIR CharacteristicsIIR Characteristics Chebyshev II filters :Chebyshev II filters :

ff

T

fHs

N22

2

1

11)(

ff

T

fHs

N22

2

1

11)(

• Defined by its order Defined by its order NN, its stopband edge, its stopband edge

frequency frequency ffss and its stopband attenuation and its stopband attenuation ..

• Monotonic in passband and ripple in stopband.Monotonic in passband and ripple in stopband.

Matlab commands:Matlab commands:

• cheb2ord cheb2ord : estimate the needed order: estimate the needed order

• cheby2cheby2 : compute the digital filter from : compute the digital filter from

analog prototype using warping and BT,analog prototype using warping and BT,

Given the order and stopband attenuationGiven the order and stopband attenuation

and edge frequency.and edge frequency.

Sample Matlab code

TTNN( ) is a Chebyshev polynomial of order ( ) is a Chebyshev polynomial of order NN

Page 16: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 16

IIR CharacteristicsIIR Characteristics Elliptic filters :Elliptic filters :

sp

Nff

fR

fH22

2

1

1)(

sp

Nff

fR

fH22

2

1

1)(

RRNN( ) is a Chebyshev rationnal polynomial of order ( ) is a Chebyshev rationnal polynomial of order NN

• Defined by its order Defined by its order NN, its passband and stopband, its passband and stopband

edge frequencies, edge frequencies, ffpp and and f fss, , its passband ripple andits passband ripple and

its stopband attenuation its stopband attenuation ..

• Ripple in passband and in stopband.Ripple in passband and in stopband.

Matlab commands:Matlab commands:

• ellipord ellipord : estimate the needed order: estimate the needed order

• ellipellip : compute the digital filter from : compute the digital filter from

analog prototype using warping and BT,analog prototype using warping and BT,

given the order, passband ripple, stopbandgiven the order, passband ripple, stopband

attenuation and center frequency.attenuation and center frequency.

Sample Matlab code

Page 17: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 17

IIR CharacteristicsIIR Characteristics Group delayGroup delay

Characterize the phase distorsion (waveform Characterize the phase distorsion (waveform distorsion) introduced by the filter.distorsion) introduced by the filter.

Page 18: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 18

IIR structureIIR structure Derived from difference equationDerived from difference equation

y b x a yn i n ii

Q

k n kk

P

0 1

zz-1-1

zz-1-1

zz-1-1

zz-1-1

zz-1-1

zz-1-1

zz-1-1 zz-1-1

bb11

bb00

bb22

bb33

bbQ-1Q-1

-a-a11

-a-a22

-a-a33

-a-aQ-1Q-1

xxnn yynn

• non canonical formnon canonical form

)(

1)()(

zAzBzH

)(

1)()(

zAzBzH

Direct form IDirect form I

Page 19: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 19

IIR structureIIR structure

zz-1-1

zz-1-1

zz-1-1

zz-1-1

bb11

bb00

bb22

bb33

bbQ-1Q-1

-a-a11

-a-a22

-a-a33

-a-aQ-1Q-1

yynn

Direct form IIDirect form II

• Canonical formCanonical form

)()(

1)( zB

zAzH )(

)(

1)( zB

zAzH

xxnn

Page 20: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 20

IIR structureIIR structure

Transposed direct form IITransposed direct form II

bb22

bb33

bbQ-1Q-1

-a-a11

-a-a22

-a-a33

-a-aQ-1Q-1

xxnn

• Canonical formCanonical form

)()(

1)( zB

zAzH )(

)(

1)( zB

zAzH

zz-1-1

zz-1-1

bb11

zz-1-1

bb22

zz-1-1

yynn

Page 21: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 21

IIR – Coefficients quantizationIIR – Coefficients quantization Finite precision of DSP involves coefficients Finite precision of DSP involves coefficients

quantization:quantization:

Let consider the denominator of the transfer function with ,Let consider the denominator of the transfer function with , the the kkth th

quantized coefficients and quantized coefficients and aakk the quantification error. Quantized the quantification error. Quantized denominator is then:denominator is then:

The resulting quantified poles will disrupt the transfer function.The resulting quantified poles will disrupt the transfer function.

The higher order the polynomial is, the greater will be pertubation on its roots The higher order the polynomial is, the greater will be pertubation on its roots due to quantization.due to quantization.

Following slides illustrate this fact: Following slides illustrate this fact:

• Next slide shows the transfer function of a 6Next slide shows the transfer function of a 6thth order direct form filter for order direct form filter for different quantification.different quantification.

• Following one shows the transfer function obtained for the same filter and Following one shows the transfer function obtained for the same filter and same quantificaiton, but with a cascade structure of second order section, same quantificaiton, but with a cascade structure of second order section, this this last structure is much less sensitive to quantization than the previous onelast structure is much less sensitive to quantization than the previous one..

kkk aaa

1

1

11

1

11Q

ll

Q

k

kk zpzazA

1

1

11

1

11Q

ll

Q

k

kk zpzazA

Page 22: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 22

Direct structureDirect structure

Page 23: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 23

Cascade structure of second order sectionCascade structure of second order section

Page 24: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 24

IIR structureIIR structure This sensitivity to coefficients quantization This sensitivity to coefficients quantization

leads to second order cascade or parallel form.leads to second order cascade or parallel form. Second order section is chosen to get the least Second order section is chosen to get the least

order together with complex conjugated roots.order together with complex conjugated roots.

44thth order example: order example: Parallel form Parallel form

22

11

110

1

zaza

zbb

22

11

110

1

zaza

zbbxxnn yynn

Cascade form Cascade form

Partial fraction expansionPartial fraction expansion

1

02

21

1

110

0 1)(

)( N

i ii

ii

zaza

zbbc

zA

zB

1

02

21

1

110

0 1)(

)( N

i ii

ii

zaza

zbbc

zA

zB

c0

22

11

22

110

1

zaza

zbzbb2

21

1

22

110

1

zaza

zbzbbxxnn yynn

Spectral factorisationSpectral factorisation

1

02

21

1

22

11

0 1

1

)(

)( N

i ii

ii

zaza

zbzbb

zA

zB

1

02

21

1

22

11

0 1

1

)(

)( N

i ii

ii

zaza

zbzbb

zA

zB

Page 25: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 25

IIR – Cascade structureIIR – Cascade structure Cascade structure involves addressing two Cascade structure involves addressing two

problems :problems : PairingPairing: which zeros with which poles to form a : which zeros with which poles to form a

second order rational transfer function.second order rational transfer function.

The goal will be minimize the overshoot caused The goal will be minimize the overshoot caused by the poles.by the poles.

OrderingOrdering: which second order section will be : which second order section will be ahead and which one will be the last.ahead and which one will be the last.

To answer to this question we will have consider To answer to this question we will have consider quantification noise and the way to minimize it. quantification noise and the way to minimize it.

Page 26: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 26

IIR – case study 1IIR – case study 1 Consider the following specification:Consider the following specification:

Using inverse Chebyshev approximation, Using inverse Chebyshev approximation, we get a 6we get a 6th th order filter order filter ((matlab commandsmatlab commands))

[N,Wn]=CHEB2ORD(1800/8000,4000/8000,0.01,50);[N,Wn]=CHEB2ORD(1800/8000,4000/8000,0.01,50);

[B,A]=CHEBY2(N,50,Wn)[B,A]=CHEBY2(N,50,Wn)

Page 27: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 27

IIR – case study 2IIR – case study 2Actual transfer function is obtained Actual transfer function is obtained with: with: freqz(B,A)freqz(B,A)

Plot of poles and zeros with: Plot of poles and zeros with: zplane(A,B)zplane(A,B)

PairingPairing: complex conjugate poles closest to the unit circle (responsible for the greatest : complex conjugate poles closest to the unit circle (responsible for the greatest overshoot) are paired with complex conjugate zeros closest in frequency (angle on unit overshoot) are paired with complex conjugate zeros closest in frequency (angle on unit circle). Then the process iterate with the next complex conjugate closest to the unit circle.circle). Then the process iterate with the next complex conjugate closest to the unit circle.

This done with the following This done with the following routine

112233

Page 28: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 28

IIR – data quantizationIIR – data quantization

zz-1-1

zz-1-1

bb11

bb00

bb22

-a-a11

-a-a22

yynnxxnn

Direct form II Direct form II one noise sourceone noise source

bb22

-a-a11

-a-a22

xxnn

bb11

zz-1-1

bb22

zz-1-1

yynn

Transposed direct form II Transposed direct form II two noise sourcestwo noise sources

For DSP, quantification noise appear when we truncate the accumulator to store its For DSP, quantification noise appear when we truncate the accumulator to store its high part. (high part. (een n equivalent noise source)equivalent noise source)

eenn eenn

2/

2/

2_

2

)(

)(1 e

e

F

Fe

eoute dffA

fB

F

2/

2/

2_

2

)(

)(1 e

e

F

Fe

eoute dffA

fB

F

Output noise power is reduced by the Output noise power is reduced by the ENBENB of the complete filter of the complete filter

Output noise power is only reduced by Output noise power is only reduced by the the ENBENB of the denominator of the denominator

2/

2/

2_

2

)(

11 e

e

F

Fe

eoute dffAF

2/

2/

2_

2

)(

11 e

e

F

Fe

eoute dffAF

Page 29: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 29

IIR – scaling factorIIR – scaling factor Direct form IIDirect form II

zz-1-1

zz-1-1

bb11

bb00

bb22

-a-a11

-a-a22

yynnxxnn

wwnnTo prevent overflow when storing at the To prevent overflow when storing at the node node wwnn,, we need a scale factor to have a 0 we need a scale factor to have a 0 dB gain from input to this node.dB gain from input to this node.

This scale factor, This scale factor, , is commonly , is commonly computed depending on the nature of computed depending on the nature of signal that will be process:signal that will be process:

Narrow band signalNarrow band signal, in this case we use , in this case we use LL norm and we get: norm and we get:

Wide band signalWide band signal, we use , we use LL22 norm and we norm and we get:get:

Futhermore we have: Futhermore we have:

)(/1

11 fA

)(/1

11 fA

2

2 )(/1

1

fA

2

2 )(/1

1

fA

12 12

zz-1-1

zz-1-1

bb1 1

bb0 0

bb2 2

-a-a11

-a-a22

yynnxxnn

wwnn

Page 30: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 30

IIR – orderingIIR – ordering

Depend on:Depend on: Criteria for scale factor computation, Criteria for scale factor computation, LLor or LL22

norm.norm. Which norm of the quantization noise we want Which norm of the quantization noise we want

to minimize to minimize LLmax value) or max value) or LL22 norm norm (power).(power).

Following rules could apply:Following rules could apply:• LL for scale factor and for scale factor and LL22 for noise ascending order of overshoot. for noise ascending order of overshoot.

• LL22 for scale factor and for scale factor and LL for noise descending order of overshoot. for noise descending order of overshoot.

If the same norm is used no prefered order.If the same norm is used no prefered order.

Page 31: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 31

Scale factor & orderingScale factor & ordering 66thth filter example ( filter example (look at this look at this routineroutine))

210

03

b

210

03

b

fA0

0 /1

1

fA0

0 /1

1

fAfAfB 1000

1 /

1

fAfAfB 1000

1 /

1

fAfAfAfBfB 2101010

2 /

1

fAfAfAfBfB 2101010

2 /

1

: quantization noise source

Page 32: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 32

IIR – coefficients codingIIR – coefficients coding We have to choose the right We have to choose the right Qn Qn coding for the coding for the

coefficients.coefficients. For second order section, For second order section, A(z)A(z) or or B(z)B(z) can be written, if can be written, if

we let their roots to be we let their roots to be

Denominator: for stability we need |Denominator: for stability we need |rr|<1, so coefficients |<1, so coefficients belong to [-2,2].belong to [-2,2].

Numerator, by using analog approximation function as Numerator, by using analog approximation function as prototype we get zeros on the unit circle so |prototype we get zeros on the unit circle so |rr|=1 and |=1 and coefficients also belong to [-2,2].coefficients also belong to [-2,2].

The right coding is then The right coding is then QQ14 14 for 16 bits wordfor 16 bits word.. Look at this Look at this routineroutine which does the work fir the 6 which does the work fir the 6thth order order

filter.filter.

221cos21 zrzr

jr e

Page 33: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 33

IIR – noise powerIIR – noise power The noise power at the output of that 6The noise power at the output of that 6thth

order filter:order filter:

eF

eeo dffHfHfH

F 0

2

2

2

1

2

023

22

21

22 )()()(1 eF

eeo dffHfHfH

F 0

2

2

2

1

2

023

22

21

22 )()()(1

eF

ee dffHfH

F 0

2

2

2

123

22

2 )()(1 eF

ee dffHfH

F 0

2

2

2

123

22

2 )()(1

eF

ee dffH

F 0

2

223

2 )(1 eF

ee dffH

F 0

2

223

2 )(1

First stage noise powerFirst stage noise power

Second stage noise powerSecond stage noise power

Third stage noise powerThird stage noise power

Input scale factor attenuates only the input signal not the quantization noise:Input scale factor attenuates only the input signal not the quantization noise:

• the lower the scale factor is the worst the signal to noise ratio will be.the lower the scale factor is the worst the signal to noise ratio will be.

Page 34: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 34

IIR - computationIIR - computation Evaluation of an order 2 direct form II is as followsEvaluation of an order 2 direct form II is as follows::

ACC=ACC=x(x(nn))

ACC=ACC ACC=ACC - a- a11 ww(n-1)(n-1)

ACC=ACC ACC=ACC - a- a22 ww(n-2)(n-2)

ACC<<2ACC<<2

w(w(nn)=)=ACCHACCH

ACC=ACC=w(w(nn)) bb00

ACC=ACC ACC=ACC + b+ b22 ww(n-2)(n-2)

ACC=ACC ACC=ACC + b+ b11 ww(n-1)(n-1)

ACC<<2ACC<<2

y(y(nn)=ACCH)=ACCHw(w(nn-2)=w(-2)=w(nn-1)-1)

w(w(nn-1)=w(-1)=w(nn))

Q29=Q15 Q29=Q15 Q14 Q14

Q29=Q29 - (Q15 Q29=Q29 - (Q15 Q14) Q14)

Q29=Q29 - (Q15 Q29=Q29 - (Q15 Q14) Q14)

Q31=Q29 Q31=Q29 2 222

Q15Q15

Q29=Q15 Q29=Q15 Q14 Q14

Q29=Q29 + (Q15 Q29=Q29 + (Q15 Q14) Q14)

Q29=Q29 + (Q15 Q29=Q29 + (Q15 Q14) Q14)

Q31=Q29 Q31=Q29 2 222

Q15Q15

Page 35: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 35

IIR – program on C54IIR – program on C54 Following Following programprogram works on a sample by works on a sample by

sample basis and is C callable.sample basis and is C callable.Memory managmentMemory managment

sect1sect1

aa1111

aa1212

bb1212

bb1111

bb1010

aa2121

aa2222

bb2222

bb2121

bb2020

*AR2*AR2 ww11(n-1)(n-1)memfiltmemfilt

ww11(n-2)(n-2)

ww22(n-1)(n-1)

ww22(n-2)(n-2)

*AR3*AR3

Page 36: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 36

Follow on Activities for thr C5416 DSKFollow on Activities for thr C5416 DSK

Laboratory 6 for the C5416 DSKLaboratory 6 for the C5416 DSK Implemements high pass and low pass Implemements high pass and low pass

Butterworth filters from 1st order to 6th order.Butterworth filters from 1st order to 6th order.

Laboratory 7 for the C5416 DSKLaboratory 7 for the C5416 DSK Implemements band stop and notch filters Implemements band stop and notch filters

using poles / zeroes and Bilinear Transform using poles / zeroes and Bilinear Transform (BLT).(BLT).

Laboratory 8 for the C5416 DSKLaboratory 8 for the C5416 DSK Looks at sharpness of cut off and stability of Looks at sharpness of cut off and stability of

IIR filters designed by placing poles and zeroes IIR filters designed by placing poles and zeroes and Bilinear Transform (BLT).and Bilinear Transform (BLT).

Page 37: Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 15 Infinite Impulse Response (IIR) Filter Implementation.

Copyright © 2003 Texas Instruments. All rights reserved.

ESIEE, Slide 37

Follow on Activities for thr C5510 DSKFollow on Activities for thr C5510 DSK

Application 3 for the C5510 DSKApplication 3 for the C5510 DSK Uses IIR filter for reverberationUses IIR filter for reverberation

Simulates single and multiple reflections from Simulates single and multiple reflections from the walls of a room. Introduces the the walls of a room. Introduces the configuration used for an Infinite Impulse configuration used for an Infinite Impulse Response (IIR) filter.Response (IIR) filter.

The majority of the code is written in C, except The majority of the code is written in C, except where the C code would be too slow and where the C code would be too slow and assembly code is requiredassembly code is required