# How to control 6 stepper motor simultaneously

Hello everyone,

I am doing a project where I need to control 6 linear stepper motors (1.8deg, 0.61 mm pitch leadscrew) with motor drive A4988 and Arduino mega 2560. I would like to be able to control them independently. Each motor moves one element back or forth. The start position is with the 6 elements in different positions (for example element 1: 1 mm, element 2: 2mm, element 3: 3mm, element 4: 4mm, element 5: 5mm and element 6: 6mm). I would to be able to move the elements simultaneously in a way that it looks like a continuous motion. For example: motor 1 has to move an element forward for 5 mm while the other motors have to move backwards of 1 mm, then motor 2 will move forward of 5 mm while the other motors backwards of 1 mm and so on.

Does any of you can give me an advice on how to do this?

mila:
Does any of you can give me an advice on how to do this?

Yes, in small steps.

First step, connect a motor and write a test sketch to make it move.
Next, connect a second and make them move independently.
Connect all motors and confirm that you can make them all move.

Now, start working on your sketch for making them move the way you want.
I highly recommend that you read @Robin2's Demonstration code for several things at the same time and Stepper Motor Basics.

Come back here and ask questions if you run in to difficulty.

Am I correct to think that you want all the motors to start at the same time and all to finish at the same time but each one to move a different number of steps?

Perhaps the simplest solution is to use the Multistepper part of the Accelstepper library.

I have a system for controlling my small lathe that moves 3 motors in concert. I have a Python program on my PC that sends commands to my Arduino which contain 4 pieces of data - the total number of microseconds for a move and the number of microseconds between steps for each of the 3 motors. The Python program calculates those values either from user input on the PC screen or from data in a GCode file.

If you need a high step rate for all 6 motors you may find that a 16MHz Arduino is inadequate.