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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Function GFLIB_Lut2D_F16<br />

Equation GFLIB_Lut2D_Eq17<br />

where n is the integer defining the length of the interpolating interval in the range of -1,<br />

-2, ... -29.<br />

The computation of the abscissa offset <strong>and</strong> the interval index can be viewed also in the<br />

following way. The input abscissa value can be divided into two parts. The first n most<br />

significant bits of the 16-bit halfword, after the sign bit, compose the interval index, in<br />

which interpolation is per<strong>for</strong>med. The rest of the bits <strong>for</strong>m the abscissa offset within the<br />

interpolating interval. This simple way to calculate the interpolating interval index <strong>and</strong><br />

the abscissa offset is the consequence of assumption of all interpolating interval lengths<br />

equal 2 -n .<br />

It should be noted that the input abscissa value can be positive or negative. If it is positive<br />

then the ordinate values are read as in the ordinary data array, that is at or after the data<br />

pointer provided in the parameters structure (pParam->pf16Table). However, if it is<br />

negative, then the ordinate values are read from the memory, which is located behind the<br />

pParam->pf16Table pointer.<br />

Note<br />

The function per<strong>for</strong>ms the bilinear interpolation.<br />

CAUTION<br />

The function does not check whether the input values are within<br />

a range allowed by the interpolating data table pParam-<br />

>pf16Table. If the computed interval index points to data<br />

outside the provided data table then the interpolation will be<br />

computed with invalid data.<br />

4.71.5 Re-entrancy<br />

The function is re-entrant.<br />

4.71.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16In1;<br />

tFrac16 f16In2;<br />

tFrac16 f16Out;<br />

GFLIB_LUT2D_T_F16 tr16tMyLut2D = GFLIB_LUT2D_DEFAULT_F16;<br />

tFrac16 pf16Table2D[81] = {FRAC16 (0.0), FRAC16 (0.01), FRAC16 (0.02), FRAC16<br />

(0.03), FRAC16 (0.04), FRAC16 (0.05), FRAC16 (0.06), FRAC16 (0.07), FRAC16 (0.08),<br />

FRAC16 (0.1), FRAC16 (0.11), FRAC16 (0.12), FRAC16<br />

(0.13), FRAC16 (0.14), FRAC16 (0.15), FRAC16 (0.16), FRAC16 (0.17), FRAC16 (0.18),<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 />

380 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!