Driving two Stepper Motors at the same time

I am working on a project where I would like to drive two stepper motors simultaneously with an Arduino Uno. I have two of the A4988 Stepper Motor Drivers and two Stepper Motors (Stepper Motor: Bipolar, 200 Steps/Rev, 35×28mm, 10V, 0.5 A/Phase).

What is the best way to do this?

~ Rich

Hello, Rich.

You would typically connect those A4988 driver carriers to your Arduino Uno the same way shown in the “Minimal wiring diagram for connecting a microcontroller to an A4988 stepper motor driver carrier (full-step mode)” on the A4988 product page.

If you want both stepper motors to step at the same time and always in the same direction as each other, you can connect the STEP pins and DIR pins from both carriers to the same pins on the Arduino.

-Derrill

Derrill,

I am good with that part so far. What it I want them to turn at different speeds at the same time? Is there a better way than driving the step outputs HIGH manually in a loop?

Also how long to the step outputs need to be high to register? Is 2 ms enough?

~ Rich Bankhead

Hello, Rich.

I do not have any specific examples I can direct you to for that particular application, but you should be able to do that using non-blocking code.

The minimum HIGH and LOW pulse width for the A4988 is 1μs, so 2ms should be fine. You can find those values in the “Allegro A4988 stepper motor driver datasheet” located under the “Resources” tab of the A4988 product page.

-Derrill

Hello, Rich.

You might take a look at the “DualMotorShield” example in the AccelStepper library to see if that code can offer some insights for your code.

-Derrill

Derrill,

Thanks! That looks like exactly what I need. And all the magic is hidden in the libraries! Perfect! I post an update when I get things working.

~ Rich