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.

macro during instance declaration or by calling the<br />

GDFLIB_FilterIIR1Init_F32 function.<br />

CAUTION<br />

Because of fixed point implementation, <strong>and</strong> to avoid overflow<br />

during the calculation of the GDFLIB_FilterIIR1_F32 function,<br />

filter coefficients must be divided by eight. Function output is<br />

internally multiplied by eight to correct the coefficient scaling.<br />

4.8.5 Re-entrancy<br />

The function is re-entrant.<br />

4.8.6 Code Example<br />

#include "gdflib.h"<br />

tFrac32 f32In;<br />

tFrac32 f32Out;<br />

GDFLIB_FILTER_IIR1_T_F32 f32trMyIIR1 = GDFLIB_FILTER_IIR1_DEFAULT_F32;<br />

void main(void)<br />

{<br />

// input value = 0.25<br />

f32In = FRAC32 (0.25);<br />

}<br />

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

f32trMyIIR1.trFiltCoeff.f32B0 = FRAC32 (0.030468747091254/8);<br />

f32trMyIIR1.trFiltCoeff.f32B1 = FRAC32 (0.030468747091254/8);<br />

f32trMyIIR1.trFiltCoeff.f32A1 = FRAC32 (-0.939062505817492/8);<br />

// output should be 0x00F99998 ~ FRAC32(0.007617)<br />

GDFLIB_FilterIIR1Init_F32 (&f32trMyIIR1);<br />

f32Out = GDFLIB_FilterIIR1_F32 (f32In, &f32trMyIIR1);<br />

// output should be 0x00F99998 ~ FRAC32(0.007617)<br />

GDFLIB_FilterIIR1Init (&f32trMyIIR1, Define F32);<br />

f32Out = GDFLIB_FilterIIR1 (f32In, &f32trMyIIR1, Define F32);<br />

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

// Available only if 32-bit fractional implementation selected<br />

// as default<br />

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

// output should be 0x00F99998 ~ FRAC32(0.007617)<br />

GDFLIB_FilterIIR1Init (&f32trMyIIR1);<br />

f32Out = GDFLIB_FilterIIR1 (f32In, &f32trMyIIR1);<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. 171

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

Saved successfully!

Ooh no, something went wrong!