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.

The 9th 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 f32In (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 f32In 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( π * f32In) 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 />

Chapter 4 API References<br />

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

follows (represented as 32-bit signed fractional numbers):<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 />

Freescale Semiconductor, Inc. 401

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

Saved successfully!

Ooh no, something went wrong!