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.

• f32PropGain - is the scaled value of proportional gain [-1, 1)<br />

• s16PropGainShift - is the scaling shift <strong>for</strong> proportional gain [-31,31]<br />

• f32IntegGain - is the scaled value of integral gain [-1, 1)<br />

• s16IntegGainShift - is the scaling shift <strong>for</strong> integral gain [-31,31]<br />

Note<br />

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

declaration using the<br />

GFLIB_CONTROLLER_PI_P_DEFAULT_F32 macro.<br />

4.40.5 Re-entrancy<br />

The function is re-entrant.<br />

4.40.6 Code Example<br />

#include "gflib.h"<br />

tFrac32 f32InErr;<br />

tFrac32 f32Output;<br />

GFLIB_CONTROLLER_PI_P_T_F32 trMyPI = GFLIB_CONTROLLER_PI_P_DEFAULT_F32;<br />

void main(void)<br />

{<br />

// input error = 0.25<br />

f32InErr = FRAC32 (0.25);<br />

}<br />

// controller parameters<br />

trMyPI.f32PropGain = FRAC32 (0.01);<br />

trMyPI.f32IntegGain = FRAC32 (0.02);<br />

trMyPI.s16PropGainShift = 1;<br />

trMyPI.s16IntegGainShift = 1;<br />

trMyPI.f32IntegPartK_1 = 0;<br />

// output should be 0x01EB851E<br />

f32Output = GFLIB_<strong>Control</strong>lerPIp_F32 (f32InErr, &trMyPI);<br />

// output should be 0x01EB851E<br />

f32Output = GFLIB_<strong>Control</strong>lerPIp (f32InErr, &trMyPI, Define F32);<br />

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

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

// as default<br />

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

// output should be 0x01EB851E<br />

f32Output = GFLIB_<strong>Control</strong>lerPIp (f32InErr, &trMyPI);<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. 271

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

Saved successfully!

Ooh no, something went wrong!