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.

Figure 4-19. Course of the function GFLIB_Atan<br />

The GFLIB_Atan_F32 function is implemented with consideration to fixed point<br />

fractional arithmetic. As can be further seen from Figure 4-19, the arctangent values are<br />

identical <strong>for</strong> the input ranges [-1, 0) <strong>and</strong> [0, 1).<br />

Moreover, it can be observed from Figure 4-19 that the course of the arctan(x) function<br />

output <strong>for</strong> a ratio in interval 1. is identical, but with the opposite sign, to the output <strong>for</strong> a<br />

ratio in interval 2. There<strong>for</strong>e, the approximation of the arctangent function over the entire<br />

defined range of input ratios can be simplified to the approximation <strong>for</strong> a ratio in range<br />

[0, 1), <strong>and</strong> then, depending on the input ratio, the result will be negated. In order to<br />

increase the accuracy of approximation without the need <strong>for</strong> a higher order polynomial,<br />

the interval [0, 1) is further divided into eight equally spaced sub intervals, <strong>and</strong> minimax<br />

polynomial approximation is done <strong>for</strong> each interval respectively. Such a division results<br />

in eight sets of polynomial coefficients. Moreover, it allows using a polynomial of only<br />

the 3rd order to achieve an accuracy of less than 0.5LSB (on the upper 16 bits of 32-bit<br />

results) across the entire range of input ratios.<br />

The GFLIB_Atan_F32 function uses fixed point fractional arithmetic, so to cast the<br />

fractional value of the output angle [-0.25, 0.25) into the correct range [- π/4, π/4), the<br />

fixed point output angle can be multiplied by π <strong>for</strong> an angle in radians. Then, the fixed<br />

point fractional implementation of the minimax approximation polynomial, used <strong>for</strong><br />

calculation of each sub sector, is defined as follows:<br />

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

Chapter 4 API References<br />

Freescale Semiconductor, Inc. 235

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

Saved successfully!

Ooh no, something went wrong!