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-20 depicts a floating point arctangent function generated from Matlab <strong>and</strong> the<br />

approximated value of the arctangent function obtained from GFLIB_Atan_F32, plus<br />

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

be observed from this figure. The achieved accuracy with consideration to the 3rd order<br />

piece-wise minimax polynomial approximation <strong>and</strong> described fixed point scaling is less<br />

than 0.5LSB on the upper 16 bits of the 32-bit result.<br />

Note<br />

The output angle is normalized into the range [-0.25, 0.25). The<br />

function call is slightly different from common approach in the<br />

library set. The function can be called in four different ways:<br />

• With implementation postfix (i.e. GFLIB_Atan_F32(f32In,<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_ATAN_DEFAULT_F32 symbol.<br />

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

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

GFLIB_Atan(f32In, &pParam, F32), where the &pParam is<br />

pointer to approximation coefficients. In case the default<br />

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

replaced with GFLIB_ATAN_DEFAULT_F32 symbol.<br />

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

• With preselected default implementation (i.e.<br />

GFLIB_Atan(f32In, &pParam), where the &pParam is<br />

pointer to approximation coefficients. The &pParam<br />

parameter is optional <strong>and</strong> in case it is not used, the default<br />

GFLIB_ATAN_DEFAULT_F32 approximation<br />

coefficients are used.<br />

4.31.5 Re-entrancy<br />

The function is re-entrant.<br />

4.31.6 Code Example<br />

#include "gflib.h"<br />

tFrac32 f32Input;<br />

tFrac32 f32Angle;<br />

void main(void)<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. 237

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

Saved successfully!

Ooh no, something went wrong!