from greg

Fork of PID by Greg Abdo

Files at this revision

API Documentation at this revision

Comitter:
oprospero
Date:
Sat Sep 28 21:45:05 2013 +0000
Parent:
5:43a44c2880a3
Child:
7:1b1c2ded95f5
Commit message:
no changes

Changed in this revision

PID.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/PID.cpp	Thu Sep 26 05:18:54 2013 +0000
+++ b/PID.cpp	Sat Sep 28 21:45:05 2013 +0000
@@ -35,7 +35,7 @@
     currentError += targetPosition - currentPosition;
 
     // Sum of the errors the controller has incurred over time
-    integralError = currentError;
+    integralError += currentError;
     // Cap the sum of errors to prevent excessive correction
     if (integralError < -windupGainGuard) {
         integralError = -windupGainGuard;
@@ -45,16 +45,7 @@
     
     
     float currentderivativeError = (currentError - previousError);
-//    if(currentderivativeError > 0 && currentError > 0){
-//        errorTrim += currentderivativeError * 0.001; 
-//    }else if (currentderivativeError < 0 && currentError < 0){
-//        errorTrim += currentderivativeError * 0.001; 
-//    }
-//    
-//    currentError += errorTrim;
-    
-    
-    
+
     // Calculate the correction, based on the tuning values
     proportionalControl = proportionalGain * currentError;
     integralControl = integralError * integralGain;