Arun Raveenthiran / Mbed 2 deprecated home_position_control

Dependencies:   Encoder HIDScope mbed

Files at this revision

API Documentation at this revision

Comitter:
arunr
Date:
Wed Oct 21 11:49:33 2015 +0000
Parent:
0:239a6daf84e4
Commit message:
home position werkt nauwkeurig;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 20 11:46:31 2015 +0000
+++ b/main.cpp	Wed Oct 21 11:49:33 2015 +0000
@@ -65,29 +65,31 @@
 
 void move_motor1_ccw (){
     motor1_direction = 0;
-    motor1_speed = 0.1;
+    motor1_speed = 1;
 }
 
 void move_motor1_cw (){
     motor1_direction = 1;
-    motor1_speed = 0.1;
+    motor1_speed = 1;
 }
 
 void movetohome(){
     P = motor1.getPosition();
-    D = (P - H);
- 
-    if (D >= -48 && D <= 48){
+    
+    if (P >= -28 && P <= 28){
         motor1_speed = 0;
     }
-    else if (D > 60){
-        move_motor1_cw();
+    else if (P > 24){
+        motor1_direction = 1;
+        motor1_speed = 0.1;
     }
-    else if (D < -60){
-        move_motor1_ccw();
+    else if (P < -24){
+        motor1_direction = 0;
+        motor1_speed = 0.1;
     }
 }
 
+
 void move_motor1(){
     P = motor1.getPosition();
     D = (P - H);