2IIR Filters Rational Z transfer function Linear difference equation General considerations about Linear Time Invariant systems have been reviewed in the previous chapter.The IIR filter is describe in frequency by its Z tranfer function evaluated on the unit circle and in time by its difference equation.
3IIR Filters – Poles and Zeros Roots of the numeratorRoots of the denominatorri are the roots of the z polynomial with bi coefficients. H(z) is null whenz is equal to one of the values. They are called the zeroes of the filterand often noted by zi .ri are the roots of the z polynomial with ai coefficients. H(z) tends to infinitywhen z is close to one of these values. They are called the poles of the filtersand often noted by pi .
4Z Transfer Function Define frequency behaviour of the filter Consider a first order z rational filter:magnitudephaseH(z) can be evaluated for eachvalue wn from 0 to 1 with 1 corres-ponding to sampling frequency
5Z Transfer FunctionWe obtain the transfer function by evaluation of the z transform on the unit circleWe can see that it is a minimum phase filter (the phase comes back at 0 at Fe/2) because the zero of the filter is inside the unit circle.
6Z Transfer FunctionIf we change the zero z1 to 1/ z1 we get the same magnitude transfer function (up to a scale factor) …But a maximum phase filter (the phase goes to -p at Fe/2) because now, the zero lies outside the unit circle.
7IIR Filter SynthesisStarting from frequency specifications (here low pass filter):Fpass : passband end frequency,Fstop : stopband start frequency,Apass : maximum passband ripple,Astop : minimum stopband attenuation.
8IIR Filters SynthesisAnalog prototype with analog to digital transformation (bilinear transform) :Digital to analog frequency specification transformation using prewarpingAnalog filter prototypeAnalog transfer function to digital transfer function transformation using bilinear transform.Direct digital method : Yule WalkerTry 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.
9IIR Filters Synthesis Bilinear transform : One to one map of analog frquencies to digital frequencies.Based on the approximation of the continuous integral operator by the trapezoïdal method.ZtransformLaplacetransformEquating integral operators,we get the bilinear transform.
10IIR Filters Synthesis Bilinear transform Maps the stability region of the Laplace plane inside the unit circle of the complex plane
11IIR Filters Synthesis Bilinear transform : The one to one mapping achieved by this transform prevents aliasing.
12IIR Filters SynthesisCharacteristics frequencies (Fp, Fa) of the target specifications have to be warped.This warped specifications is used to compute an analog prototype using approximation functions :ButterworthChebyshev IChebyshev IIEllipticThen 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).
13IIR Characteristics Butterworth filters : Defined by its order N and its cut-off frequency fp.Monotonic magnitude transfer function.Matlab commands:buttord : estimate the needed orderbutter : compute the digital filter fromanalog prototype using warping and BT,given the order and cut-off frequency.Sample Matlab code
14IIR Characteristics Chebyshev I filters : Defined by its order N, its passband cornerfrequency fp and its passband ripple e.Ripple in passband and monotonic in stopband.Matlab commands:cheb1ord : estimate the needed ordercheby1 : compute the digital filter fromanalog prototype using warping and BT,Given the order and passband ripple andCorner frequency.Sample Matlab codeTN( ) is a Chebyshev polynomial of order N
15IIR Characteristics Chebyshev II filters : Defined by its order N, its stopband edgefrequency fs and its stopband attenuation e.Monotonic in passband and ripple in stopband.Matlab commands:cheb2ord : estimate the needed ordercheby2 : compute the digital filter fromanalog prototype using warping and BT,Given the order and stopband attenuationand edge frequency.Sample Matlab codeTN( ) is a Chebyshev polynomial of order N
16IIR Characteristics Elliptic filters : Defined by its order N, its passband and stopbandedge frequencies, fp and fs, its passband ripple andits stopband attenuation e.Ripple in passband and in stopband.Matlab commands:ellipord : estimate the needed orderellip : compute the digital filter fromanalog prototype using warping and BT,given the order, passband ripple, stopbandattenuation and center frequency.Sample Matlab codeRN( ) is a Chebyshev rationnal polynomial of order N
17IIR Characteristics Group delay Characterize the phase distorsion (waveform distorsion) introduced by the filter.
18IIR structure Derived from difference equation Direct form I xn yn b0 z-1z-1b1-a1z-1z-1b2-a2non canonical formz-1z-1b3-a3z-1z-1bQ-1-aQ-1
19IIR structure Direct form II xn yn b0 z-1 -a1 b1 z-1 -a2 b2 Canonical formz-1-a3b3z-1-aQ-1bQ-1
20IIR structure Transposed direct form II xn yn b2 z-1 b1 -a1 Canonical formz-1b2-a2z-1b3-a3z-1bQ-1-aQ-1
21IIR – Coefficients quantization Finite precision of DSP involves coefficients quantization:Let consider the denominator of the transfer function with , the kth quantized coefficients and Dak 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 6th 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.
22Direct structureThis graph represents the shape of the magnitude transfer function for different quantization of the filter coefficients.The number of quantization bits varies between 3 and 14.
24IIR structureThis 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.4th order example: Parallel formCascade formc0xnynComplex conjugated roots allow to have characterics frequencies not only at 0 or Fe/2, but at any frequencies between this two bounds.xnynSpectral factorisationPartial fraction expansion
25IIR – Cascade structure Cascade structure involves addressing two problems :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.To answer to this question we will have consider quantification noise and the way to minimize it.
26IIR – case study 1 Consider the following specification: Using inverse Chebyshev approximation, we get a 6th order filter (matlab commands)[N,Wn]=CHEB2ORD(1800/8000,4000/8000,0.01,50);[B,A]=CHEBY2(N,50,Wn)
27IIR – case study 2Actual transfer function is obtained with: freqz(B,A)Plot of poles and zeros with: zplane(A,B)321Pairing: 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
28IIR – data quantization For DSP, quantification noise appear when we truncate the accumulator to store its high part. (en equivalent noise source)Direct form II one noise sourceTransposed direct form II two noise sourcesenenb0b2xnynxnynz-1z-1-a1b1b1-a1z-1-a2b2z-1b2-a2ENB: equivalent noise bandwidthOutput noise power is reduced by the ENB of the complete filterOutput noise power is only reduced by the ENB of the denominator
29IIR – scaling factor wn xn yn wn xn yn Direct form II To prevent overflow when storing at the node wn, we need a scale factor to have a 0 dB gain from input to this node.This scale factor, a, 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 L2 norm and we get:Futhermore we have:wnb0xnynz-1-a1b1z-1-a2b2awnb0 /a1/axnynz-1-a1b1 /az-1-a2b2 /a
30IIR – ordering Depend on: Following rules could apply: Criteria for scale factor computation, L or L2 norm.Which norm of the quantization noise we want to minimize L (max value) or L2 norm (power).Following rules could apply:L for scale factor and L2 for noise ascending order of overshoot.L2 for scale factor and L for noise descending order of overshoot.If the same norm is used no prefered order.
31Scale factor & ordering 6th filter example (look at this routine): quantization noise source
32IIR – coefficients coding We have to choose the right Qn coding for the coefficients.For second order section, A(z) or B(z) can be written, ifwe let their roots to beDenominator: 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].The right coding is then Q14 for 16 bits word.Look at this routine which does the work fir the 6th order filter.The right Qn coding is the one which preserve the maximum precision on the coefficients.
33IIR – noise powerThe noise power at the output of that 6th order filter:First stage noise powerSecond stage noise powerThird stage noise powerInput 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.
34IIR - computationEvaluation of an order 2 direct form II is as follows:ACC=x(n) a0ACC=ACC - a1 w(n-1)ACC=ACC - a2 w(n-2)ACC<<2w(n)=ACCHACC=w(n) b0ACC=ACC + b2 w(n-2)ACC=ACC + b1 w(n-1)y(n)=ACCHQ29=Q15 Q14Q29=Q29 - (Q15 Q14)Q31=Q29 22Q15Q29=Q29 + (Q15 Q14)The computation of an IIR cell is much less regular than for an FIRw(n-2)=w(n-1)w(n-1)=w(n)
35IIR – program on C54Following program works on a sample by sample basis and is C callable.Memory managmentw1(n-1)*AR3a*AR2memfiltsect1w1(n-2)a11w2(n-1)a12w2(n-2)b12b11b10a21a22b22b21b20
36Follow on Activities for thr C5416 DSK Laboratory 6 for the C5416 DSKImplemements high pass and low pass Butterworth filters from 1st order to 6th order.Laboratory 7 for the C5416 DSKImplemements band stop and notch filters using poles / zeroes and Bilinear Transform (BLT).Laboratory 8 for the C5416 DSKLooks at sharpness of cut off and stability of IIR filters designed by placing poles and zeroes and Bilinear Transform (BLT).
37Follow on Activities for thr C5510 DSK Application 3 for the C5510 DSKUses IIR filter for reverberationSimulates 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