Documentation
Tools for embedded systems
|
API for the qPID Controller library. More...
Data Structures | |
struct | qPID_Gains_t |
PID Gains structure. More... | |
struct | qPID_AutoTuning_t |
A PID Auto-tuning object. More... | |
struct | qPID_controller_t |
A PID controller object. More... | |
Macros | |
#define | QPID_AUTOTUNING_UNDEFINED |
Macro to keep the auto-tuner enabled indefinitely. | |
Enumerations | |
enum | qPID_Type_t { qPID_TYPE_P , qPID_TYPE_PD , qPID_TYPE_PI , qPID_TYPE_PID } |
Enumeration class with the operational modes for the PID controller. More... | |
enum | qPID_Mode_t { qPID_Automatic , qPID_Manual } |
Enumeration with the operational modes for the PID controller. More... | |
enum | qPID_Direction_t { qPID_Forward , qPID_Backward } |
Direction modes of the PID controller. More... | |
Functions | |
int | qPID_Setup (qPID_controller_t *const c, const float kc, const float ki, const float kd, const float dt) |
Setup and initialize the PID controller instance. | |
int | qPID_SetDirection (qPID_controller_t *const c, const qPID_Direction_t d) |
Set the PID control action direction. | |
int | qPID_SetParams (qPID_controller_t *const c, const float kc, const float ti, const float td) |
Set/Change the PID controller gains by using the [Kc, Ti Td ] triplet. | |
int | qPID_SetGains (qPID_controller_t *const c, const float kc, const float ki, const float kd) |
Set/Change the PID controller gains. | |
int | qPID_SetExtraGains (qPID_controller_t *const c, const float kw, const float kt) |
Set/Change extra PID controller gains. | |
int | qPID_Reset (qPID_controller_t *const c) |
Reset the internal PID controller calculations. | |
int | qPID_SetSaturation (qPID_controller_t *const c, const float min, const float max) |
Setup the output saturation for the PID controller. | |
int | qPID_SetSeries (qPID_controller_t *const c) |
Convert the controller gains to conform the series or interacting form. | |
int | qPID_SetEpsilon (qPID_controller_t *const c, const float eps) |
Set the minimum value considered as error. | |
int | qPID_SetDerivativeFilter (qPID_controller_t *const c, const float beta) |
Set the tuning parameter for the derivative filter. | |
int | qPID_SetReferenceWeighting (qPID_controller_t *const c, const float gb, const float gc) |
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. | |
int | qPID_SetManualInput (qPID_controller_t *const c, const float manualInput) |
Set the PID manual input mode. This value will be used as the manual input when the controller it set into the qPID_Manual mode. Bumpless-transfer is guaranteed. | |
int | qPID_SetMode (qPID_controller_t *const c, const qPID_Mode_t m) |
Change the controller operational mode. In qPID_Automatic mode, the computed output of the PID controller will be used as the control signal for the process. In qPID_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 qPID_Automatic mode its performed;. | |
int | qPID_SetMRAC (qPID_controller_t *const c, const float *modelRef, const float gamma) |
Enable the additive MRAC(Model Reference Adaptive Control) feature. | |
float | qPID_Control (qPID_controller_t *const c, const float w, const float y) |
Computes the control action for given PID controller instance. | |
int | qPID_BindAutoTuning (qPID_controller_t *const c, qPID_AutoTuning_t *const at) |
Binds the specified instance to enable the PID controller auto tuning algorithm. | |
int | qPID_EnableAutoTuning (qPID_controller_t *const c, const uint32_t tEnable) |
Set the number of time steps where the auto tuner algorithm will modify the controller gains. | |
int | qPID_AutoTuningComplete (const qPID_controller_t *const c) |
Verifies that the auto tuning process has finished with new gains set on the controller. | |
int | qPID_AutoTuningSetParameters (qPID_controller_t *const c, const float mu, const float alfa, const float lambda) |
Change parameters of the auto-tuning algorithm. | |
int | qPID_SetIntegrationMethod (qPID_controller_t *const c, qNumA_IntegrationMethod_t im) |
Set integration method for the PID controller. | |
bool | qPID_AutoTunningControllerType (qPID_controller_t *c, const qPID_Type_t t) |
API for the qPID Controller library.
For a brief description of this module, please read PID Controller
enum qPID_Direction_t |
enum qPID_Mode_t |
enum qPID_Type_t |
int qPID_AutoTuningComplete | ( | const qPID_controller_t *const | c | ) |
Verifies that the auto tuning process has finished with new gains set on the controller.
[in] | c | A pointer to the PID controller instance. |
int qPID_AutoTuningSetParameters | ( | qPID_controller_t *const | c, |
const float | mu, | ||
const float | alfa, | ||
const float | lambda ) |
Change parameters of the auto-tuning algorithm.
[in] | c | A pointer to the PID controller instance. |
[in] | mu | Algorithm momentum. [ 0 <= alfa <= 1 ]. |
[in] | alfa | Final controller speed adjustment. [ 0 < alfa <= 1 ]. |
[in] | lambda | Algorithm forgetting factor [ 0.8 <= lambda <= 1 ]. |
int qPID_BindAutoTuning | ( | qPID_controller_t *const | c, |
qPID_AutoTuning_t *const | at ) |
Binds the specified instance to enable the PID controller auto tuning algorithm.
NULL
as argument. [in] | c | A pointer to the PID controller instance. |
[in] | at | A pointer to the PID auto tuning instance. |
float qPID_Control | ( | qPID_controller_t *const | c, |
const float | w, | ||
const float | y ) |
Computes the control action for given PID controller instance.
[in] | c | A pointer to the PID controller instance. |
[in] | w | The reference value aka SetPoint. |
[in] | y | The controlled variable aka Process-variable. |
int qPID_EnableAutoTuning | ( | qPID_controller_t *const | c, |
const uint32_t | tEnable ) |
Set the number of time steps where the auto tuner algorithm will modify the controller gains.
[in] | c | A pointer to the PID controller instance. |
[in] | tEnable | The number of time steps. To keep the auto tuner enabled indefinitely pass QPID_AUTOTUNING_UNDEFINED as argument. |
int qPID_Reset | ( | qPID_controller_t *const | c | ) |
Reset the internal PID controller calculations.
[in] | c | A pointer to the PID controller instance. |
int qPID_SetDerivativeFilter | ( | qPID_controller_t *const | c, |
const float | beta ) |
Set the tuning parameter for the derivative filter.
[in] | c | A pointer to the PID controller instance. |
[in] | beta | The tuning parameter. [ 0 < beta < 1 ] |
int qPID_SetDirection | ( | qPID_controller_t *const | c, |
const qPID_Direction_t | d ) |
Set the PID control action direction.
[in] | c | A pointer to the PID controller instance. |
[in] | d | Desired output direction. |
int qPID_SetEpsilon | ( | qPID_controller_t *const | c, |
const float | eps ) |
Set the minimum value considered as error.
[in] | c | A pointer to the PID controller instance. |
[in] | eps | The minimal error value. |
int qPID_SetExtraGains | ( | qPID_controller_t *const | c, |
const float | kw, | ||
const float | kt ) |
Set/Change extra PID controller gains.
[in] | c | A pointer to the PID controller instance. |
[in] | kw | Saturation feedback gain. Used for antiWindup and bumpless transfer. A zero value disables these features. |
[in] | kt | Manual input gain. |
int qPID_SetGains | ( | qPID_controller_t *const | c, |
const float | kc, | ||
const float | ki, | ||
const float | kd ) |
Set/Change the PID controller gains.
[in] | c | A pointer to the PID controller instance. |
[in] | kc | Proportional Gain. |
[in] | ki | Integral Gain. |
[in] | kd | Derivative Gain. |
int qPID_SetIntegrationMethod | ( | qPID_controller_t *const | c, |
qNumA_IntegrationMethod_t | im ) |
Set integration method for the PID controller.
[in] | c | A pointer to the PID controller instance. |
[in] | im | The desired integration method. Use one of the following: |
qNumA_IntegralRe
: Integrate using the Rectangular rule.
qNumA_IntegralTr
: (default) Integrate using the Trapezoidal rule.
qNumA_IntegralSi
: Integrate using the Simpson's 1/3 rule.
int qPID_SetManualInput | ( | qPID_controller_t *const | c, |
const float | manualInput ) |
Set the PID manual input mode. This value will be used as the manual input when the controller it set into the qPID_Manual mode. Bumpless-transfer is guaranteed.
[in] | c | A pointer to the PID controller instance. |
[in] | manualInput | The value of the manual input. |
int qPID_SetMode | ( | qPID_controller_t *const | c, |
const qPID_Mode_t | m ) |
Change the controller operational mode. In qPID_Automatic mode, the computed output of the PID controller will be used as the control signal for the process. In qPID_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 qPID_Automatic mode its performed;.
[in] | c | A pointer to the PID controller instance. |
[in] | m | The desired operational mode. |
int qPID_SetMRAC | ( | qPID_controller_t *const | c, |
const float * | modelRef, | ||
const float | gamma ) |
Enable the additive MRAC(Model Reference Adaptive Control) feature.
[in] | c | A pointer to the PID controller instance. |
[in] | modelRef | A pointer to the output of the model reference. |
[in] | gamma | Adjustable parameter to indicate the adaptation speed. |
int qPID_SetParams | ( | qPID_controller_t *const | c, |
const float | kc, | ||
const float | ti, | ||
const float | td ) |
Set/Change the PID controller gains by using the [Kc, Ti Td ] triplet.
[in] | c | A pointer to the PID controller instance. |
[in] | kc | Proportional Gain. |
[in] | ti | Integral time. |
[in] | td | Derivative time. |
int qPID_SetReferenceWeighting | ( | qPID_controller_t *const | c, |
const float | gb, | ||
const float | gc ) |
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] | c | A pointer to the PID controller instance. |
[in] | gb | The reference weight value for the proportional element. |
[in] | gc | The reference weight value for the derivative element. |
int qPID_SetSaturation | ( | qPID_controller_t *const | c, |
const float | min, | ||
const float | max ) |
Setup the output saturation for the PID controller.
[in] | c | A pointer to the PID controller instance. |
[in] | min | The minimal value allowed for the output. |
[in] | max | The maximal value allowed for the output. |
int qPID_SetSeries | ( | qPID_controller_t *const | c | ) |
Convert the controller gains to conform the series or interacting form.
[in] | c | A pointer to the PID controller instance. |
int qPID_Setup | ( | qPID_controller_t *const | c, |
const float | kc, | ||
const float | ki, | ||
const float | kd, | ||
const float | dt ) |
Setup and initialize the PID controller instance.
[in] | c | A pointer to the PID controller instance. |
[in] | kc | Proportional Gain. |
[in] | ki | Integral Gain. |
[in] | kd | Derivative Gain. |
[in] | dt | Time step in seconds. |