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_<strong>Control</strong>lerPIr_F16<br />

The introduced scaling shift u16NShift is chosen such that both coefficients f16CC1sc,<br />

f16CC2sc reside in the range [-1, 1). To simplify the implementation, this scaling shift is<br />

chosen to be a power of 2, so the final scaling is a simple shift operation. Moreover, the<br />

scaling shift cannot be a negative number, so the operation of scaling is always to scale<br />

numbers with an absolute value larger than 1 down to fit in the range [-1, 1).<br />

Equation GFLIB_<strong>Control</strong>lerPIr_Eq11<br />

The final, scaled, fractional equation of a recurrent PI controller on a 16-bit fixed point<br />

plat<strong>for</strong>m is there<strong>for</strong>e implemented as follows:<br />

where:<br />

Equation GFLIB_<strong>Control</strong>lerPIr_Eq12<br />

• u f(k) - fractional representation [-1, 1) of the controller output<br />

• e f(k) - fractional representation [-1, 1) of the controller input (error)<br />

• f16CC1sc - fractional representation [-1, 1) of the 1st controller coefficient<br />

• f16CC2sc - fractional representation [-1, 1) of the 2nd controller coefficient<br />

• u16NShift - in range [0,15] - is chosen such that both coefficients f16CC1sc <strong>and</strong><br />

f16CC2sc are in the range [-1, 1)<br />

Note<br />

All controller parameters <strong>and</strong> states can be reset during<br />

declaration using the<br />

GFLIB_CONTROLLER_PI_R_DEFAULT_F16 macro.<br />

4.47.5 Re-entrancy<br />

The function is re-entrant.<br />

4.47.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16InErr;<br />

tFrac16 f16Output;<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 />

300 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!