Eduard Medla / PID

Dependents:   Autonomous_quadcopter

Fork of PID by Aaron Berk

Revision:
5:9bc7a51e97ba
Parent:
4:3f9903757639
Child:
6:02717c0e74ce
diff -r 3f9903757639 -r 9bc7a51e97ba PID.cpp
--- a/PID.cpp	Sun Mar 25 10:07:32 2018 +0000
+++ b/PID.cpp	Sun Mar 25 12:56:26 2018 +0000
@@ -210,8 +210,10 @@
 }
 
 void PID::setSetPoint(float sp) {
-    if(stabelized_ == true)
+    if(stabelized_ == true){
+        tauR_ = firstTauR_;
         stabelized_ = false;
+    }
     setPoint_ = sp;
 
 }
@@ -249,11 +251,12 @@
     }
 
     float error = scaledSP - scaledPV;
-    if(error < 0.05 && error > -0.05){
+    if(error < 0.005 && error > -0.001){
         error = 0;
         if(stabelized_ == false){
+            printf("stabelized \n\r");
             stabelized_ = true;
-            float newTauR = 0.0005;
+            float newTauR = 0.02;
             float newError = (accError_ * tauR_) / newTauR;
             accError_ = newError;
             tauR_ = newTauR;