Motorcortex Control  version: 3.0.0
mcx::control3::PID Class Reference

The PID Control Object provides a PID controller with Proportional, Derivative and Integral action. More...

#include <ctrl_pid.h>

Public Member Functions

void setError (double error)
 Sets the error input signal. More...
 
void setActual (double actual)
 Sets the actual (feedback) signal. More...
 
double getOutput () const
 Returns the output signal. More...
 
void setKp (double kp)
 Sets the proportional gain. More...
 
void setKi (double ki)
 Sets the integral gain. More...
 
void setKd (double kd)
 Sets the derivative gain. More...
 
void setIMax (double iMax)
 Sets the upper limit for the integral term. More...
 
void setIReset (bool iReset)
 Sets the reset signal that zeros the integral action. More...
 

Detailed Description

The PID Control Object provides a PID controller with Proportional, Derivative and Integral action.

The controller acts on the error signal that is the input of the controller. The output \( u(t) \) is calculated according to:

\( u(t) = K_\text{p} e(t) + K_\text{i} \int_0^t e(t') \,dt' + K_\text{d} \frac{de(t)}{dt} \).

where \( e \) is the error signal, and \( K_\text{p} \), \( K_\text{i} \) and \( K_\text{d} \) are the proportional, derivative and integral gains respectively.

\u200b

Parameters
[in]error- the error signal, which is the difference between the reference (command value) and the actual value of signal we are trying to control
[in]actual- the actual value of signal we are trying to control, it is only used to determine if the actual signal is beyond the velocity threshold of the reference signal. If the velocity threshold is set to zer this input can be left at zero.
[in]iReset- reset signal for the integral action. The integrator output is set to zero when this signal is true.
[out]output- the controller output signal
[out]iTerm- the current value of the integral term
[out]dTerm- the current value of the derivative term
kp- the proportional gain
ki- the integral gain
kd- the derivative gain
iMin- lower limit value of the integral action
iMax- upper limit value of the integral action
iPositionErrorThresholdNeg- lower threshold value of the error for enabling the integral action
iPositionErrorThresholdPos- upper threshold value of the error for enabling the integral action
iActualVelocityThresholdNeg- lower threshold value of the actual velocity for enabling the integral action
iActualVelocityThresholdPos- upper threshold value of the actual velocity for enabling the integral action
iMin- lower limit for the integral action
iMax- upper limit for the integral action

Member Function Documentation

◆ getOutput()

double mcx::control3::PID::getOutput ( ) const
inline

Returns the output signal.

Returns
actual value of the output.

◆ setActual()

void mcx::control3::PID::setActual ( double  actual)
inline

Sets the actual (feedback) signal.

Parameters
actual- new value of the actual signal.

◆ setError()

void mcx::control3::PID::setError ( double  error)
inline

Sets the error input signal.

Parameters
error- new value of the error signal.

◆ setIMax()

void mcx::control3::PID::setIMax ( double  iMax)
inline

Sets the upper limit for the integral term.

Parameters
iMax- new value of the upper limit for the integral gain.

◆ setIReset()

void mcx::control3::PID::setIReset ( bool  iReset)
inline

Sets the reset signal that zeros the integral action.

Parameters
iReset- reset signal

◆ setKd()

void mcx::control3::PID::setKd ( double  kd)
inline

Sets the derivative gain.

Parameters
kd- new value of the derivative gain.

◆ setKi()

void mcx::control3::PID::setKi ( double  ki)
inline

Sets the integral gain.

Parameters
ki- new value of the integral gain.

◆ setKp()

void mcx::control3::PID::setKp ( double  kp)
inline

Sets the proportional gain.

Parameters
kp- new value of the proportional gain.

The documentation for this class was generated from the following files: