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

The bounds are described by a limitation element equation<br />

GFLIB_<strong>Control</strong>lerPIpAW_Eq12. When the bounds are exceeded the non-linear<br />

saturation characteristic will take effect <strong>and</strong> influence the dynamic behavior. The<br />

described limitation is implemented on the integral part accumulator (limitation during<br />

the calculation) <strong>and</strong> on the overall controller output. There<strong>for</strong>e, if the limitation occurs,<br />

the controller output is clipped to its bounds <strong>and</strong> the wind-up occurrence of the<br />

accumulator portion is avoided by saturating the actual sum.<br />

Note<br />

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

declaration using the<br />

GFLIB_CONTROLLER_PIAW_P_DEFAULT_F16 macro. To<br />

effectively reach the target precision the internal calculation is<br />

done in 32-bit fractional arithmetic <strong>and</strong> internal accumulator is<br />

32-bit wide.<br />

4.44.5 Re-entrancy<br />

The function is re-entrant.<br />

4.44.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16InErr;<br />

tFrac16 f16Output;<br />

GFLIB_CONTROLLER_PIAW_P_T_F16 trMyPI = GFLIB_CONTROLLER_PIAW_P_DEFAULT_F16;<br />

void main(void)<br />

{<br />

// input error = 0.25<br />

f16InErr = FRAC16 (0.25);<br />

// controller parameters<br />

trMyPI.f16PropGain = FRAC16 (0.01);<br />

trMyPI.f16IntegGain = FRAC16 (0.02);<br />

trMyPI.s16PropGainShift = 1;<br />

trMyPI.s16IntegGainShift = 1;<br />

trMyPI.f32IntegPartK_1 = FRAC32 (0);<br />

trMyPI.f16UpperLimit = FRAC16 (1.0);<br />

trMyPI.f16LowerLimit = FRAC16 (-1.0);<br />

// output should be 0x01EB<br />

f16Output = GFLIB_<strong>Control</strong>lerPIpAW_F16 (f16InErr, &trMyPI);<br />

// output should be 0x01EB<br />

f16Output = GFLIB_<strong>Control</strong>lerPIpAW (f16InErr, &trMyPI, Define F16);<br />

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

// Available only if 16-bit fractional implementation selected<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 />

288 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!