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.

}<br />

// output should be 0x5A82 ~ FRAC16(0.70710678)<br />

f16Out = GFLIB_Sqrt (f16In);<br />

4.84 Function GFLIB_Sqrt_FLT<br />

This function returns the square root of input value.<br />

4.84.1 Declaration<br />

tFloat GFLIB_Sqrt_FLT(tFloat fltIn);<br />

4.84.2 Arguments<br />

Table 4-106. GFLIB_Sqrt_FLT arguments<br />

Type Name Direction Description<br />

tFloat fltIn input The input value.<br />

4.84.3 Return<br />

The function returns the square root of the input value. The return value is in single<br />

precision floating point <strong>for</strong>mat.<br />

4.84.4 Description<br />

The GFLIB_Sqrt_FLT function computes the square root of the input value.<br />

The computations are made by an approximation with two additional "Babylonian" steps<br />

<strong>for</strong> elimination quadratic errors. This technique is based on the fact that the IEEE floating<br />

point <strong>for</strong>mat approximates base-2 logarithm. For example, you can get the approximate<br />

logarithm of 32-bit single precision floating point number by translating its binary<br />

representation as an integer, scaling it by 2 -23 <strong>and</strong> removing a bias of 127 as shown in the<br />

following <strong>for</strong>mula:<br />

Equation GFLIB_Sqrt_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. 417

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

Saved successfully!

Ooh no, something went wrong!