![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: PID/PID.cpp
- Revision:
- 57:43f707648f2b
- Parent:
- 55:ee5257fb73df
- Child:
- 58:0ef7bb34fe29
--- a/PID/PID.cpp Fri Oct 09 13:06:14 2015 +0000 +++ b/PID/PID.cpp Mon Oct 12 11:46:47 2015 +0200 @@ -33,7 +33,7 @@ // if(timeChange <=SampleTime){ float input = *myInput; error = *mySetpoint - input; // get error for proportional - errSum += error; // Error for integral + ITerm += (ki*error); // Error for integral (with ki included) // check for integrator windup if(errSum> outMax) errSum=outMax; else if(errSum<outMin) errSum=outMin; @@ -41,7 +41,7 @@ // (could still be tuned for derivative kick) // compute PID output - float output = kp * error + ki * errSum + kd * dErr; + float output = kp * error + ITerm + kd * dErr; // make sure output is allso within min/max if(output> outMax) output=outMax; else if(output<outMin) output=outMin; @@ -96,13 +96,9 @@ void PID::Initialize(){ lastInput = *myInput; - errSum = *myOutput; + ITerm = *myOutput; lastErr = 0; if(errSum> outMax) errSum=outMax; else if(errSum<outMin) errSum=outMin; } - -float PID::getOutput(){ - return output; - } \ No newline at end of file