Robin2:
Please always post a complete program.The way I would move two stepper is something like this
void loop() {
if (stepper1pos < stepper1destination) {
myStepper1.step(1);
stepper1pos ++;
}
if (stepper2pos < stepper2destination) {
myStepper2.step(1);
stepper2pos ++;
}
delay(intervalBetweenSteps);
}
Obviously you also need code to set the initial value for stepper1pos and the value for stepper1destination. For testing you could set those in setup() And for a working program you will probably not want to use delay() and you may wish to have separate step intervals for each motor. ...R
Thank you for your suggestions!
Following your example i tryed to modify the code once again..
What do you think about it? may it be correct?
#include <Stepper.h>
const int stepsPerRevolution = 1600; // change this to fit the number of steps per revolution
int stepperXpos = 0; // How far we've traveled on X
int stepperYpos = 0; // How far we've traveled on Y
int stepperXdestination = 67200;
int stepperYdestination = 88;
// for your motor
// initialize the stepper library on pins
Stepper myStepperX(stepsPerRevolution, 8, 5, 2);
Stepper myStepperY(stepsPerRevolution, 8, 6, 3);
void setup() {
// set the speed at 60 rpm:
myStepperX.setSpeed(60);
myStepperY.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
stepperXpos = stepperXpos +1;
stepperYpos = stepperYpos +1;
Serial.println("clockwise");
myStepperX.step(stepperXdestination);
if (stepperXpos < stepperXdestination) {
myStepperX.step(1);
stepperXpos ++;
}
if (((stepperxpos + 88) / 1600) == 0) {
Serial.println("clockwise");
myStepper.step(stepperYdestination);
}
if (stepperYdestination == stepperYpos) {
stepperYpos = 0;
}
if (((stepperxpos + 88) / 3200) == 0) {
Serial.println("clockwise");
myStepper.step(stepperYdestination);
}
if (stepperYdestination == stepperYpos) {
stepperYpos = 0;
}
if (((stepperxpos + 88) / 4800) == 0) {
Serial.println("clockwise");
myStepper.step(stepperYdestination);
}
if (stepperYdestination == stepperYpos) {
stepperYpos = 0;
}
if (((stepperxpos + 88) / 6400) == 0) {
Serial.println("clockwise");
myStepper.step(stepperYdestination);
}
if (stepperYdestination == stepperYpos) {
stepperYpos = 0;
}
if (((stepperxpos + 88) / 8000) == 0) {
Serial.println("clockwise");
myStepper.step(stepperYdestination);
}
if (stepperYdestination == stepperYpos) {
stepperYpos = 0;
}
}
There are 2 things witch i'm not sure: is the pins' order correct here?
Pin 8 is for Enable, 5 and 6 for direction and 2 and 3 for step)
Stepper myStepperX(stepsPerRevolution, 8, 5, 2);
Stepper myStepperY(stepsPerRevolution, 8, 6, 3);
And the second thing is: here what value i have to insert? the full step option of my steppers (200 step/rev) or 1600 steps per revolution i am using because of 1/8 microstep i have setted on the driver?
const int stepsPerRevolution = 1600; // change this to fit the number of steps per revolution
Thank you a lot for your help, i really appreciate!