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.

call. The number of the filtered points is defined by assigning a value to the<br />

u16NSamples variable stored within the filter structure. This number represents the<br />

number of filtered points, as a power of 2, as follows:<br />

Equation GDFLIB_FilterMA_Eq5<br />

Note<br />

The size of the filter window (number of filtered points) must<br />

be defined prior to this function call <strong>and</strong> must be equal to or<br />

greater than 0, <strong>and</strong> equal to or smaller than 31 (0 <<br />

u16NSamples < 31).<br />

4.24.5 Re-entrancy<br />

The function is re-entrant.<br />

4.24.6 Code Example<br />

#include "gdflib.h"<br />

tFloat fltInput;<br />

tFloat fltOutput;<br />

GDFLIB_FILTER_MA_T_FLT flttrMyMA = GDFLIB_FILTER_MA_DEFAULT_FLT;<br />

void main(void)<br />

{<br />

// input value = 0.25<br />

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

}<br />

// filter window = 2^5 = 32 samples<br />

flttrMyMA.u16NSamples = 5;<br />

GDFLIB_FilterMAInit_FLT (&flttrMyMA);<br />

// output should be 0.0078125<br />

fltOutput = GDFLIB_FilterMA_FLT (fltInput,&flttrMyMA);<br />

// output should be 0.0078125<br />

fltOutput = GDFLIB_FilterMA (fltInput,&flttrMyMA,Define FLT);<br />

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

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

// implementation selected as default<br />

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

// output should be 0.0078125<br />

fltOutput = GDFLIB_FilterMA (fltInput,&flttrMyMA);<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. 207

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

Saved successfully!

Ooh no, something went wrong!