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.

Function GFLIB_Tan_F16<br />

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

The GFLIB_Tan_F16 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-42, 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 />

Moreover, it can be observed from Figure 4-42 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.<br />

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

fractional value of the input angle f16In [-1, 1) into the correct range [- π, π), the fixed<br />

point input angle f16In must be multiplied by π. Then the fixed point fractional<br />

implementation of the approximation polynomial, used <strong>for</strong> calculation of each sub sector,<br />

is defined as follows:<br />

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

426 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!