Sven van Wincoop / Mbed 2 deprecated Controller

Dependencies:   MODSERIAL QEI biquadFilter mbed

Fork of Controller by Ruben Lucas

Revision:
9:34e3dd8548c0
Parent:
8:0ed8609252d3
--- a/main.cpp	Fri Oct 26 10:57:25 2018 +0000
+++ b/main.cpp	Mon Oct 29 12:12:18 2018 +0000
@@ -43,7 +43,7 @@
     {
         if (PositionRef <= 0.4*(6.2830))
         {
-            PositionRef += 0.0005*(6.2830);
+            PositionRef += 0.001*(6.2830);
         }
     }
     
@@ -51,7 +51,7 @@
     {
         if (PositionRef >= -0.4*(6.2830))
         {
-            PositionRef -= 0.0005*(6.2830);
+            PositionRef -= 0.001*(6.2830);
         }
     }
     }
@@ -59,12 +59,12 @@
     {
             if (PositionRef <= 0)
             {
-                PositionRef += 0.0005*(6.2830);
+                PositionRef += 0.001*(6.2830);
             }
         
             if (PositionRef >= 0)
             {
-                PositionRef -= 0.0005*(6.2830);
+                PositionRef -= 0.001*(6.2830);
             }
     }
    // double ValuePot = Potmeter1.read(); // Read value from potmeter (range from 0-1)
@@ -91,11 +91,18 @@
 ///The controller
 double PID_Controller(double Error)
 {
-
+    //Belt drive parameters
    double Ts = 0.01; //Sampling time 100 Hz
-   double Kp = 3.7; // proportional gain
-   double Ki = 5;
-   double Kd = 2.8; //integral gain ranging from 0-20.
+   double Kp = 11.1; // proportional gain
+   double Ki = 11.2; //Integral gain
+   double Kd = 5.5; //Differential gain
+   
+   //Arm drive parameters
+   //double Ts = 0.01; //Sampling time 100 Hz
+   //double Kp = 19.8; // proportional gain
+   //double Ki = 19.9; //Intergral gain
+   //double Kd = 9.8; //Differential gain.
+   
    static double ErrorIntegral = 0;
    static double ErrorPrevious = Error;
    static BiQuad LowPassFilter(0.0640, 0.1279, 0.0640, -1.1683, 0.4241);