Operation Mode State Machine plus homing for StateMachinePTR

Dependencies:   MODSERIAL QEI biquadFilter mbed

Fork of Controller by Sven van Wincoop

Revision:
14:771cd444764b
Parent:
13:9125d359619c
Child:
15:97311058e012
--- a/OperationMode.cpp	Thu Nov 01 08:23:55 2018 +0000
+++ b/OperationMode.cpp	Thu Nov 01 09:26:12 2018 +0000
@@ -36,8 +36,6 @@
 
 void OperationStateMachine()
 {
-
-
     switch (CurrentOperationState) {
         case OPWait:
             LedRed = 0; //red
@@ -73,7 +71,7 @@
             if (PositionRef < 0.48*(6.380)) { //counts/8400 *2 because encoder X2 -> X4
                 PositionRef += 0.0005*(6.380);
             }
-            if ((PositionRef > 0.48*(6.380)) && (TimerLoop >= 4.0)) {
+            if ((PositionRef > 0.48*(6.380)) && (TimerLoop >= 2.0)) {
                 CurrentOperationState = OPState2;
                 TimerLoop.reset();
             }
@@ -86,7 +84,7 @@
             if (PositionRef2 > -1.133*(6.380)) {
                 PositionRef2 -= 0.0005*(6.380);
             }
-            if ((PositionRef2 < -1.133*(6.380)) && (TimerLoop >= 4.0)) {
+            if ((PositionRef2 < -1.133*(6.380)) && (TimerLoop >= 2.0)) {
                 CurrentOperationState = OPState3;
                 TimerLoop.reset();
             }
@@ -100,9 +98,9 @@
                 PositionRef -= 0.0005*(6.380);
             }
             if (PositionRef2 > -1.483*(6.380)) {
-                PositionRef2 -= 0.0002*(6.380);
+                PositionRef2 -= 0.0003*(6.380);
             }
-            if ((PositionRef < -0.15*(6.380)) && (PositionRef2 < -1.483*(6.380)) && (TimerLoop >= 4.0)) {
+            if ((PositionRef < -0.15*(6.380)) && (PositionRef2 < -1.483*(6.380)) && (TimerLoop >= 3.0)) {
                 CurrentOperationState = OPState4;
                 TimerLoop.reset();
             }
@@ -115,7 +113,7 @@
             if (PositionRef2 > -2.133*(6.380)) {
                 PositionRef2 -= 0.005*(6.380);
             }
-            if ((PositionRef2 < -2.133*(6.380)) && (TimerLoop > 4)) {
+            if ((PositionRef2 < -2.133*(6.380)) && (TimerLoop > 0.5)) {
                 TimerLoop.reset();
                 CurrentOperationState = OPHoming;
             }
@@ -131,7 +129,7 @@
             if (PositionRef2 < -0.733*(6.380)) {
                 PositionRef2 += 0.001*(6.380);
             }
-            if ((PositionRef > 0) && (PositionRef2 > -0.733*(6.380)) && (TimerLoop > 4)) {
+            if ((PositionRef > 0) && (PositionRef2 > -0.733*(6.380)) && (TimerLoop > 3)) {
                 CurrentOperationState = OPWait;
             }
             break;