Arun Raveenthiran / Mbed 2 deprecated VerslagCode

Dependencies:   Encoder HIDScope MODSERIAL mbed

Fork of TotalCodegr13V2 by Rianne Bulthuis

Files at this revision

API Documentation at this revision

Comitter:
arunr
Date:
Mon Nov 02 14:24:46 2015 +0000
Parent:
16:bf76ed65da88
Child:
18:60251896da8d
Commit message:
Move to home opgesplitst in 2 functies voor m1 en m2. Werkt nu voor beide motoren.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Nov 02 14:06:12 2015 +0000
+++ b/main.cpp	Mon Nov 02 14:24:46 2015 +0000
@@ -227,12 +227,11 @@
    
 }
 
-void movetohome()
+void movetohome1()
 {
     P1 = motor1.getPosition();
-    P2 = motor2.getPosition();
 
-    if ((P1 >= -28 && P1 <= 28) || (P2 >= -28 && P2 <= 28)) {
+    if ((P1 > -25 && P1 < 25)) {
         motor1_speed = 0;
     } else if (P1 > 24) {
         motor1_direction = 1;
@@ -240,11 +239,19 @@
     } else if (P1 < -24) {
         motor1_direction = 0;
         motor1_speed = 0.1;
-    } else if (P2 > 24) {
-        motor2_direction = 1;
+    } 
+}
+
+void movetohome2()
+{
+    P2 = motor2.getPosition();
+    if (P2 > -25 && P2 < 25){
+        motor2_speed = 0;
+    }else if (P2 > 24) {
+        motor2_direction = 0;
         motor2_speed = 0.1;
     } else if (P2 < -24) {
-        motor2_direction = 0;
+        motor2_direction = 1;
         motor2_speed = 0.1;
     }
 }
@@ -303,7 +310,8 @@
 
                 ticker_regelaar.attach(setregelaar_ticker_flag, SAMPLETIME_REGELAAR);
                 while(state == BACKTOHOMEPOSITION) {
-                    movetohome();
+                    movetohome1();
+                    movetohome2();
                     while(regelaar_ticker_flag != true);
                     regelaar_ticker_flag = false;