03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Function GDFLIB_FilterIIR2_F32<br />

In order to implement the second order IIR filter on a microcontroller, the discrete time<br />

domain representation of the filter, described by eq. GDFLIB_FilterIIR2_Eq2, must be<br />

trans<strong>for</strong>med into a time difference equation as follows:<br />

Equation GDFLIB_FilterIIR2_Eq3<br />

Equation GDFLIB_FilterIIR2_Eq3 represents a Direct Form I implementation of a<br />

second order IIR filter. It is well known that Direct Form I (DF-I) <strong>and</strong> Direct Form II<br />

(DF-II) implementations of an IIR filter are generally sensitive to parameter quantization<br />

if a finite precision arithmetic is considered. This, however, can be neglected when the<br />

filter transfer function is broken down into low order sections, i.e. first or second order.<br />

The main difference between DF-I <strong>and</strong> DF-II implementations of an IIR filter is in the<br />

number of delay buffers <strong>and</strong> in the number of guard bits required to h<strong>and</strong>le the potential<br />

overflow. The DF-II implementation requires less delay buffers than DF-I, hence less<br />

data memory is utilized. On the other h<strong>and</strong>, since the poles come first in the DF-II<br />

realization, the signal entering the state delay-line typically requires a larger dynamic<br />

range than the output signal y(k). There<strong>for</strong>e, overflow can occur at the delay-line input of<br />

the DF-II implementation, unlike in the DF-I implementation.<br />

Figure 4-4. Direct Form 1 second order IIR filter<br />

The coefficients of the filter depicted in Figure 4-4 can be designed to meet the<br />

requirements <strong>for</strong> the second order B<strong>and</strong> Pass (BPF) or B<strong>and</strong> Stop (BSF) filters. Filter<br />

coefficients can be calculated using various tools, <strong>for</strong> example the Matlab butter function.<br />

In order to avoid overflow during the calculation of the GDFLIB_FilterIIR2_F32<br />

function, filter coefficients must be divided by eight. The coefficient quantization error<br />

due to finite precision arithmetic can be neglected in the case of a second order filter.<br />

There<strong>for</strong>e, calculation of coefficients can be done using Matlab as follows:<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

184 Freescale Semiconductor, Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!