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_AtanYXShifted_F16<br />

• error contributed by higher order harmonics appearing in the input signals<br />

• computational error of the multiplication due to the finite length of registers<br />

• error of the phase shift Δθ representation in the finite precision arithmetic <strong>and</strong> in the<br />

values<br />

• error due to differences in signal amplitudes<br />

It should be noted that the function requires both signals to have the same amplitude. To<br />

minimize the output error, the amplitude of both signals should be as close to 1.0 as much<br />

as possible.<br />

The function has been tested to be reliable at a phase shift in the range of [-165, -15] <strong>and</strong><br />

[15, 165] degrees <strong>for</strong> perfectly sinusoidal input signals. Beyond this range, the function<br />

operates correctly, however, the output error can be beyond the guaranteed value. In a<br />

real application, an error, contributed by an AD conversion <strong>and</strong> by higher order<br />

harmonics of the input signals, should be also taken into account.<br />

Note<br />

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

function may become numerically unstable <strong>for</strong> a phase shift<br />

approaching -180, 0 or 180 degrees. The function accuracy is<br />

guaranteed <strong>for</strong> a phase shift in the range of [-165, -15] <strong>and</strong> [15,<br />

165] degrees at perfect input signals.<br />

4.38.5 Re-entrancy<br />

The function is re-entrant.<br />

4.38.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16InY;<br />

tFrac16 f16InX;<br />

tFrac16 f16Ang;<br />

GFLIB_ATANYXSHIFTED_T_F16 Param;<br />

void main(void)<br />

{<br />

//dtheta = 69.33deg, thetaoffset = 10deg<br />

//CY = (1 - 2^-15)/(2*cos((69.33/2)/180*pi))= 0.60789036201452440<br />

//CX = (1 - 2^-15)/(2*sin((69.33/2)/180*pi))= 0.87905201358520957<br />

//NY = 0 (abs(CY) < 1)<br />

//NX = 0 (abs(CX) < 1)<br />

//KY = 0.60789/2^0 = 0.60789036201452440<br />

//KX = 0.87905/2^0 = 0.87905201358520957<br />

//THETAADJ = 10/180 = 0.05555555555<br />

Param.f16Ky = FRAC16 (0.60789036201452440);<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 />

262 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!