Hello !
I launched into the programming for a week for a project in connection with my studies. However my beginner's level returns complicated things.
I have to realize a program to test two engines step by step(Which moves a rail in translation), here is my specifications :
" Realize the program which will later allow to verify the smooth running of the engines of axes X and Y.
1st Program:
- a procedure of grip of origin (By means of the sensors of the end of running)
- a sequence of movement such as described below:
Travel of 100mm according to X.
Travel of 50mm according to Y.
Travel of - 50mm according to X.
Travel of 70mm according to Y.
Return in the point of origin. "
Here is the material which I have at my disposal:
-L298N Hour-bridge.
-2 moters step by step
- a card Arduino
- 4 Sensors of the end of running
I used the function steppers to realize a program but I meet many problems at the level of the programming :
#include <Stepper.h>
const int stepsPerRevolution = 200;
// initialize the stepper library on pins 2-5 n 8-11
Stepper myStepper1(step_360,2,3,4,5);
Stepper myStepper2(step_360,8,9,10,11);
void setup()
{
// set the speed at 60 rpm:
myStepper1.setSpeed(60);//left
myStepper2.setSpeed(60);//right
// initialize the serial port:
Serial.begin(9600);
} myStepper.setSpeed(60);void loop() {
stepper1.move(200);
stepper2.move(200);
do {
stepper1.run(); // Update du moteur 1
stepper2.run(); //Update du moteur2
capteur = digitalRead(8);
capteur = digitalRead(10);
} while (capteur == LOW);
stepper.stop();
stepper.move(-500);
do {
stepper1.run(); // Update du moteur 1
stepper2.run(); // Update du moteur 2
} while ( stepper1.distanceToGo() != 0 ) || ( stepper2.distanceToGo() != 0);
delay(50);
}
{
Moteur1.step(?); //I have to calculate the report between the steps of the engine and the distance traveled by the wagon.//
delay(50);
Moteur2.step( ?);
delay(50);
Moteur1.step( ?) ;
delay(50);
Moteur2.step( ?) ;
delay(50);
}
{
stepper1.move(200);
stepper2.move(200);
do {
stepper1.run();
stepper2.run();
capteur = digitalRead(8);
capteur = digitalRead(10);
} while (capteur == LOW);
stepper.stop();
stepper.move(-500);
do {
stepper1.run(); // Update du moteur 1
stepper2.run(); // Update du moteur 2
} while ( stepper1.distanceToGo() != 0 ) && ( stepper2.distanceToGo() != 0);
delay(50);
}
Thanks ! ![]()