Merged to branch

Dependencies:   USBDevice mbed EquatorStrutController LightWeightSerialTransmit

Fork of EquatorStrutDigitalMonitor by Stewart Coulden-Smith

Revision:
18:ab282713f4a7
Parent:
17:f54cdc9ae52f
Child:
19:a6369257c00f
--- a/main.cpp	Thu Aug 14 09:20:50 2014 +0000
+++ b/main.cpp	Thu Aug 14 14:23:56 2014 +0000
@@ -156,12 +156,22 @@
         pc.putc('-');
         outputValue *= -1.0;
     }
+    if (outputValue >= 1000.0)
+    {
+        outChar = outputValue / 1000;
+        pc.putc(outChar + 48);
+        outputValue -= outChar * 1000.0;
+    }
     if (outputValue >= 100.0)
     {
         outChar = outputValue / 100;
         pc.putc(outChar + 48);
         outputValue -= outChar * 100.0;
     }
+    else if(outChar > 0)
+    {
+        pc.putc('0');
+    }
     if (outputValue >= 10.0)
     {
         outChar = outputValue / 10;
@@ -245,11 +255,11 @@
     
     pc.putc('\t');
     
-    SerialOut(PosKiGain);
+    SerialOut(VelKpGain);
     
-    pc.putc('\t');
+    //pc.putc('\t');
     
-    SerialOut(PosKdGain);
+    //SerialOut(PosKdGain);
     
     pc.putc(10);
     pc.putc(13);
@@ -271,7 +281,7 @@
         
         while (!HallTriggered)
         {
-            wait(0.5);
+            wait(0.1);
         }
     }
     
@@ -289,7 +299,7 @@
     
     while (!HallTriggered)
     {
-        wait(0.5);
+        wait(0.1);
     }
 }
 
@@ -318,7 +328,7 @@
 }
 
 
-double SetPoint = 50.0; //Target Position in Millimeter per second
+double SetPoint = 70.0; //Target Position in Millimeter per second
 
 double PosProError;
 double PosIntError;
@@ -466,28 +476,33 @@
     PosPreviousError[errorcounter]=0;
     
     PreviousTime = RunningTime.read_us();
-    
-    wait(5.0);
 
     while(Enabled)
     {
         //double pow = 0.4;
         //while(pow < 1.0)
-        while(PosKpGain < 1.0)
+        PosKpGain = 10.0;
+        while(PosKpGain < 50.0)
         {
             //pow += 0.05;
-            PosKpGain += 0.01;
-                    
-            float iterationStart = RunningTime.read();
+            PosKpGain += 1.0;
             
-            while(RunningTime.read()-iterationStart < 10.0)
+            VelKpGain = 0.003;
+            while (VelKpGain < 0.008)
             {
-                SerialTransmit();
+                VelKpGain += 0.001;
+                                
+                float iterationStart = RunningTime.read();
                 
-                Controller();
+                while(RunningTime.read()-iterationStart < 10.0)
+                {
+                    SerialTransmit();
+                    
+                    Controller();
+                }
+                
+                Home();
             }
-            
-            Home();
         }
         
         Disable();