Running Multiple Stepper motors simultaneously

As I am sure you will be able to tell I am not very good at programming but I am trying to learn. I would like to move 6 steppers with three v2 motor shields all simultaneously. I want to move each stepper a different number of steps then reverse the same number of steps.

I modified the adafruit sample to get where I am now. The steppers are all turning one rotation but I cant figure out how to make each stepper move a different number of steps.

#include <Wire.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMStop(0x62);
Adafruit_MotorShield AFMSmid(0x61);
Adafruit_MotorShield AFMSbot(0x60);

// On the top shield
Adafruit_StepperMotor *myStepper5 = AFMStop.getStepper(2048, 1);
Adafruit_StepperMotor *myStepper6 = AFMStop.getStepper(2048, 2);

// On the middle shield
Adafruit_StepperMotor *myStepper3 = AFMSmid.getStepper(2048, 1);
Adafruit_StepperMotor *myStepper4 = AFMSmid.getStepper(2048, 2);

// On the bottom shield
Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(2048, 1);
Adafruit_StepperMotor *myStepper2 = AFMSbot.getStepper(2048, 2);

void setup() {
while (!Serial);
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“MMMMotor party!”);

AFMSbot.begin(); // Start the bottom shield
AFMSmid.begin(); // Start the middle shield
AFMStop.begin(); // Start the top shield

myStepper1->setSpeed(40); // 40 rpm
myStepper2->setSpeed(40); // 40 rpm
myStepper3->setSpeed(40); // 40 rpm
myStepper4->setSpeed(40); // 40 rpm
myStepper5->setSpeed(40); // 40 rpm
myStepper6->setSpeed(40); // 40 rpm

}

int i;
void loop() {

for (i=0; i<2048; i++) {
myStepper1->step(1, FORWARD, SINGLE);
myStepper2->step(1, FORWARD, SINGLE);
myStepper3->step(1, FORWARD, SINGLE);
myStepper4->step(1, FORWARD, SINGLE);
myStepper5->step(1, FORWARD, SINGLE);
myStepper6->step(1, FORWARD, SINGLE);
//delay(100);
}

for (i=0; i<2048; i++) {
myStepper1->step(1, BACKWARD, SINGLE);
myStepper2->step(1, BACKWARD, SINGLE);
myStepper3->step(1, BACKWARD, SINGLE);
myStepper4->step(1, BACKWARD, SINGLE);
myStepper5->step(1, BACKWARD, SINGLE);
myStepper6->step(1, BACKWARD, SINGLE);
//delay(100);

}
}

First thing is to identify what you mean by simultaneous.

It can mean that several motors start their movements at the same time but finish at different times depending on how many steps are needed and the interval between steps. That is the simplest situation.

The other possibility is that all the motors must start at the same time and finish at the same time even though one moves (say) 123 steps and another moves 847 steps. That is how things like 3D printers and CNC milling machines work.

If you only need the simpler style of movement then I suggest you use AccelStepper library rather than the Adafruit system.

If you need the type of co-ordinated movement then the MultiStepper library (which is a superset of AccelStepper) can do that but it does not do acceleration. If you need coordinated movement with acceleration you will need to write your own code - which is not too difficult.

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

Simple acceleration code.

Thanks for the response. I see what you are saying in regards to the moments, luckily they dont need to be timed. Each stepper is connected to a screw and the screw will move a carriage back and forth. This is just for demonstration purposes and each slide is individual so they don't need to start and end at the same time. It should be really simple. The screws have different pitches which is why I need them to each move a different number of steps.

Someone had suggest the accellibrary to me but I thought i read that it only worked with the v1 motor shield but maybe that was a misunderstanding. I'm confused as how the accellibary works with the motor shield. I'll look at this in more detail. I'm just surprised at how difficult it seems to be just to move a few steppers back and forth.

jonica:
I'm just surprised at how difficult it seems to be just to move a few steppers back and forth.

It's a great deal easier with a specialized stepper motor driver that takes step and direction signals from the Arduino.

Sorry, I'm not familar with your Adafruit shield.

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

I'm using a 28byj-48 stepper motors which should be capable of stepping at 15rpm but know matter what speed I set it its running at like 1 rpm. Do you know what might be the issue?

jonica:
I'm using a 28byj-48 stepper motors which should be capable of stepping at 15rpm but know matter what speed I set it its running at like 1 rpm. Do you know what might be the issue?

Please post your program.

Are you using the usual ULN2003 driver with the 28BYJ motor?

...R