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.

Figure 4-36 depicts a floating point sine function generated from Matlab <strong>and</strong> the<br />

approximated value of the sine function obtained from GFLIB_Sin_FLT, plus their<br />

difference. The course of calculation accuracy as a function of the input angle can be<br />

observed from this figure.<br />

Figure 4-36. sin(x) vs. GFLIB_Sin_FLT(fltIn)<br />

Note<br />

The input angle (fltIn) is in single precision floating point<br />

<strong>for</strong>mat considering the input angle directly in radians. As<br />

during the computation the irrational value of π is used <strong>for</strong><br />

subtraction, the correction constant is used to increase the<br />

calculation precision in boundary intervals. This correction<br />

constant is equal to the difference of π computed in double <strong>and</strong><br />

in single precision. The function call is slightly different from<br />

common approach in the library set. The function can be called<br />

in four different ways:<br />

• With implementation postfix (i.e. GFLIB_Sin_FLT(fltIn,<br />

&pParam)), where the &pParam is pointer to<br />

approximation coefficients. In case the default<br />

approximation coefficients are used, the &pParam must be<br />

replaced with GFLIB_SIN_DEFAULT_FLT symbol. The<br />

&pParam parameter is m<strong>and</strong>atory.<br />

• With additional implementation parameter (i.e.<br />

GFLIB_Sin(fltIn, &pParam, FLT), where the &pParam is<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. 411

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

Saved successfully!

Ooh no, something went wrong!