Projectgroep 20 Biorobotics / Mbed 2 deprecated DEMO_en_autodemo

Dependencies:   Encoder MODSERIAL mbed

Fork of DEMO by Annelotte Bex

Revision:
3:120fbef23c17
Parent:
2:9f343567723c
Child:
4:836d7f9ac0ca
--- a/main.cpp	Thu Nov 02 09:43:40 2017 +0000
+++ b/main.cpp	Thu Nov 02 10:00:46 2017 +0000
@@ -26,8 +26,8 @@
 double pi = 3.14159265359;
 double SetPx = 38;     //Setpoint position x-coordinate from changePosition (EMG dependent)
 double SetPy = 30;     //Setpoint position y-coordinate from changePosition (EMG dependent)
-volatile double q1 = 0;          //Reference position q1 from calibration (only the first time)
-volatile double q2 = (pi/2);       //Reference position q2 from calibration (only the first time)
+double q1 = 0;          //Reference position q1 from calibration (only the first time)
+double q2 = (pi/2);       //Reference position q2 from calibration (only the first time)
 const double L1 = 30;  //Length arm 1
 const double L2 = 38;  //Length arm 2
 double K = 1;           //Spring constant for movement end-joint to setpoint
@@ -80,15 +80,19 @@
     if (Potmeterwaarde2>0.6) {
         SetPx++;    // hoe veel verder gaat hij? 1 cm? 10 cm?
     }
-    if (Potmeterwaarde2<0.4) {
+    else if (Potmeterwaarde2<0.4) {
         SetPx--;
     }
+    else
+    {}
     if (Potmeterwaarde1>0.6) {
         SetPy++;
     }
-    if (Potmeterwaarde1<0.4) {
+    else if (Potmeterwaarde1<0.4) {
         SetPy--;
     }
+    else
+    {}
     //pc.printf("Setpointx = %f, Setpointy = %f \r\n", SetPx, SetPy);
 }