i am using two stepper motors and two drives if we give pulse to the driver stepper motor will rotate
but problem how to run two motors at a same time to draw a xy plot like drawing circle.
i used one code but it is rotate like Diamond shape
this is my code
#define motor1pul 2
#define motor1dir 3
#define motor2pul 4
#define motor2dir 5 // 2, 3 first motor puls and direc
void setup()
{
pinMode(motor1pul, OUTPUT);
pinMode(motor1dir, OUTPUT);
pinMode(motor2pul, OUTPUT);
pinMode(motor2dir, OUTPUT);
}
void loop()
{
digitalWrite(motor1dir, HIGH);
digitalWrite(motor2dir, HIGH);
for(i=0; i<12000; i++)
{
digitalWrite(motor1pul, HIGH);
digitalWrite(motor2pul, HIGH);
delay(1);
digitalWrite(motor1pul, LOW);
digitalWrite(motor2pul, LOW);
delay(1);
}
digitalWrite(motor1dir, HIGH);
digitalWrite(motor2dir, LOW);
for(i=0; i<12000; i++)
{
digitalWrite(motor1pul, HIGH);
digitalWrite(motor2pul, HIGH);
delay(1);
digitalWrite(motor1pul, LOW);
digitalWrite(motor2pul, LOW);
delay(1);
}
digitalWrite(motor1dir, LOW);
digitalWrite(motor2dir, LOW);
for(i=0; i<12000; i++)
{
digitalWrite(motor1pul, HIGH);
digitalWrite(motor2pul, HIGH);
delay(1);
digitalWrite(motor1pul, LOW);
digitalWrite(motor2pul, LOW);
delay(1);
}
digitalWrite(motor1dir, LOW);
digitalWrite(motor2dir, HIGH);
for(i=0; i<12000; i++)
{
digitalWrite(motor1pul, HIGH);
digitalWrite(motor2pul, HIGH);
delay(1);
digitalWrite(motor1pul, LOW);
digitalWrite(motor2pul, LOW);
delay(1);
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.