Robin2:
You have not posted the program you have been trying so I don't know what changes to recommend.
If you are using the regular Stepper library then it is really only designed to run one motor at a time as it blocks the Arduino until a move is complete Of course you could use the library just to do single steps and supply the iner-step timing yourself.
Have a look at the AccelStepper library. It can move the motors without blocking.
...R
Stepper Motor Basics
Simple Stepper Code
Thank you for your reply.
This is the program i am actually using:
#define EN 8
//Direction pin
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7
//Step pin
#define X_STP 2
#define Y_STP 3
#define Z_STP 4
//DRV8825
int delayTime=200; //Delay between each pause (uS)
int Xstps=1600; //X movement
int Ystps=88; //Y movement
void step(boolean dir, byte dirPin, byte stepperPin, int steps)
{
digitalWrite(dirPin, dir);
delay(50);
for (int i = 0; i < steps; i++) {
digitalWrite(stepperPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(stepperPin, LOW);
delayMicroseconds(delayTime);
}
}
void setup(){
pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop(){
//Layer 1/12
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(true, Y_DIR, Y_STP, Ystps); //Y, Counterclockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
//Layer 2/12
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
step(false, Y_DIR, Y_STP, Ystps); //Y, Clockwise
delay(10);
step(false, X_DIR, X_STP, Xstps); //X, Clockwise
delay(10);
}
But it does one instruction at time
[/code]