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_IntegratorTR_F32<br />

where E MAX is the input scale <strong>and</strong> U MAX is the output scale. Then integrator constant<br />

C1 is defined as:<br />

Equation GFLIB_IntegratorTR_Eq6<br />

In order to implement the discrete <strong>for</strong>m integrator as in GFLIB_IntegratorTR_Eq5 on a<br />

fixed point plat<strong>for</strong>m, the value of C1 f coefficient must reside in a the fractional range<br />

[-1,1). There<strong>for</strong>e, scaling must be introduced as follows:<br />

Equation GFLIB_IntegratorTR_Eq7<br />

The introduced scaling is chosen such that coefficient f32C1 fits into fractional range<br />

[-1,1). To simplify the implementation, this scaling is chosen to be a power of 2, so the<br />

final scaling is a simple shift operation using the u16NShift variable. Hence, the shift is<br />

calculated as:<br />

Equation GFLIB_IntegratorTR_Eq8<br />

Note<br />

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

during declaration using the<br />

GFLIB_INTEGRATOR_TR_DEFAULT_F32 macro.<br />

4.58.5 Re-entrancy<br />

The function is re-entrant.<br />

4.58.6 Code Example<br />

#include "gflib.h"<br />

tFrac32 f32In;<br />

tFrac32 f32Out;<br />

// Definition of one integrator instance<br />

GFLIB_INTEGRATOR_TR_T_F32 trMyIntegrator = GFLIB_INTEGRATOR_TR_DEFAULT_F32;<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 />

340 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!