2 Motores + Joystick
Dependencies: X_NUCLEO_IHM01A1 TextLCD
Fork of HelloWorld_IHM01A1_2Motors_mbedOS by
Revision 36:0cd4fdbb40af, committed 2018-04-25
- Comitter:
- leogrotti
- Date:
- Wed Apr 25 14:26:35 2018 +0000
- Parent:
- 35:a05bef8dd995
- Child:
- 37:d5d1468f1dd2
- Commit message:
- 2 motores+joystick +motores configurados;
Changed in this revision
| X_NUCLEO_IHM01A1.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/X_NUCLEO_IHM01A1.lib Tue Apr 24 15:09:16 2018 +0000 +++ b/X_NUCLEO_IHM01A1.lib Wed Apr 25 14:26:35 2018 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#974ca699c792 +https://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#a3d9b5f641e7
--- a/main.cpp Tue Apr 24 15:09:16 2018 +0000
+++ b/main.cpp Wed Apr 25 14:26:35 2018 +0000
@@ -107,6 +107,8 @@
float w;
float u;
+float a;
+
unsigned int minspeed = 1300;
@@ -115,11 +117,15 @@
unsigned int speed1;
unsigned int speed2;
+unsigned int speed3;
+
+unsigned int pos3;
/* Motor Control Component. */
L6474 *motor1;
L6474 *motor2;
+L6474 *motor3;
/* Main ----------------------------------------------------------------------*/
@@ -134,12 +140,16 @@
/* Initializing Motor Control Components. */
motor1 = new L6474(D2, D8, D7, D9, D10, dev_spi);
motor2 = new L6474(D2, D8, D4, D3, D10, dev_spi);
+ motor3 = new L6474(D2, D8, D5, D6, D10, dev_spi);
if (motor1->init() != COMPONENT_OK) {
exit(EXIT_FAILURE);
}
if (motor2->init() != COMPONENT_OK) {
exit(EXIT_FAILURE);
}
+ if (motor3->init() != COMPONENT_OK) {
+ exit(EXIT_FAILURE);
+ }
@@ -147,7 +157,15 @@
motor2->set_acceleration(160);
motor1->set_max_speed(speed1);
motor2->set_max_speed(speed2);*/
+
+
+
+//motor1->set_min_speed(1300);
+//motor2->set_min_speed(1300);
+
+//motor1->set_parameter(L6474_STEP_MODE,L6474_STEP_SEL_1_2);
+//motor2->set_parameter(L6474_STEP_MODE,L6474_STEP_SEL_1_2);
while(true) {
u = eixo_X.read();
@@ -156,17 +174,16 @@
// wait (1.5);
// pc.printf ("X: %f \r\n",u);
// pc.printf ("Y: %f \r\n",w);
-
-
+
if (u>0.740) {
motor1->run(StepperMotor::FWD);
speed1 = motor1->get_speed();
- printf("speed1 =%d \r\n\n", speed1);
- printf("U =%f \r\n\n", u);
+ //printf("speed1 =%d \r\n\n", speed1);
+ //printf("U =%f \r\n\n", u);
}
else{ if(u<0.65) {
@@ -174,17 +191,17 @@
motor1->run(StepperMotor::BWD);
speed1 = motor1->get_speed();
- printf("speed1 =%d \r\n\n", speed1);
+ //printf("speed1 =%d \r\n\n", speed1);
- printf("U =%f \r\n\n", u);
+ // printf("U =%f \r\n\n", u);
}
else
motor1->hard_stop();
speed1 = 0;
- printf("speed1 =%d \r\n\n", speed1);
+ //printf("speed1 =%d \r\n\n", speed1);
- printf("U =%f \r\n\n", u);
+ // printf("U =%f \r\n\n", u);
}
@@ -193,8 +210,8 @@
motor2->run(StepperMotor::BWD);
speed2 = motor2->get_speed();
- printf("speed2 =%d \r\n\n", speed2);
- printf("W =%f \r\n\n", w);
+ //printf("speed2 =%d \r\n\n", speed2);
+ //printf("W =%f \r\n\n", w);
}
else{ if(w<0.67) {
@@ -203,16 +220,18 @@
motor2->run(StepperMotor::FWD);
speed2 = motor2->get_speed();
- printf("speed2 =%d \r\n\n", speed2);
- printf("W =%f \r\n\n", w);
+ // printf("speed2 =%d \r\n\n", speed2);
+ // printf("W =%f \r\n\n", w);
}
else
motor2->hard_stop();
speed2 = 0;
- printf("speed2 =%d \r\n\n", speed2);
- printf("W =%f \r\n\n", w);
+ // printf("speed2 =%d \r\n\n", speed2);
+ //printf("W =%f \r\n\n", w);
}
+
+
}
}
\ No newline at end of file
