robot

Dependencies:   Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed

Fork of Robot2false by BMT M9 Groep01

Revision:
52:b4af2a4ce38e
Parent:
51:26a2af57b8e9
Child:
53:bdcbf365a9aa
--- a/main.cpp	Sun Nov 02 14:21:30 2014 +0000
+++ b/main.cpp	Sun Nov 02 14:46:03 2014 +0000
@@ -655,34 +655,37 @@
 
 void motor2aansturing()
 {
-    if (positie == 0) {
-        if (motor2.getPosition()>= 0) {
+    switch(positie)
+    {
+        case 0:
+            if (motor2.getPosition()>= 0) {
             motordir2 = 1;
             pwm_motor2.write(PWM2);
-        } else {
-            pwm_motor2.write(0);
-        }
-    }
-    if (positie ==1) {
-        if (motor2.getPosition()>= 2) {
+            } else {
+                pwm_motor2.write(0);
+            }
+            break;
+        case 1:
+            if (motor2.getPosition()>= 2) {
             motordir2 = 1;
             pwm_motor2.write(PWM2);
-        }
-        if (motor2.getPosition()<= 2) {
+            }
+            if (motor2.getPosition()<= 2) {
+                motordir2 = 0;
+                pwm_motor2.write(PWM2);
+            } else {
+                pwm_motor2.write(0);
+            }
+            break;
+        case 2:
+            if (motor2.getPosition()<= 4) {
             motordir2 = 0;
             pwm_motor2.write(PWM2);
-        } else {
-            pwm_motor2.write(0);
-        }
+            } else {
+                pwm_motor2.write(0);
+            }
+            break;
     }
-    if (positie ==2) {
-        if (motor2.getPosition()<= 4) {
-            motordir2 = 0;
-            pwm_motor2.write(PWM2);
-        } else {
-            pwm_motor2.write(0);
-        }
-    } //end if
 }
 
 void motor1aansturing()
@@ -725,7 +728,7 @@
                 }//end switch
             } //end if
             break;
-        case TERUGKEREN:
+        /*case TERUGKEREN:
             if (motor1.getPosition()<=ANGLEMAX) {
                 new_pwmpos = pidpositie(ANGLEMAX, motor1.getPosition());
                 pwm_motor1.write(new_pwmpos); //mogelijk moet dit -new_pwm zijn???
@@ -735,7 +738,7 @@
                 new_pwmpos = pidpositie(ANGLEMAX, motor1.getPosition());
                 pwm_motor1.write(new_pwmpos); //mogelijk moet dit -new_pwm zijn???
                 motordir1 = 1;
-            }
+            }*///overbodig!!! 
             break;
     } //end switch
     scope.set(0,motor1.getPosition());