Running two stepper motors (DRV8825 Drivers) simultaneously with accel and decel

Good day.
I'm stuck using a NEMA 23 (X carriage) and NEMA 17 (Y carriage) -stepper motor for my automatic bar dispensing machine.
I need an X and Y movement for dispensing the liquor thus meaning I want to move the glass to an X position and a Y position. The tricky part is to move both stepper motors simultaneously with acceleration and deceleration.... If possible is there a way to combine the Multistepper and Accelstepper libraries in order to get the best of both since the Multistepper library doesn't support acceleration...?

For more info:
*There are 13 positions (X and Y).
*I use DRV8825 stepper drivers.
*X carriage = NEMA 23 = Half steps.
*Y carriage = NEMA 17 = Half Steps.
*Using 24V Dc NEMA stepper drivers.
*Using Arduino Mega 2560.
*X carriage is using a belt driven system with 24T pinion pulley.
*Y carriage is using en 8 mm lead screw setup with 2 mm pitch.

Thanks :slight_smile:

The word "simultaneous" can be ambiguous. For example if you want motorA to move 100 steps and motorB to move 23 steps but you don't care if motorB finishes long before motorA then you can use the regular AccelStepper library.

On the other hand if you want motorA to do its 100 steps in the exact same time that motorB moves 23 steps then you need to use the MultiStepper library which cannot do acceleration or you need to abandon the library and write your own acceleration code - which is not too difficult.

Have a look at this Simple acceleration code.

...R

Ideally I would like them to start at the same time and end at the same time with acceleration and deceleration, but as you would know since the X and Y distances aren't the same the one stepper motor's speed will have to be lowered in order to compensate for time. I need to keep my speed at maximum with both stepper motors as to lower waiting time for dispensing liquor.

Knowing this the second best way would be to implement acceleration and deceleration where the stepper motors starts at the same time at full speed (if max is achieved after acceleration) without stopping at the same time. If by chance do you have a compiled code of this caliber?

I've looked at the code you referred to consisting out of the self-written acceleration, but I'm not to sure as of how to implement it into my program. And I'm even less sure as of how to implement two stepper motors. Your code is very impressive and most probably too 'high' for me. :o

Much Appreciated.

wikkels:
Knowing this the second best way would be to implement acceleration and deceleration where the stepper motors starts at the same time at full speed (if max is achieved after acceleration) without stopping at the same time. If by chance do you have a compiled code of this caliber?

If you are content with that then just use the normal AccelStepper run() function for the two motors. Perhaps do some tests to see if it is adequate before trying anything more complex.

I've looked at the code you referred to consisting out of the self-written acceleration, but I'm not to sure as of how to implement it into my program.

It will require some learning on your part. Start with a single motor.

To run two motors you need to find an interval that is suitable for the speed of the two motors and then check the time after every interval. Perhaps one motor will need to make step every 3 intervals and the other would make a step every 11 intervals. My maths is rusty (it never was anything else) but I think you need to find the Highest Common Multiple for the steps-per-second for each motor.

...R

AccelStepper will control multiple motors at the same time. Have you tried to use it?