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.

Function GFLIB_AtanYX_FLT<br />

In the second step, the vector ordinate is divided by the vector abscissa (y/x) to obtain the<br />

tangent value of the angle offset. The angle offset is computed by applying the ordinary<br />

arctangent function.<br />

The sum of the integral multiple of half-quarters <strong>and</strong> the angle offset within a single halfquarter<br />

<strong>for</strong>m the angle to be computed. The function will return 0 if both input arguments<br />

are 0.<br />

In comparison to the GFLIB_Atan_F16 function, the GFLIB_AtanYX_F16 function<br />

correctly places the calculated angle within the whole fractional range of [-1, 1), which<br />

corresponds to the real angle range of [- π, π).<br />

Note<br />

The function calls the GFLIB_Atan_F16 function. The<br />

computed value is within the range of [-1, 1).<br />

4.35.5 Re-entrancy<br />

The function is re-entrant.<br />

4.35.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16InY;<br />

tFrac16 f16InX;<br />

tFrac16 f16Ang;<br />

void main(void)<br />

{<br />

// Angle 45 deg = PI/4 rad<br />

f16InY = FRAC16 (0.5);<br />

f16InX = FRAC16 (0.5);<br />

}<br />

// output should be close to 0x2000<br />

f16Ang = GFLIB_AtanYX_F16 (f16InY, f16InX);<br />

// output should be close to 0x2000<br />

f16Ang = GFLIB_AtanYX (f16InY, f16InX, Define F16);<br />

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

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

// as default<br />

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

// output should be close to 0x2000<br />

f16Ang = GFLIB_AtanYX (f16InY, f16InX);<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 />

250 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!