Download presentation

Presentation is loading. Please wait.

Published byCaleb Richards Modified over 3 years ago

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

2
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 2 IIR Filters Rational Z transfer function Rational Z transfer function Linear difference equation Linear difference equation

3
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 3 IIR Filters – Poles and Zeros Roots of the numerator Roots of the numerator Roots of the denominator Roots of the denominator r i are the roots of the z polynomial with b i coefficients. H(z) is null when z is equal to one of the values. They are called the zeroes of the filter and often noted by z i. r i are the roots of the z polynomial with a i coefficients. H(z) tends to infinity when z is close to one of these values. They are called the poles of the filters and often noted by p i.

4
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 4 Z Transfer Function Define frequency behaviour of the filter Define frequency behaviour of the filter Consider a first order z rational filter: Consider a first order z rational filter: H(z) can be evaluated for each value n from 0 to 1 with 1 corres- ponding to sampling frequency magnitudephase

5
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 5 Z Transfer Function We obtain the transfer function by evaluation of the z transform on the unit circle We obtain the transfer function by evaluation of the z transform on the unit circle We can see that it is a minimum phase filter (the phase comes back at 0 at F e /2) because the zero of the filter is inside the unit circle. We can see that it is a minimum phase filter (the phase comes back at 0 at F e /2) because the zero of the filter is inside the unit circle.

6
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 6 Z Transfer Function If we change the zero z 1 to 1/ z 1 we get the same magnitude transfer function (up to a scale factor) … If we change the zero z 1 to 1/ z 1 we get the same magnitude transfer function (up to a scale factor) … But a maximum phase filter (the phase goes to - at F e /2) because now, the zero lies outside the unit circle. But a maximum phase filter (the phase goes to - at F e /2) because now, the zero lies outside the unit circle.

7
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 7 IIR Filter Synthesis Starting from frequency specifications (here low pass filter): Starting from frequency specifications (here low pass filter): F pass : passband end frequency, F pass : passband end frequency, F stop : stopband start frequency, F stop : stopband start frequency, A pass : maximum passband ripple, A pass : maximum passband ripple, A stop : minimum stopband attenuation. A stop : minimum stopband attenuation.

8
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 8 IIR Filters Synthesis Analog prototype with analog to digital transformation (bilinear transform) : Analog prototype with analog to digital transformation (bilinear transform) : Digital to analog frequency specification transformation using prewarping Digital to analog frequency specification transformation using prewarping Analog filter prototype Analog filter prototype Analog transfer function to digital transfer function transformation using bilinear transform. Analog transfer function to digital transfer function transformation using bilinear transform. Direct digital method : Yule Walker Direct digital method : Yule Walker Try to find the recursive filter of order N which is as close as possible to the frequency specifi- cations using the least square optimization method. Try to find the recursive filter of order N which is as close as possible to the frequency specifi- cations using the least square optimization method.

9
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 9 IIR Filters Synthesis Bilinear transform : Bilinear transform : One to one map of analog frquencies to digital frequencies. One to one map of analog frquencies to digital frequencies. Based on the approximation of the continuous integral operator by the trapezoïdal method. Based on the approximation of the continuous integral operator by the trapezoïdal method. Laplacetransform Ztransform Equating integral operators, we get the bilinear transform.

10
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 10 IIR Filters Synthesis Bilinear transform Bilinear transform Maps the stability region of the Laplace plane inside the unit circle of the complex plane Maps the stability region of the Laplace plane inside the unit circle of the complex plane

11
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 11 IIR Filters Synthesis Bilinear transform : Bilinear transform : The one to one mapping achieved by this transform prevents aliasing.

12
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 12 IIR Filters Synthesis Characteristics frequencies (F p, F a ) of the target specifications have to be warped. Characteristics frequencies (F p, F a ) of the target specifications have to be warped. This warped specifications is used to compute an analog prototype using approximation functions : This warped specifications is used to compute an analog prototype using approximation functions : Butterworth Butterworth Chebyshev I Chebyshev I Chebyshev II Chebyshev II Elliptic Elliptic Then the analog prototype is tranformed into a digital filter that matches target frequency specification thanks to Bilinear Transform (BT) (this cancels the warping introduce at the first step). Then the analog prototype is tranformed into a digital filter that matches target frequency specification thanks to Bilinear Transform (BT) (this cancels the warping introduce at the first step).

13
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 13 IIR Characteristics Butterworth filters : Butterworth filters : Defined by its order N and its cut-off frequency f p. Defined by its order N and its cut-off frequency f p. Monotonic magnitude transfer function. Monotonic magnitude transfer function. Matlab commands: buttord : estimate the needed order buttord : estimate the needed order butter : compute the digital filter from butter : compute the digital filter from analog prototype using warping and BT, given the order and cut-off frequency. Sample Matlab code Sample Matlab code

14
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 14 IIR Characteristics Chebyshev I filters : Chebyshev I filters : Defined by its order N, its passband corner Defined by its order N, its passband corner frequency f p and its passband ripple. Ripple in passband and monotonic in stopband. Ripple in passband and monotonic in stopband. Matlab commands: cheb1ord : estimate the needed order cheb1ord : estimate the needed order cheby1 : compute the digital filter from cheby1 : compute the digital filter from analog prototype using warping and BT, Given the order and passband ripple and Corner frequency. Sample Matlab code Sample Matlab code T N ( ) is a Chebyshev polynomial of order N

15
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 15 IIR Characteristics Chebyshev II filters : Chebyshev II filters : Defined by its order N, its stopband edge Defined by its order N, its stopband edge frequency f s and its stopband attenuation. Monotonic in passband and ripple in stopband. Monotonic in passband and ripple in stopband. Matlab commands: cheb2ord : estimate the needed order cheb2ord : estimate the needed order cheby2 : compute the digital filter from cheby2 : compute the digital filter from analog prototype using warping and BT, Given the order and stopband attenuation and edge frequency. Sample Matlab code Sample Matlab code T N ( ) is a Chebyshev polynomial of order N

16
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 16 IIR Characteristics Elliptic filters : Elliptic filters : R N ( ) is a Chebyshev rationnal polynomial of order N Defined by its order N, its passband and stopband Defined by its order N, its passband and stopband edge frequencies, f p and f s, its passband ripple and its stopband attenuation. Ripple in passband and in stopband. Ripple in passband and in stopband. Matlab commands: ellipord : estimate the needed order ellipord : estimate the needed order ellip : compute the digital filter from ellip : compute the digital filter from analog prototype using warping and BT, given the order, passband ripple, stopband attenuation and center frequency. Sample Matlab code Sample Matlab code

17
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 17 IIR Characteristics Group delay Group delay Characterize the phase distorsion (waveform distorsion) introduced by the filter. Characterize the phase distorsion (waveform distorsion) introduced by the filter.

18
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 18 IIR structure Derived from difference equation Derived from difference equation z -1 b1b1b1b1 b0b0b0b0 b2b2b2b2 b3b3b3b3 b Q-1 -a 1 -a 2 -a 3 -a Q-1 xnxnxnxn ynynynyn non canonical form non canonical form Direct form I

19
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 19 IIR structure z -1 b1b1b1b1 b0b0b0b0 b2b2b2b2 b3b3b3b3 b Q-1 -a 1 -a 2 -a 3 -a Q-1 ynynynyn Direct form II Canonical form Canonical form xnxnxnxn

20
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 20 IIR structure Transposed direct form II b2b2b2b2 b3b3b3b3 b Q-1 -a 1 -a 2 -a 3 -a Q-1 xnxnxnxn Canonical form Canonical form z -1 b1b1b1b1 b2b2b2b2 ynynynyn

21
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 21 IIR – Coefficients quantization Finite precision of DSP involves coefficients quantization: Finite precision of DSP involves coefficients quantization: Let consider the denominator of the transfer function with, the k th quantized coefficients and a k the quantification error. Quantized denominator is then: The resulting quantified poles will disrupt the transfer function. The higher order the polynomial is, the greater will be pertubation on its roots due to quantization. Following slides illustrate this fact: Next slide shows the transfer function of a 6 th order direct form filter for different quantification. Next slide shows the transfer function of a 6 th order direct form filter for different quantification. Following one shows the transfer function obtained for the same filter and same quantificaiton, but with a cascade structure of second order section, this last structure is much less sensitive to quantization than the previous one. Following one shows the transfer function obtained for the same filter and same quantificaiton, but with a cascade structure of second order section, this last structure is much less sensitive to quantization than the previous one.

22
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 22 Direct structure

23
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 23 Cascade structure of second order section

24
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 24 IIR structure This sensitivity to coefficients quantization leads to second order cascade or parallel form. This sensitivity to coefficients quantization leads to second order cascade or parallel form. Second order section is chosen to get the least order together with complex conjugated roots. Second order section is chosen to get the least order together with complex conjugated roots. 4 th order example: Parallel form xnxnxnxn ynynynyn Cascade form Partial fraction expansion c0c0 xnxnxnxn ynynynyn Spectral factorisation

25
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 25 IIR – Cascade structure Cascade structure involves addressing two problems : Cascade structure involves addressing two problems : Pairing: which zeros with which poles to form a second order rational transfer function. Pairing: which zeros with which poles to form a second order rational transfer function. The goal will be minimize the overshoot caused by the poles. Ordering: which second order section will be ahead and which one will be the last. Ordering: which second order section will be ahead and which one will be the last. To answer to this question we will have consider quantification noise and the way to minimize it.

26
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 26 IIR – case study 1 Consider the following specification: Consider the following specification: Using inverse Chebyshev approximation, we get a 6 th order filter (matlab commands) Using inverse Chebyshev approximation, we get a 6 th order filter (matlab commands) [N,Wn]=CHEB2ORD(1800/8000,4000/8000,0.01,50);[B,A]=CHEBY2(N,50,Wn)

27
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 27 IIR – case study 2 Actual transfer function is obtained with: freqz(B,A) Plot of poles and zeros with: zplane(A,B) Pairing: 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 circle). Then the process iterate with the next complex conjugate closest to the unit circle. This done with the following routine routine 123

28
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 28 IIR – data quantization z -1 b1b1b1b1 b0b0b0b0 b2b2b2b2 -a 1 -a 2 ynynynyn xnxnxnxn Direct form II one noise source b2b2b2b2 -a 1 -a 2 xnxnxnxn b1b1b1b1 z -1 b2b2b2b2 ynynynyn Transposed direct form II two noise sources For DSP, quantification noise appear when we truncate the accumulator to store its high part. (e n equivalent noise source) enenenen enenenen Output noise power is reduced by the ENB of the complete filter Output noise power is only reduced by the ENB of the denominator

29
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 29 IIR – scaling factor Direct form II Direct form II z -1 b1b1b1b1 b0b0b0b0 b2b2b2b2 -a 1 -a 2 ynynynyn xnxnxnxn wnwnwnwn To prevent overflow when storing at the node w n, we need a scale factor to have a 0 dB gain from input to this node. This scale factor,, is commonly computed depending on the nature of signal that will be process: Narrow band signal, in this case we use L norm and we get: Wide band signal, we use L 2 norm and we get: Futhermore we have: z -1 b 1 b 1 b 0 b 0 b 2 b 2 -a 1 -a 2 ynynynyn xnxnxnxn wnwnwnwn

30
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 30 IIR – ordering Depend on: Depend on: Criteria for scale factor computation, L or L 2 norm. Criteria for scale factor computation, L or L 2 norm. Which norm of the quantization noise we want to minimize L max value) or L 2 norm (power). Which norm of the quantization noise we want to minimize L max value) or L 2 norm (power). Following rules could apply: Following rules could apply: L for scale factor and L 2 for noise ascending order of overshoot. L for scale factor and L 2 for noise ascending order of overshoot. L 2 for scale factor and L for noise descending order of overshoot. L 2 for scale factor and L for noise descending order of overshoot. If the same norm is used no prefered order.

31
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 31 Scale factor & ordering 6 th filter example ( look at this routine ) 6 th filter example ( look at this routine )routine : quantization noise source

32
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 32 IIR – coefficients coding We have to choose the right Qn coding for the coefficients. We have to choose the right Qn coding for the coefficients. For second order section, A(z) or B(z) can be written, if For second order section, A(z) or B(z) can be written, if we let their roots to be Denominator: for stability we need |r|<1, so coefficients belong to [-2,2]. Denominator: for stability we need |r|<1, so coefficients belong to [-2,2]. Numerator, by using analog approximation function as prototype we get zeros on the unit circle so |r|=1 and coefficients also belong to [-2,2]. Numerator, by using analog approximation function as prototype we get zeros on the unit circle so |r|=1 and coefficients also belong to [-2,2]. The right coding is then Q 14 for 16 bits word. The right coding is then Q 14 for 16 bits word. Look at this routine which does the work fir the 6 th order filter. Look at this routine which does the work fir the 6 th order filter.routine

33
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 33 IIR – noise power The noise power at the output of that 6 th order filter: The noise power at the output of that 6 th order filter: First stage noise power Second stage noise power Third stage noise power 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.

34
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 34 IIR - computation Evaluation of an order 2 direct form II is as follows : Evaluation of an order 2 direct form II is as follows : ACC=x(n) ACC=x(n) ACC=ACC - a 1 w(n-1) ACC=ACC - a 2 w(n-2) ACC<<2 w(n)=ACCH ACC=w(n) b 0 ACC=ACC + b 2 w(n-2) ACC=ACC + b 1 w(n-1) ACC<<2 y(n)=ACCH w(n-2)=w(n-1) w(n-1)=w(n) Q29=Q15 Q14 Q29=Q29 - (Q15 Q14) Q31=Q29 2 2 Q15 Q29=Q15 Q14 Q29=Q29 + (Q15 Q14) Q31=Q29 2 2 Q15

35
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 35 IIR – program on C54 Following program works on a sample by sample basis and is C callable. Following program works on a sample by sample basis and is C callable.program Memory managment sect1 a 11 a 12 b 12 b 11 b 10 a 21 a 22 b 22 b 21 b 20 *AR2 w 1 (n-1) memfilt w 1 (n-2) w 2 (n-1) w 2 (n-2) *AR3

36
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 36 Follow on Activities for thr C5416 DSK Laboratory 6 for the C5416 DSK Laboratory 6 for the C5416 DSK Implemements high pass and low pass Butterworth filters from 1st order to 6th order. Implemements high pass and low pass Butterworth filters from 1st order to 6th order. Laboratory 7 for the C5416 DSK Laboratory 7 for the C5416 DSK Implemements band stop and notch filters using poles / zeroes and Bilinear Transform (BLT). Implemements band stop and notch filters using poles / zeroes and Bilinear Transform (BLT). Laboratory 8 for the C5416 DSK Laboratory 8 for the C5416 DSK Looks at sharpness of cut off and stability of IIR filters designed by placing poles and zeroes and Bilinear Transform (BLT). Looks at sharpness of cut off and stability of IIR filters designed by placing poles and zeroes and Bilinear Transform (BLT).

37
Copyright © 2003 Texas Instruments. All rights reserved. ESIEE, Slide 37 Follow on Activities for thr C5510 DSK Application 3 for the C5510 DSK Application 3 for the C5510 DSK Uses IIR filter for reverberation Uses IIR filter for reverberation Simulates single and multiple reflections from the walls of a room. Introduces the configuration used for an Infinite Impulse Response (IIR) filter. Simulates single and multiple reflections from the walls of a room. Introduces the configuration used for an Infinite Impulse Response (IIR) filter. The majority of the code is written in C, except where the C code would be too slow and assembly code is required The majority of the code is written in C, except where the C code would be too slow and assembly code is required

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google