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

4.79.2 Arguments<br />

Table 4-100. GFLIB_Sin_F32 arguments<br />

Type Name Direction Description<br />

tFrac32 f32In input Input argument is a 32-bit number that contains an angle in<br />

radians between [- π, π) normalized between [-1, 1).<br />

const<br />

GFLIB_SIN_T_F32<br />

*const<br />

4.79.3 Return<br />

pParam input Pointer to an array of Taylor coefficients.<br />

The function returns the sin of the input argument as a fixed point 32-bit number,<br />

normalized between [-1, 1).<br />

4.79.4 Description<br />

The GFLIB_Sin_F32 function provides a computational method <strong>for</strong> calculation of a<br />

st<strong>and</strong>ard trigonometric sine function sin(x), using the 9th order Taylor polynomial<br />

approximation. The Taylor polynomial approximation of a sine function is described as<br />

follows:<br />

where x is the input angle.<br />

Equation GFLIB_Sin_Eq1<br />

The 9th order polynomial approximation is chosen as sufficient an order to achieve the<br />

best ratio between calculation accuracy <strong>and</strong> speed of calculation. Because the<br />

GFLIB_Sin_F32 function is implemented with consideration to fixed point fractional<br />

arithmetic, all variables are normalized to fit into the [-1, 1) range. There<strong>for</strong>e, in order to<br />

cast the fractional value of the input angle f32In [-1, 1) into the correct range [- π, π), the<br />

input f32In must be multiplied by π. So the fixed point fractional implementation of the<br />

GFLIB_Sin_F32 function, using 9th order Taylor approximation, is given as follows:<br />

Equation GFLIB_Sin_Eq2<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 />

400 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!