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.

Equation GFLIB_Tan_Eq1<br />

Because both sin(x) <strong>and</strong> cos(x) are defined on interval [- π, π), function tan(x) is equal to<br />

zero when sin(x)=0 <strong>and</strong> is equal to infinity when cos(x)=0. There<strong>for</strong>e, the tangent<br />

function has asymptotes at n* π/2 <strong>for</strong> n= , , ... The graph of tan(x) is shown in Figure<br />

4-40.<br />

Figure 4-40. Course of the function GFLIB_Tan<br />

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

fractional arithmetic, hence all tangent values falling beyond [-1, 1) are truncated to -1<br />

<strong>and</strong> 1 respectively. This truncation is applied <strong>for</strong> angles in the ranges [-3 π/4, - π/4) <strong>and</strong><br />

[ π/4, 3 π/4). As can be further seen from Figure 4-40, tangent values are identical <strong>for</strong><br />

angles in the ranges:<br />

1. [- π/4, 0) <strong>and</strong> [3 π/4, π)<br />

2. [- π, -3 π/4) <strong>and</strong> [0, π/4)<br />

Chapter 4 API References<br />

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

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

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

range of input angles can be simplified to an approximation <strong>for</strong> angles in the range [0, π/<br />

4), <strong>and</strong> then, depending on the input angle, the result will be negated. In order to increase<br />

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

interval [0, π/4) is further divided into eight equally spaced sub intervals, <strong>and</strong> polynomial<br />

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

of polynomial coefficients. Moreover, it allows using a polynomial of only the 4th order<br />

to achieve an accuracy of less than 0.5LSB (on the upper 16 bits of 32-bit results) across<br />

the full range of input angles.<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. 421

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

Saved successfully!

Ooh no, something went wrong!