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 input f16In must be multiplied by π. So, the fixed point fractional<br />

implementation of the GFLIB_Sin_F16 function, using 9th order Taylor approximation,<br />

is given as follows:<br />

Equation GFLIB_Cos_Eq3<br />

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

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_Cos_Eq2, results in<br />

the following:<br />

Equation GFLIB_Cos_Eq4<br />

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

Equation GFLIB_Cos_Eq5<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 16-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. 323

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

Saved successfully!

Ooh no, something went wrong!