2 Motores + Joystick
Dependencies: X_NUCLEO_IHM01A1 TextLCD
Fork of HelloWorld_IHM01A1_2Motors_mbedOS by
Revision 52:7f80fc02710e, committed 2018-05-21
- Comitter:
- leogrotti
- Date:
- Mon May 21 16:49:53 2018 +0000
- Parent:
- 51:3f0e4e641054
- Child:
- 53:7c56b06e694e
- Commit message:
- corre??o fim de curso
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri May 18 17:44:44 2018 +0000
+++ b/main.cpp Mon May 21 16:49:53 2018 +0000
@@ -284,8 +284,12 @@
zd = eixo_ZD.read();
sp = salva_pos.read();
vc = vai_cami.read();
- if (count == 9999) {
- printf("segurança fim de curso =%i \r\n\n", segu_fim_curso);
+ if (count == 50) {
+ printf("seguranca fim de curso =%i \r\n\n", segu_fim_curso);
+ //printf("w =%f \r\n\n", w);
+ //printf("u =%f \r\n\n", u);
+ wait_ms(DELAY_1);
+
count = 0;
}
@@ -293,47 +297,46 @@
// Movimentando eixo Z cima caso botão 1 apertado
if (zu >0.7) {
motor3->run(StepperMotor::FWD);
- speed3 = motor3->get_speed();
- wait_ms(DELAY_1);
- }
-
- // Parando eixo Z caso botão 1 e 2 liberado
- if (zu< 0.7 && zd < 0.7){
- motor3->hard_stop();
- wait_ms(DELAY_1);
- }
-
-// Movimentando eixo Z baixo caso botão 2 apertado
- if (zd >0.7) {
- motor3->run(StepperMotor::BWD);
- speed3 = motor3->get_speed();
+ printf("Z UP \r\n\n");
wait_ms(DELAY_1);
}
// Parando eixo Z caso botão 1 e 2 liberado
if (zu< 0.7 && zd < 0.7){
motor3->hard_stop();
+ printf("Z PARA \r\n\n");
+ wait_ms(DELAY_1);
+ }
+
+// Movimentando eixo Z baixo caso botão 2 apertado
+ if (zd >0.7) {
+ motor3->run(StepperMotor::BWD);
+ printf("Z DESCE \r\n\n");
+ wait_ms(DELAY_1);
+ }
+
+ // Parando eixo Z caso botão 1 e 2 liberado
+ if (zu< 0.7 && zd < 0.7){
+ motor3->hard_stop();
+ printf("Z PARA \r\n\n");
wait_ms(DELAY_1);
}
-// Movimentando eixo Y duas direções com joystick
- //if (flagY1 == 0 ) {
-
-
+// Movimentando eixo Y duas direções com joystick
// Movimentando eixo Y fwd
if (u>0.820 && !fim_curso_Y) {
motor1->run(StepperMotor::FWD);
- wait_ms(DELAY_1);
Dir_Y = 1;
segu_fim_curso = 1;
+ wait_ms(DELAY_1);
}
// Movimentando eixo Y bwd
else if(u<0.65 && !fim_curso_Y) {
motor1->run(StepperMotor::BWD);
- wait_ms(DELAY_1);
Dir_Y = 0;
segu_fim_curso = 1;
+ wait_ms(DELAY_1);
}
// parando eixo Y
@@ -346,11 +349,13 @@
motor1->move(StepperMotor::BWD, 1000);
motor1->wait_while_active();
segu_fim_curso = 0;
+ wait_ms(DELAY_1);
}
if (Dir_Y == 0){
motor1->move(StepperMotor::FWD, 1000);
motor1->wait_while_active();
segu_fim_curso = 0;
+ wait_ms(DELAY_1);
}
}
}
@@ -360,17 +365,17 @@
// Movimentando eixo X fwd
if (w>0.80 && !fim_curso_X) {
motor2->run(StepperMotor::BWD);
- wait_ms(DELAY_1);
Dir_X = 1;
segu_fim_curso = 1;
+ wait_ms(DELAY_1);
}
// Movimentando eixo X Bwd
else if(w<0.60 && !fim_curso_X) {
motor2->run(StepperMotor::FWD);
- wait_ms(DELAY_1);
Dir_X = 0;
segu_fim_curso = 1;
+ wait_ms(DELAY_1);
}
// parando eixo X
else{
@@ -382,11 +387,13 @@
motor2->move(StepperMotor::FWD, 1000);
motor2->wait_while_active();
segu_fim_curso = 0;
+ wait_ms(DELAY_1);
}
if (Dir_X == 0){
motor2->move(StepperMotor::BWD, 1000);
motor2->wait_while_active();
segu_fim_curso = 0;
+ wait_ms(DELAY_1);
}
}
}
