23:00

Dependencies:   biquadFilter MODSERIAL QEI Servo mbed

Fork of StateMachine_EMg_RKI_PID_MOTOR_DEMO_CLICK by Gaston Gabriël

Revision:
16:438b330f5312
Parent:
15:6ad7abc5c691
--- a/main.cpp	Thu Nov 01 21:23:12 2018 +0000
+++ b/main.cpp	Thu Nov 01 22:00:34 2018 +0000
@@ -130,7 +130,7 @@
 int EMGymin ;
 
 // Dit moet experimenteel geperfectioneerd worden
-float tijdstap = 0.005;      //nu wss heel langzaam, kan miss omhoog KEER V GEEFT VERANDERING IN POSITIE
+float tijdstap = 0.001;      //nu wss heel langzaam, kan miss omhoog KEER V GEEFT VERANDERING IN POSITIE
 float v = 0.1;                // snelheid kan wss ook hoger
 
 float px = 0.2;     //starting x    // BOUNDARIES
@@ -317,42 +317,44 @@
 
 void demomodus()
 {
-    if(t==2) {
-        px = px1;
-        py = py1;
-    } else if(t==4) {
-        px = px2;
-        py = py2;
-    } else if(t==6) {
-        px = px3;
-        py = py3;
-    } else if(t==8) {
-        px = px1;
-        py = py1;
-    } else if(t==10) {
-        px = px5;
-        py = py5;
-    } else if(t==12) {
-        px = px6;
-        py = py6;
-    } else if(t==14) {
-        px = px1;
-        py = py1;
-    } else if(t==16) {
-        px = px3;
-        py = py3;
-    } else if(t==18) {
-        px = px5;
-        py = py5;
-    } else if(t==20) {
-        px = px2;
-        py = py2;
-    } else if(t==22) {
-        px = px6;
-        py = py6;
-    } else if(t==24) {
-        px = px1;
-        py = py1;
+    while(t<48) {
+        if(t>=0 && t<4) {
+            px = px1;
+            py = py1;
+        } else if(t>=4 && t<8) {
+            px = px2;
+            py = py2;
+        } else if(t>=8 && t<12) {
+            px = px3;
+            py = py3;
+        } else if(t>=12 && t<16) {
+            px = px1;
+            py = py1;
+        } else if(t>=16 & t<20) {
+            px = px5;
+            py = py5;
+        } else if(t>=20 && t<24) {
+            px = px6;
+            py = py6;
+        } else if(t>=24 && t<28) {
+            px = px1;
+            py = py1;
+        } else if(t>=28 && t<32) {
+            px = px3;
+            py = py3;
+        } else if(t>=32 && t<36) {
+            px = px5;
+            py = py5;
+        } else if(t>=36 && t<40) {
+            px = px2;
+            py = py2;
+        } else if(t>=40 && t<44) {
+            px = px6;
+            py = py6;
+        } else if(t>=44 && t<48) {
+            px = px1;
+            py = py1;
+        }
     }
 
 }
@@ -646,13 +648,12 @@
                 led1 = 0;
                 led2 = 1;
                 led3 = 0;
-                wait (1);
+                wait(1);
                 t.reset();
                 t.start();
                 demomodus();
-                    if(t>=26) {
-                    t.stop();
-                }
+                t.stop();
+
                 stateChanged = false;
             }
 
@@ -671,14 +672,14 @@
                 led1 = 1;
                 led2 = 0;
                 led3 = 0;
-                wait(2);
+                wait(0.5);
 
                 movement_ticker_activator();
 
                 led1 = 0;
                 led2 = 0;
                 led3 = 0;
-                wait(2);
+                wait(0.5);
 
 
                 stateChanged = false;
@@ -759,6 +760,7 @@
                 led1 = 1;
                 led2 = 1;
                 led3 = 0;
+                wait(1);
                 for(float p=1; p>0; p -= 0.1) {
                     myservo = p;
                     wait(0.1);