Documentation
Tools for embedded systems
|
A PID controller object. More...
#include <pid.hpp>
Public Member Functions | |
virtual | ~pidController () |
pidController ()=default | |
bool | setup (const real_t kc, const real_t ki, const real_t kd, const real_t dT) noexcept |
Setup and initialize the PID controller instance. | |
bool | setup (const pidGains &g, const real_t dT) noexcept |
Setup and initialize the PID controller instance. | |
bool | setDirection (const pidDirection d) noexcept |
Set the PID control action direction. | |
bool | setParams (const real_t kc, const real_t ti, const real_t td) noexcept |
Set/Change the PID controller gains by using the [Kc, Ti Td ] triplet. | |
bool | setGains (const real_t kc, const real_t ki, const real_t kd) noexcept |
Set/Change the PID controller gains. | |
bool | setGains (const pidGains &g) noexcept |
Set/Change the PID controller gains. | |
bool | setExtraGains (const real_t Kw, const real_t Kt) noexcept |
Set/Change extra PID controller gains. | |
bool | setSaturation (const real_t Min, const real_t Max) noexcept |
Setup the output saturation for the PID controller. | |
bool | setSeries (void) noexcept |
Convert the controller gains to conform the series or interacting form. | |
bool | setEpsilon (const real_t eps) noexcept |
Set the minimum value considered as error. | |
bool | setDerivativeFilter (const real_t Beta) noexcept |
Set the tuning parameter for the derivative filter. | |
bool | setDerivativeFilterTimeConstant (const real_t Tf) noexcept |
Set the time constant for the derivative filter. | |
bool | setMode (const pidMode Mode) noexcept |
Change the controller operational mode. In pidMode::PID_AUTOMATIC, the computed output of the PID controller will be used as the control signal for the process. In pidMode::PID_MANUAL mode, the manual input will be used as the control signal for the process and the PID controller loop will continue operating to guarantee the bumpless-transfer when a switch to the pidMode::PID_AUTOMATIC its performed;. | |
bool | setReferenceWeighting (const real_t gb, const real_t gc) noexcept |
Set the PID Reference(Set-Point) Weighting. This value is used in order to avoid the increase of the rise time due to the smoothing of the reference signal applied to the closed-loop system. | |
bool | setManualInput (const real_t manualInput) noexcept |
Set the PID manual input mode. This value will be used as the manual input when the controller it set into the pidMode::PID_MANUAL mode. Bumpless-transfer is guaranteed. | |
bool | setModelReferenceControl (const real_t &modelRef, const real_t Gamma=0.5_re, const real_t Alpha=0.01_re) noexcept |
Enable the additive MRAC(Model Reference Adaptive Control) feature. | |
bool | removeModelReferenceControl (void) noexcept |
Removes the Enable the additive MRAC(Model Reference Adaptive Control) feature from the control loop. | |
real_t | control (const real_t w, const real_t y) noexcept |
Computes the control action for given PID controller instance. | |
bool | bindAutoTuning (pidAutoTuning &at) noexcept |
Binds the specified instance to enable the PID controller auto tuning algorithm. | |
bool | unbindAutoTuning (void) noexcept |
Unbind and disable the PID controller auto-tuning algorithm. | |
bool | enableAutoTuning (const uint32_t tEnable) noexcept |
Set the number of time steps where the auto tuner algorithm will modify the controller gains. | |
bool | isAutoTuningComplete (void) const noexcept |
Verifies that the auto tuning process has finished with new gains set on the controller. | |
bool | setAutoTuningParameters (const real_t Mu, const real_t Alpha, const real_t lambda) noexcept |
Change parameters of the auto-tuning algorithm. | |
bool | setAutoTuningControllerType (const pidType t) noexcept |
Select the PID type to tune. | |
bool | reset (void) noexcept |
Reset the internal PID controller calculations. | |
pidGains | getGains (void) const noexcept |
Retrieve the current PID gains. | |
Public Member Functions inherited from qlibs::nState | |
virtual | ~nState () |
nState (const real_t x0=0.0_re, const real_t sn_1=0.0_re, const real_t sn_2=0.0_re) noexcept | |
Constructor for the state object. | |
void | init (const real_t x0=0.0_re, const real_t sn_1=0.0_re, const real_t sn_2=0.0_re) noexcept |
Initialize the state object. | |
real_t | integrate (const real_t s, const real_t dt, const bool bUpdate=true) noexcept |
Perform a numerical integration step. | |
real_t | derive (const real_t s, const real_t dt, const bool bUpdate=true) noexcept |
Perform a numerical derivation step by using the delta rule. | |
void | setIntegrationMethod (integrationMethod m) noexcept |
Set integration method . | |
void | setDerivationMethod (derivationMethod m) noexcept |
Set derivation method. | |
real_t | operator() (void) const noexcept |
Get the value of the state. | |
Additional Inherited Members | |
Public Attributes inherited from qlibs::pidGains | |
real_t | Kc |
real_t | Ki |
real_t | Kd |
A PID controller object.
The instance should be initialized using the pid::setup() method.
|
inlinevirtual |
|
default |
|
noexcept |
Binds the specified instance to enable the PID controller auto tuning algorithm.
[in] | at | The PID auto-tuning instance. |
true
on success, otherwise return false
. Computes the control action for given PID controller instance.
[in] | w | The reference value aka SetPoint. |
[in] | y | The controlled variable aka Process-variable. |
|
noexcept |
Set the number of time steps where the auto tuner algorithm will modify the controller gains.
[in] | tEnable | The number of time steps. To keep the auto tuner enabled indefinitely pass pidAutoTuning::UNDEFINED as argument. |
true
on success, otherwise return false
.
|
inlinenoexcept |
Retrieve the current PID gains.
|
noexcept |
Verifies that the auto tuning process has finished with new gains set on the controller.
true
if auto-tuning its complete, otherwise return false
.
|
noexcept |
Removes the Enable the additive MRAC(Model Reference Adaptive Control) feature from the control loop.
true
on success, otherwise return false
.
|
noexcept |
Reset the internal PID controller calculations.
true
on success, otherwise return false
.
|
noexcept |
Select the PID type to tune.
[in] | t | The type of controller to tune. |
true
on success, false
on failure.
|
noexcept |
Change parameters of the auto-tuning algorithm.
[in] | Mu | Algorithm momentum. [ 0 <= Mu <= 1 ]. |
[in] | Alpha | Final controller speed adjustment. [ 0 < Alpha <= 1 ]. |
[in] | lambda | Algorithm forgetting factor [ 0.8 <= lambda <= 1 ]. |
true
on success, false
on failure.
|
noexcept |
Set the tuning parameter for the derivative filter.
[in] | Beta | The tuning parameter. [ 0 <= Beta < 1 ] |
true
on success, otherwise return false
.
|
noexcept |
Set the time constant for the derivative filter.
[in] | Tf | Derivative filter time constant [ Tf >= 0 ] |
true
on success, otherwise return false
.
|
noexcept |
Set the PID control action direction.
[in] | d | Desired output direction. |
true
on success, otherwise return false
.
|
noexcept |
Set the minimum value considered as error.
[in] | eps | The minimal error value ( eps > 0 ). |
true
on success, otherwise return false
. Set/Change extra PID controller gains.
[in] | Kw | Saturation feedback gain. Used for antiWindup and bumpless transfer. A zero value disables these features. |
[in] | Kt | Manual input gain. |
true
on success, otherwise return false
.
|
noexcept |
Set/Change the PID controller gains.
[in] | g | The structure with the controller gains |
true
on success, otherwise return false
. Set/Change the PID controller gains.
[in] | kc | Proportional Gain. |
[in] | ki | Integral Gain. |
[in] | kd | Derivative Gain. |
true
on success, otherwise return false
.
|
noexcept |
Set the PID manual input mode. This value will be used as the manual input when the controller it set into the pidMode::PID_MANUAL mode. Bumpless-transfer is guaranteed.
[in] | manualInput | The value of the manual input. |
true
on success, otherwise return false
.
|
noexcept |
Change the controller operational mode. In pidMode::PID_AUTOMATIC, the computed output of the PID controller will be used as the control signal for the process. In pidMode::PID_MANUAL mode, the manual input will be used as the control signal for the process and the PID controller loop will continue operating to guarantee the bumpless-transfer when a switch to the pidMode::PID_AUTOMATIC its performed;.
[in] | Mode | The desired operational mode. |
true
on success, otherwise return false
.
|
noexcept |
Enable the additive MRAC(Model Reference Adaptive Control) feature.
[in] | modelRef | A pointer to the output of the model reference. |
[in] | Gamma | Adjustable parameter to indicate the adaptation speed. |
[in] | Alpha | Adjustable parameter the adaptation momentum. |
true
on success, otherwise return false
. Set/Change the PID controller gains by using the [Kc, Ti Td ] triplet.
[in] | kc | Proportional Gain. |
[in] | ti | Integral time. |
[in] | td | Derivative time. |
true
on success, otherwise return false
. Set the PID Reference(Set-Point) Weighting. This value is used in order to avoid the increase of the rise time due to the smoothing of the reference signal applied to the closed-loop system.
[in] | gb | The reference weight value for the proportional element. |
[in] | gc | The reference weight value for the derivative element. |
true
on success, otherwise return false
. Setup the output saturation for the PID controller.
[in] | Min | The minimal value allowed for the output. |
[in] | Max | The maximal value allowed for the output. |
true
on success, otherwise return false
.
|
noexcept |
Convert the controller gains to conform the series or interacting form.
true
on success, otherwise return false
. Setup and initialize the PID controller instance.
[in] | g | The structure with the controller gains |
[in] | dT | Time step in seconds. |
true
on success, otherwise return false
.
|
noexcept |
Setup and initialize the PID controller instance.
[in] | kc | Proportional Gain. |
[in] | ki | Integral Gain. |
[in] | kd | Derivative Gain. |
[in] | dT | Time step in seconds. |
true
on success, otherwise return false
.
|
inlinenoexcept |
Unbind and disable the PID controller auto-tuning algorithm.
true
on success, otherwise return false
.