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.

CAUTION<br />

For correct functionality, the threshold f16HystOn value must<br />

be greater than the f16HystOff value.<br />

Note<br />

All parameters <strong>and</strong> states used by the function can be reset<br />

during declaration using the GFLIB_HYST_DEFAULT_F16<br />

macro.<br />

4.56.5 Re-entrancy<br />

The function is re-entrant.<br />

4.56.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16In;<br />

tFrac16 f16Out;<br />

GFLIB_HYST_T_F16 f16trMyHyst = GFLIB_HYST_DEFAULT_F16;<br />

void main(void)<br />

{<br />

// Setting parameters <strong>for</strong> hysteresis<br />

f16trMyHyst.f16HystOn = FRAC16 (0.1289);<br />

f16trMyHyst.f16HystOff = FRAC16 (-0.3634);<br />

f16trMyHyst.f16OutValOn = FRAC16 (0.589);<br />

f16trMyHyst.f16OutValOff = FRAC16 (-0.123);<br />

f16trMyHyst.f16OutState = FRAC16 (-0.3333);<br />

// input value = -0.41115<br />

f16In = FRAC16 (-0.41115);<br />

}<br />

// output should be 0x8FBE ~ FRAC16(-0.123)<br />

f16Out = GFLIB_Hyst_F16 (f16In,&f16trMyHyst);<br />

// output should be 0x8FBE ~ FRAC16(-0.123)<br />

f16trMyHyst.f16OutState = FRAC16 (0);<br />

f16Out = GFLIB_Hyst (f16In, &f16trMyHyst, Define F16);<br />

// ##############################################################<br />

// Available only if 16-bit fractional implementation selected<br />

// as default<br />

// ##############################################################<br />

// output should be 0x8FBE ~ FRAC16(-0.123)<br />

f16trMyHyst.f16OutState = FRAC16 (0);<br />

f16Out = GFLIB_Hyst (f16In, &f16trMyHyst);<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. 335

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

Saved successfully!

Ooh no, something went wrong!