[HOW TO] Control two (or more) stepper motors in parallel with one microcontroller

Hey, last year i made a project to a course with my fellow colleague André which consisted on two Human-Interface designs to a robotic arm, and we came up with a difficulty in controlling the two stepper motors in parallel using different velocities.

For that we used some kind of “time-division” thing, to select a window to generate a clock to each stepper.

Lets take for instance 5 motors, and a 1s loop time, with a 40ms window, you can see in black the steppers to be clocked.

We used a L296-L298 IC combination to use only two pin per stepper (clock and direction), but you can use the 4 usual signaling per stepper with minor modifications in the code.

You can have the code (implemented on an Atmega8), but i don’t have much time to explain it, it just connects with PC and the uC will respond to the commands of the protocol table (if you need another language ask for it on the comments):


Changes the mode to mode X, with X=0,1 or 2
If mode=1
A e B represents the number of steps to performs on motors 1 and 2

(at maximum velocity)
If mode=2
A e B represents the velocity (in steps p second) of 1 and 2.


if A<0 or B < 0, the correspondent motor will step negativelly

PC-> Micro
Motor test
PC-> Micro
Puts the arm on the reference
Returned by the Uc when the command finishes (on mode=1 , ‘T’ or ‘I’)
Micro-> PC
Command not recognized
Micro ->PC

Below you have a video demonstrating the functionality, the max. vel. of the steppers wasn’t too big, so don’t surprise.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>