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.

Function GFLIB_AtanYXShifted_F32<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 angle addition <strong>and</strong> the angle offset within a single quarter <strong>for</strong>m the angle<br />

to be computed. The function will return 0 if both input arguments are 0.<br />

Note<br />

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

computed value is within the range of [- π, π].<br />

4.36.5 Re-entrancy<br />

The function is re-entrant.<br />

4.36.6 Code Example<br />

#include "gflib.h"<br />

tFloat fltInY;<br />

tFloat fltInX;<br />

tFloat fltAng;<br />

void main(void)<br />

{<br />

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

fltInY = (tFloat)(0.5);<br />

fltInX = (tFloat)(0.5);<br />

}<br />

// Output angle should be 45 deg = PI/4 rad = 0.7853981634<br />

fltAng = GFLIB_AtanYX_FLT (fltInY, fltInX);<br />

// Output angle should be 45 deg = PI/4 rad = 0.7853981634<br />

fltAng = GFLIB_AtanYX (fltInY, fltInX, Define FLT);<br />

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

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

// implementation selected as default<br />

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

// Output angle should be 45 deg = PI/4 rad = 0.7853981634<br />

fltAng = GFLIB_AtanYX (fltInY, fltInX);<br />

4.37 Function GFLIB_AtanYXShifted_F32<br />

This function calculates the angle of two sine waves shifted in phase to each other.<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 />

252 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!