Backcalculate per Astrom 1989 and http://brettbeauregard.com/blog/2011/04/improving-the-beginner%e2%80%99s-pid-reset-windup/#comment-18721
This commit is contained in:
parent
9b4ca0e5b6
commit
a0eb0d6d82
12
PID_v1.cpp
12
PID_v1.cpp
@ -82,9 +82,15 @@ bool PID::Compute()
|
|||||||
/*Compute Rest of PID Output*/
|
/*Compute Rest of PID Output*/
|
||||||
output += outputSum - kd * dInput;
|
output += outputSum - kd * dInput;
|
||||||
|
|
||||||
if(output > outMax) output = outMax;
|
if(output > outMax){
|
||||||
else if(output < outMin) output = outMin;
|
outputSum -= output - outMax; // backcalculate integral to feasability
|
||||||
*myOutput = output;
|
output = outMax;
|
||||||
|
}
|
||||||
|
else if(output < outMin) {
|
||||||
|
outputSum += outMin - output; // backcalculate integral to feasability
|
||||||
|
output = outMin;
|
||||||
|
}
|
||||||
|
*myOutput = output;
|
||||||
|
|
||||||
/*Remember some variables for next time*/
|
/*Remember some variables for next time*/
|
||||||
lastInput = input;
|
lastInput = input;
|
||||||
|
Loading…
Reference in New Issue
Block a user