PID controller library.
More...
#include <PID.h>
|
| PID (float kp, float ki, float kd, float max_output, float alpha) |
| Initializes the PID class with necessary parameters.
|
|
void | updateReferenceValue (float ref) |
| Sets the reference value.
|
|
void | setKp (float kp) |
| Sets the proportional gain.
|
|
void | setKi (float ki) |
| Sets the integrative gain.
|
|
void | setKd (float kd) |
| Sets the derivative gain.
|
|
float | getOutput () |
| Gets output computed from the last iteration of calculate()
|
|
float | getReferenceValue () |
| Gets the currently used reference value.
|
|
void | calculate () |
| Main PID routine.
|
|
void | updateFeedback (float fb) |
| Updates the feedback for PID computation.
|
|
void | resetState () |
| Resets the PID state, as if it was the first iteration.
|
|
◆ PID()
PID::PID |
( |
float |
kp, |
|
|
float |
ki, |
|
|
float |
kd, |
|
|
float |
max_output, |
|
|
float |
alpha |
|
) |
| |
Initializes the PID class with necessary parameters.
- Parameters
-
kp | Proportional gain. |
ki | Integrative gain. |
kd | Derivative gain. |
max_output | To define the range of the output, from -max_output to max_output. |
alpha | Error filte, 1 to disable filtering. |
◆ calculate()
Main PID routine.
Should be executed at a fixed frequency, which will influence the behaviour for a given set of gains.
◆ getOutput()
Gets output computed from the last iteration of calculate()
- Returns
- float Output value of the PID controller.
◆ getReferenceValue()
float PID::getReferenceValue |
( |
| ) |
|
Gets the currently used reference value.
- Returns
- float The currently set reference value.
◆ resetState()
Resets the PID state, as if it was the first iteration.
◆ setKd()
void PID::setKd |
( |
float |
kd | ) |
|
Sets the derivative gain.
- Parameters
-
kd | Value of the derivative gain. |
◆ setKi()
void PID::setKi |
( |
float |
ki | ) |
|
Sets the integrative gain.
- Parameters
-
ki | Value of the integrative gain. |
◆ setKp()
void PID::setKp |
( |
float |
kp | ) |
|
Sets the proportional gain.
- Parameters
-
kp | Value of the proportional gain. |
◆ updateFeedback()
void PID::updateFeedback |
( |
float |
fb | ) |
|
Updates the feedback for PID computation.
- Parameters
-
◆ updateReferenceValue()
void PID::updateReferenceValue |
( |
float |
ref | ) |
|
Sets the reference value.
- Parameters
-
ref | Reference value for the PID. |
The documentation for this class was generated from the following files: