8000 going back to output def thing lol · br3ttb/Arduino-PID-Library@9515d2c · GitHub
[go: up one dir, main page]

Skip to content

Commit 9515d2c

Browse files
committed
going back to output def thing lol
1 parent e023923 commit 9515d2c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

PID_v1.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,19 @@ bool PID::Compute()
6868
else if (outputTemp < outMin) outputTemp = outMin;
6969

7070
/*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 */
7173
if (pOnE) outputTemp += kp * error;
74+
else output = 0;
7275

7376
/* Compute Rest of PID Output*/
74-
outputTemp -= kddT * dInput;
77+
output += outputTemp - kddT * dInput;
7578

7679
/* 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;
7982

80-
*myOutput = outputTemp;
83+
*myOutput = output;
8184

8285
return true;
8386
}

0 commit comments

Comments
 (0)
0