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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

eplaced by output from the previous calculation step of the<br />

Matlab precise reference model.<br />

CAUTION<br />

The filter delay line includes four delay buffers which should<br />

be reset after filter initialization. This can be done by assigning<br />

to the filter instance a<br />

GDFLIB_FILTER_IIR2_DEFAULT_FLT macro during<br />

instance declaration or by calling the<br />

GDFLIB_FilterIIR2Init_FLT function.<br />

4.18.5 Re-entrancy<br />

The function is re-entrant.<br />

4.18.6 Code Example<br />

#include "gdflib.h"<br />

tFloat fltIn;<br />

tFloat fltOut;<br />

GDFLIB_FILTER_IIR2_T_FLT flttrMyIIR2 = GDFLIB_FILTER_IIR2_DEFAULT_FLT;<br />

void main(void)<br />

{<br />

// input value = 0.25<br />

fltIn = (tFloat)(0.25);<br />

}<br />

// filter coefficients (BPF 400-625Hz, Ts=100e-6)<br />

flttrMyIIR2.trFiltCoeff.fltB0 = (tFloat)(0.066122101544579);<br />

flttrMyIIR2.trFiltCoeff.fltB1 = (tFloat)(0.0);<br />

flttrMyIIR2.trFiltCoeff.fltB2 = (tFloat)(-0.066122101544579);<br />

flttrMyIIR2.trFiltCoeff.fltA1 = (tFloat)(-1.776189018043779);<br />

flttrMyIIR2.trFiltCoeff.fltA2 = (tFloat)(0.867755796910841);<br />

// output should be 0.01651<br />

GDFLIB_FilterIIR2Init_FLT (&flttrMyIIR2);<br />

fltOut = GDFLIB_FilterIIR2_FLT (fltIn, &flttrMyIIR2);<br />

// output should be 0.01651<br />

GDFLIB_FilterIIR2Init (&flttrMyIIR2, Define FLT);<br />

fltOut = GDFLIB_FilterIIR2 (fltIn, &flttrMyIIR2, Define FLT);<br />

// ##############################################################<br />

// Available only if single precision floating point<br />

// implementation selected as default<br />

// ##############################################################<br />

// output should be 0.01651<br />

GDFLIB_FilterIIR2Init (&flttrMyIIR2);<br />

fltOut = GDFLIB_FilterIIR2 (fltIn, &flttrMyIIR2);<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 />

Chapter 4 API References<br />

Freescale Semiconductor, Inc. 195

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

Saved successfully!

Ooh no, something went wrong!