21 #ifndef _PID_CONTROLLER_H_
22 #define _PID_CONTROLLER_H_
51 long steadyStateCount;
72 long PValue,
long IValue,
long DValue,
73 int steadyStateCountThreshold,
74 long outputGain,
long absMaxOutput)
77 pidControl.
PValue = PValue;
78 pidControl.
IValue = IValue;
79 pidControl.
DValue = DValue;
87 pidControl.steadyStateCount = 0;
107 pidControl.steadyStateCount = 0;
144 long P, I, D, error, output;
149 error = pidControl.
setPoint - currentPoint;
153 pidControl.steadyStateCount++;
long PIDControlStep(PIDControl &pidControl, long currentPoint)
Steps the PID controller. currentPoint is the current state of the system. The return value is the ou...
int steadyStateCountThreshold
void PIDControlInit(PIDControl &pidControl, long PIDScale, long PValue, long IValue, long DValue, int steadyStateCountThreshold, long outputGain, long absMaxOutput)
Initializes a PID controller with the given P, I and D values, output parameters. ...
bool PIDControlCheckEnd(PIDControl &pidControl)
Checks if the PID controller has ended.
void PIDControlSetIntegralLimit(PIDControl &pidControl, long absIntegralLimit)
Sets integral output absolute maximum used to prevent integral windup. The default is set to absMaxOu...
void PIDControlSetPoint(PIDControl &pidControl, long setPoint)
Sets a new set point for the controller. The controller state is reset and the new target is pursued...
long PIDControlGetLastError(PIDControl &pidControl)
Gets the error from the last step.