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

The 7th order polynomial approximation of the sine function has a very good accuracy in<br />

the range [- π/2, π/2) of the argument, but in wider ranges the calculation error quickly<br />

increases. To minimize the error without having to use a higher order polynomial, the<br />

symmetry of the sine function sin(x) = sin( π - x) is utilized. There<strong>for</strong>e, the input<br />

argument is transferred to be always in the range [- π/2, π/2) <strong>and</strong> the Taylor polynomial<br />

is calculated only in the range of the argument [- π/2, π/2).<br />

To make calculations more precise, the given argument value f16In (that is to be<br />

transferred into the range [-0.5, 0.5) due to the sine function symmetry) is shifted by 1 bit<br />

to the left (multiplied by 2). Then, the value of f16In 2 , used in the calculations, is in the<br />

range [-1, 1) instead of [-0.25, 0.25). Shifting the input value by 1 bit to the left will<br />

increase the accuracy of the calculated sin( π * f16In) function. Implementing such a<br />

scale on the approximation function described by equation GFLIB_Sin_Eq2, results in<br />

the following:<br />

Equation GFLIB_Sin_Eq3<br />

Equation GFLIB_Sin_Eq3 can be further rewritten into the following <strong>for</strong>m:<br />

Equation GFLIB_Sin_Eq4<br />

where a 1 ... a 4 are coefficients of the approximation polynomial, which are calculated as<br />

follows (represented as 16-bit signed fractional numbers):<br />

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

406 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!