homing
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:555373c1b9be
- Parent:
- 0:49f7a745f758
- Child:
- 2:ff77628098e4
--- a/main.cpp Thu Nov 01 10:23:33 2018 +0000 +++ b/main.cpp Thu Nov 01 10:34:03 2018 +0000 @@ -4,29 +4,40 @@ double rotation_end_position=1; double tower_1_position=1; double tower_end_position=1; -const int revcount = 25*8400; +const int revcounts = 25*8400; +int counts1=1; +int counts2=1; // -void home(){ +void translation_start(int a,int b){} +void translation_stop(){} +void rotation_start(int a, int b){} +void rotation_stop(){} +int main(){ //translation home - if (counts2 > ((tower_end_position - tower_1_position)/2){ + if (counts2 > ((tower_end_position - tower_1_position)/2)){ translation_start(0,1); } else { translation_start(1,1); } - if (counts2 > ((tower_end_position - tower_1_position)/2 - 100){ - if (counts2 < ((tower_end_position - tower_1_position)/2 + 100){ - translation_stop() + if (counts2 > ((tower_end_position - tower_1_position)/2 - 100)){ + if (counts2 < ((tower_end_position - tower_1_position)/2 + 100)){ + translation_stop(); } else{} } else{} //rotation home - rotation_start(); - if ((counts1 - (revcount * (counts1 / revcounts))) > (rotation_end_position - 100)){ //check if motor 1 is in the right position within 100 counts range - if ((counts1 - (revcount * (counts1 / revcounts))) < (rotation_end_position + 100)){ + if ((counts1 - (revcounts * (counts1 / revcounts))) > (rotation_end_position)){ + rotation_start(0,1); + } + else{ + rotation_start(1,1); + } + if ((counts1 - (revcounts * (counts1 / revcounts))) > (rotation_end_position - 100)){ //check if motor 1 is in the right position within 100 counts range + if ((counts1 - (revcounts * (counts1 / revcounts))) < (rotation_end_position + 100)){ rotation_stop(); } else {}