This is probably never gonna get done

Dependencies:   Crypto

Files at this revision

API Documentation at this revision

Comitter:
Olaffo
Date:
Fri Mar 22 12:24:17 2019 +0000
Parent:
26:d3e69e507616
Child:
28:613a88b88074
Commit message:
tightest speed control so far, no overshooting, but slow approach

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 21 17:15:02 2019 +0000
+++ b/main.cpp	Fri Mar 22 12:24:17 2019 +0000
@@ -452,8 +452,8 @@
     float Rev;
     int8_t leads = -2;
     int8_t leadr = -2;
-    float kps = 25;
-    float kis = 0.07;
+    float kps = 27;
+    float kis = 0.2;
     float kpr = 35;
     float kdr = 14.75; //proportional constant for speed
     // Timer to count time passed between ticks to calculate velocity
@@ -479,8 +479,11 @@
         
         //equation for controls
         sError = Speed -abs(motorVelocity);
-        if (motorVelocity != 0){
-            intError = intError + sError;
+        if ((motorVelocity != 0) && (abs(sError)<560)){
+            intError = intError + sError;  
+            if (abs(intError*kis)>2000) {
+                intError = intError - sError;
+            }
         }
         Ts = (kps * sError + kis * intError)*(error/abs(error));
         Tr = kpr*error+kdr*(error-olderror)/ myTime;