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

4.53.2 Arguments<br />

Table 4-69. GFLIB_Cos_F16 arguments<br />

Type Name Direction Description<br />

tFrac16 f16In input Input argument is a 16-bit number that contains an angle in<br />

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

const<br />

GFLIB_COS_T_F16<br />

*const<br />

4.53.3 Return<br />

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

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

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

4.53.4 Description<br />

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

st<strong>and</strong>ard trigonometric cosine function cos(x), using the 7th order Taylor polynomial<br />

approximation of the sine function. The following two equations describe the chosen<br />

approach of calculating the cosine function:<br />

Equation GFLIB_Cos_Eq1<br />

Equation GFLIB_Cos_Eq2<br />

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

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

Because the GFLIB_Cos_F16 function is implemented with consideration to fixed point<br />

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

in order to cast the fractional value of the input angle f16In [-1, 1) into the correct range<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 />

322 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!