File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -68,16 +68,19 @@ bool PID::Compute()
68
68
else if (outputTemp < outMin) outputTemp = outMin;
69
69
70
70
/* Add Proportional on Error, if P_ON_E is specified*/
71
+ double output; /* i'm also not sure why the original author made another variable
72
+ , but i believe it may be impactful so I'm reverting the prev change to eliminate this */
71
73
if (pOnE) outputTemp += kp * error;
74
+ else output = 0 ;
72
75
73
76
/* Compute Rest of PID Output*/
74
- outputTemp -= kddT * dInput;
77
+ output += outputTemp - kddT * dInput;
75
78
76
79
/* filter output again */
77
- if (outputTemp > outMax) outputTemp = outMax;
78
- else if (outputTemp < outMin) outputTemp = outMin;
80
+ if (output > outMax) output = outMax;
81
+ else if (output < outMin) output = outMin;
79
82
80
- *myOutput = outputTemp ;
83
+ *myOutput = output ;
81
84
82
85
return true ;
83
86
}
You can’t perform that action at this time.
0 commit comments