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.

Note<br />

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

declaration using the<br />

GFLIB_CONTROLLER_PI_R_DEFAULT_FLT macro. As<br />

the PI controller also contains the integration part, the output<br />

result is saddled by cumulative error. To enumerate the<br />

computation error in one calculation cycle, the internal<br />

accumulator is not used <strong>for</strong> testing purposes <strong>and</strong> is replaced by<br />

output from the previous calculation step of the reference<br />

model.<br />

4.48.5 Re-entrancy<br />

The function is re-entrant.<br />

4.48.6 Code Example<br />

#include "gflib.h"<br />

tFloat fltInErr;<br />

tFloat fltOutput;<br />

GFLIB_CONTROLLER_PI_R_T_FLT trMyPI = GFLIB_CONTROLLER_PI_R_DEFAULT_FLT;<br />

void main(void)<br />

{<br />

// input error = 0.25<br />

fltInErr = (tFloat)(0.25);<br />

}<br />

// controller parameters<br />

trMyPI.fltCC1sc = (tFloat)(0.01);<br />

trMyPI.fltCC2sc = (tFloat)(0.01);<br />

// output should be 5e-3<br />

fltOutput = GFLIB_<strong>Control</strong>lerPIr_FLT (fltInErr,&trMyPI);<br />

// output should be 5e-3<br />

fltOutput = GFLIB_<strong>Control</strong>lerPIr (fltInErr,&trMyPI, Define FLT);<br />

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

// Available only if single precision floating point implementation<br />

// selected as default<br />

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

// output should be 5e-3<br />

fltOutput = GFLIB_<strong>Control</strong>lerPIr (fltInErr,&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. 303

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

Saved successfully!

Ooh no, something went wrong!