Hello.
I am going to use two step motors, two easy-drivers, one arduino uno.
Each step motors have gear to rotate, both forward and backward.
First, I'd like to assign multiple rotation cues for each steppers. such as,
int step1cue1 = 329
int step1cue2 = 582
int step1cue3 = 1038
int step1 cue4 = 1790
...
int step2cue1 = 568
int step2cue2 = 1004
int step2cue3 = 1928
int step2cue4 = 3592
...
and each stepper needs minimum 0 and maximum value, such as,
int step1maxcue = 8372
int step2maxcue = 8421
each rotation speed and acceleration need to be set and controllable as well.
I would like to use rotation speed = 0 to make the stepper stopped at the cue.
** Operation
Both steppers start from 0,
First, stepper1 rotates to randomly chosen cue from its step1cues, when it almost reaches to the chosen cue, stepper2 starts to rotate to randomly chosen cue from step2cues.(stepper1 stopped at the cue with speed=0), when step2 almost reaches to its cue, stepper1 starts to rotate to another randomly chosen step1cue (not the current cue).. (stepper2 stops with speed=0).. and repeat this transition between two steppers.
I would like to use the code from this, Easy Driver Examples
#include <AccelStepper.h>
// Define two steppers and the pins they will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 7, 6);
int pos1 = 3600;
int pos2 = 5678;
void setup()
{
stepper1.setMaxSpeed(3000);
stepper1.setAcceleration(1000);
stepper2.setMaxSpeed(2000);
stepper2.setAcceleration(800);
}
void loop()
{
if (stepper1.distanceToGo() == 0)
{
pos1 = -pos1;
stepper1.moveTo(pos1);
}
if (stepper2.distanceToGo() == 0)
{
pos2 = -pos2;
stepper2.moveTo(pos2);
}
stepper1.run();
stepper2.run();
}
Could you please help me to code this?
Best,
J