![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Implements a proportional-integral-derivative (PID) controller. More...
#include <PID.h>
Public Member Functions | |
PID () | |
Default constructor for PID , initializes gains to zero. | |
PID (float kp, float ki, float kd) | |
Constructs a PID controller with specified gains. | |
~PID () | |
Destructor for PID . | |
float | Calculate (float setpoint, float processVariable, unsigned long currentMillis) |
Calculates the control output based on the setpoint and process variable. | |
float | Calculate (float setpoint, float processVariable, float dT) |
Calculates the control output based on the setpoint and process variable. | |
Private Attributes | |
float | integral |
Integral term accumulator. | |
float | error |
Current error value. | |
float | previousError |
Previous error value for derivative calculation. | |
float | output |
Calculated output value. | |
float | kp |
Proportional gain. | |
float | ki |
Integral gain. | |
float | kd |
Derivative gain. | |
float | previousSeconds |
Time of the previous calculation in seconds. | |
Implements a proportional-integral-derivative (PID) controller.
This class calculates control outputs based on the error between a setpoint and a process variable, using configurable proportional, integral, and derivative gains.
PID | ( | ) |
Calculates the control output based on the setpoint and process variable.
This method requires the caller to provide the time delta in seconds since the last calculation.
setpoint | Desired target value. |
processVariable | Current value of the process variable. |
dT | Time delta in seconds since the last calculation. |
Definition at line 46 of file PID.cpp.
References error, integral, kd, ki, kp, output, and previousError.
Calculates the control output based on the setpoint and process variable.
This method uses the elapsed time in milliseconds since the last call to calculate the derivative term.
setpoint | Desired target value. |
processVariable | Current value of the process variable. |
currentMillis | Current time in milliseconds. |
Definition at line 25 of file PID.cpp.
References error, integral, kd, ki, kp, output, previousError, and previousSeconds.
|
private |
Current error value.
Definition at line 25 of file PID.h.
Referenced by Calculate(), and Calculate().
|
private |
Integral term accumulator.
Definition at line 24 of file PID.h.
Referenced by Calculate(), and Calculate().
|
private |
|
private |
|
private |
|
private |
Calculated output value.
Definition at line 27 of file PID.h.
Referenced by Calculate(), and Calculate().
|
private |
Previous error value for derivative calculation.
Definition at line 26 of file PID.h.
Referenced by Calculate(), and Calculate().
|
private |
Time of the previous calculation in seconds.
Definition at line 31 of file PID.h.
Referenced by Calculate().