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.

where:<br />

Equation GFLIB_AtanYXShifted_Eq2<br />

• x, y are respectively, the fltInX, <strong>and</strong> fltInY<br />

• θ is the angle to be computed by the function, see the previous equation<br />

• Δθ is the phase difference between the x, y signals, see the previous equation<br />

• a, b intermediate variables<br />

• θ Offset is the additional phase shift in radians, the computed angle will be θ + θ Offset<br />

The algorithm can be easily justified by proving the trigonometric identity:<br />

Equation GFLIB_AtanYXShifted_Eq3<br />

The function initialization parameters can be calculated as shown in the following Matlab<br />

code:<br />

function [KY, KX, THETAADJ] = atanyxshiftedpar(dthdeg, thoffsetdeg)<br />

// ATANYXSHIFTEDPAR calculation of parameters <strong>for</strong> atanyxshifted() function<br />

//<br />

// [KY, KX, NY, NX, THETAADJ] = atanyxshiftedpar(dthdeg, thoffsetdeg)<br />

//<br />

// dthdeg = phase shift (delta theta) between sine waves in degrees<br />

// thoffsetdeg = angle offset (theta offset) in degrees<br />

// KY - multiplication coefficient of y signal<br />

// KX - multiplication coefficient of x signal<br />

// THETAADJ - adjusting angle in radians, scaled from [-pi, pi) to [-1, 1)<br />

if (dthdeg < -180) || (dthdeg >= 180)<br />

error('atanyxshiftedpar: dthdeg out of range');<br />

end<br />

if (thoffsetdeg < -180) || (thoffsetdeg >= 180)<br />

error('atanyxshiftedpar: thoffsetdeg out of range');<br />

end<br />

dth2 = ((dthdeg/2)/180*pi);<br />

thoffset = (thoffsetdeg/180*pi);<br />

KY = 1/(2*cos(dth2));<br />

KX = 1/(2*sin(dth2));<br />

THETAADJ = dthdeg/2 - thoffsetdeg;<br />

if THETAADJ >= 180<br />

THETAADJ = THETAADJ - 360;<br />

elseif THETAADJ < -180<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. 265

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

Saved successfully!

Ooh no, something went wrong!