Opgeschoonde code voor verslag

Dependencies:   Encoder HIDScope MODSERIAL mbed

Fork of TotalCodegr13V2 by Rianne Bulthuis

Revision:
14:25edcf2935f6
Parent:
13:4f4cc1a5a79a
Child:
15:ece330b45d93
diff -r 4f4cc1a5a79a -r 25edcf2935f6 main.cpp
--- a/main.cpp	Wed Oct 28 14:29:18 2015 +0000
+++ b/main.cpp	Thu Oct 29 22:56:57 2015 +0000
@@ -239,13 +239,13 @@
 
 void move_motor1()
 {
-    if (safety_stop == true && (final_filter1 > 0.02 || button_1 == pressed)) {
+    if (safety_stop == true && (final_filter1 > 0.05 && final_filter2 < 0.02 && final_filter3 < 0.04 && final_filter4 < 0.04)) {
         pc.printf("motor1 cw \n\r");
-        motor1_direction = 0; //counterclockwise
+        motor1_direction = 1; //clockwise
         motor1_speed = 0.1;
-    } else if (safety_stop == true && (final_filter2 > 0.02 || button_2 == pressed)) {
+    } else if (safety_stop == true && (final_filter2 > 0.05 && final_filter1 < 0.02 && final_filter3 < 0.04 && final_filter4 < 0.04)) {
         pc.printf("motor1 ccw \n\r");
-        motor1_direction = 1; //clockwise
+        motor1_direction = 0; //counterclockwise
         motor1_speed = 0.1  ;
     } else {
         pc.printf("Not moving1 \n\r");
@@ -255,11 +255,11 @@
 
 void move_motor2()
 {
-    if (safety_stop == true && (final_filter3 > 0.08 || button_1 == pressed)) {
+    if (safety_stop == true && (final_filter3 > 0.04 && final_filter1 < 0.02 && final_filter2 < 0.02 && final_filter4 < 0.02)) {
         pc.printf("motor2 cw \n\r");
         motor2_direction = 1; //clockwise
         motor2_speed = 0.4;
-    } else if (safety_stop == true && (final_filter4 > 0.08 || button_2 == pressed)) {
+    } else if (safety_stop == true && (final_filter4 > 0.03 && final_filter1 < 0.02 && final_filter2 < 0.02 && final_filter3 < 0.02)) {
         pc.printf("motor2 ccw \n\r");
         motor2_direction = 0; //counterclockwise
         motor2_speed = 0.4;
@@ -325,8 +325,8 @@
     safety_stop = true;
     while (true) {
         pc.baud(9600);                          //pc baud rate van de computer
-        EMG_Filter.attach_us(Filters, 5e4);     //filters uitvoeren
-        Scope.attach_us(HIDScope, 5e4);         //EMG en encoder signaal naar de hidscope sturen
+        EMG_Filter.attach_us(Filters, 5e3);     //filters uitvoeren
+        Scope.attach_us(HIDScope, 5e3);         //EMG en encoder signaal naar de hidscope sturen
 
         switch (state) {                            //zorgt voor het in goede volgorde uitvoeren van de cases