Update PID_v1.cpp
corrects possible errors in larger projects.
This commit is contained in:
parent
9b4ca0e5b6
commit
3936ba4947
@ -65,8 +65,8 @@ bool PID::Compute()
|
|||||||
/*Compute all the working error variables*/
|
/*Compute all the working error variables*/
|
||||||
double input = *myInput;
|
double input = *myInput;
|
||||||
double error = *mySetpoint - input;
|
double error = *mySetpoint - input;
|
||||||
double dInput = (input - lastInput);
|
double dInput = 1000*(input - lastInput)/timechange;
|
||||||
outputSum+= (ki * error);
|
outputSum+= 1000*(ki * error)/timechange;
|
||||||
|
|
||||||
/*Add Proportional on Measurement, if P_ON_M is specified*/
|
/*Add Proportional on Measurement, if P_ON_M is specified*/
|
||||||
if(!pOnE) outputSum-= kp * dInput;
|
if(!pOnE) outputSum-= kp * dInput;
|
||||||
|
Loading…
Reference in New Issue
Block a user