AccelStepper - multi stepper help

Im writing code for a automated cocktail maker, i am using adafruit motor shields and their subsequent libraries. My code works great and I'm happy with it, but the motors will not operate at the same time without the use of the accelStepper library which i don't quite understand.

I want my x and y axis steppers to move at the same time. It seems like i have to use AccelStepper commands like the onestep() command inside of a while loop counting down the number of steps you need to take. with the step() commands i can tell the stepper exactly how far to go. Why can't i do that in AccelStepper.

I think it's on line 42, from what I can see of your code ...

Aaronkoe:
but the motors will not operate at the same time without the use of the accelStepper library which i don't quite understand.

You need to spend some time studying the examples that come with the library - especially the stepper.run() function.

I want my x and y axis steppers to move at the same time.

You have not said whether the movement needs to be coordinated - for example stepperA must move exactly 123 steps in the same time that stepperB moves 337 steps. OR if it is OK for stepperA to finish before stepperB.

...R
Stepper Motor Basics
Simple Stepper Code

I don't think I need to include my 1000+ lines of code to ask a simple question about a library I don't understand.

I have gone through the supplied examples and there aren't even comments as to what the commands are doing. And the code is just making the motors move back and fourth constantly. That hardly seems helpful to understand more useful functions like precision movements.

The accelStepper library will run multiple motors simultaneously, but in a timed manner, and not on a quantity of steps.

I want to tell my motors to go x and y at the same time, not one after the other.

 xStepper->(100, FORWARD, DOUBLE) 
yStepper->( 200,  BACKWARD, DOUBLE)

This is an example of how I will tell my steppers to move to precise positions.

How can I make that operate together.

Aaronkoe:
The accelStepper library will run multiple motors simultaneously, but in a timed manner, and not on a quantity of steps.

I want to tell my motors to go x and y at the same time, not one after the other.

Did you read Reply #2 carefully?

You have not answered my question.

...R

Robin2:
Did you read Reply #2 carefully?

You have not answered my question.

...R

I do not care if they finish at the same time or not. I just want them to move together to save time. My question is specifically pertaining to the adafruit motor shields v2, which operate differently than the standard stepper drivers and/or CNC shields. I have used both so i know what I'm talking about, and therefore the links you provided are not specifically relevant to my coding question, though i do appreciate the replies.

I always get more questions then i do answers on these boards, but every once in a while someone is nice and decides to be helpful and i would greatly appreciate it.

Aaronkoe:
I do not care if they finish at the same time or not. I just want them to move together to save time. My question is specifically pertaining to the adafruit motor shields v2, which operate differently than the standard stepper drivers and/or CNC shields.

AccelStepper can certainly make two (or more) motors work at the same time if you don't need them to finish at the same time. And AFAIK it can work with that motor shield (as well as with specialized stepper drivers).

...R

Robin2:
AccelStepper can certainly make two (or more) motors work at the same time if you don't need them to finish at the same time. And AFAIK it can work with that motor shield (as well as with specialized stepper drivers).

...R

yes... i understand that it can work. but adafruit provides one example for their shield and it is as follows:

// Shows how to run three Steppers at once with varying speeds
//
// Requires the Adafruit_Motorshield v2 library 
//   https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library
// And AccelStepper with AFMotor support 
//   https://github.com/adafruit/AccelStepper

// This tutorial is for Adafruit Motorshield v2 only!
// Will not work with v1 shields

#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closed
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers

// Connect two steppers with 200 steps per revolution (1.8 degree)
// to the top shield
Adafruit_StepperMotor *myStepper1 = AFMStop.getStepper(200, 1);
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 2);

// Connect one stepper with 200 steps per revolution (1.8 degree)
// to the bottom shield
Adafruit_StepperMotor *myStepper3 = AFMSbot.getStepper(200, 2);

// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {  
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {  
  myStepper1->onestep(BACKWARD, SINGLE);
}
// wrappers for the second motor!
void forwardstep2() {  
  myStepper2->onestep(FORWARD, DOUBLE);
}
void backwardstep2() {  
  myStepper2->onestep(BACKWARD, DOUBLE);
}
// wrappers for the third motor!
void forwardstep3() {  
  myStepper3->onestep(FORWARD, INTERLEAVE);
}
void backwardstep3() {  
  myStepper3->onestep(BACKWARD, INTERLEAVE);
}

// Now we'll wrap the 3 steppers in an AccelStepper object
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);
AccelStepper stepper3(forwardstep3, backwardstep3);

void setup()
{  
  AFMSbot.begin(); // Start the bottom shield
  AFMStop.begin(); // Start the top shield
   
  stepper1.setMaxSpeed(100.0);
  stepper1.setAcceleration(100.0);
  stepper1.moveTo(24);
    
  stepper2.setMaxSpeed(200.0);
  stepper2.setAcceleration(100.0);
  stepper2.moveTo(50000);

  stepper3.setMaxSpeed(300.0);
  stepper3.setAcceleration(100.0);
  stepper3.moveTo(1000000);
}

void loop()
{
    // Change direction at the limits
    if (stepper1.distanceToGo() == 0)
 stepper1.moveTo(-stepper1.currentPosition());

    if (stepper2.distanceToGo() == 0)
 stepper2.moveTo(-stepper2.currentPosition());

    if (stepper3.distanceToGo() == 0)
 stepper3.moveTo(-stepper3.currentPosition());

    stepper1.run();
    stepper2.run();
    stepper3.run();
}

this is almost useless because there are no commends to explain what its doing, while it is pretty apparent. Its moving the motors back and fourth constantly.

this code in no way helps me do something useful like precision stepper movements and i cannot for the life of me figure out how to translate it to my code, which looks like this friggin mess:

 yAxis->step(1050, BACKWARD, DOUBLE);delay(5000);
  xAxis->step(1050, FORWARD, DOUBLE);yAxis->step(650, FORWARD, DOUBLE);
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(500, FORWARD, DOUBLE);yAxis->step(650, BACKWARD, DOUBLE); 
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(425, FORWARD, DOUBLE);yAxis->step(650, FORWARD, DOUBLE); 
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(525, FORWARD, DOUBLE);yAxis->step(650, BACKWARD, DOUBLE);
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(875, FORWARD, DOUBLE);
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(550, FORWARD, DOUBLE);yAxis->step(650, FORWARD, DOUBLE); 
  zAxis->step(950, FORWARD, DOUBLE);delay(4000);zAxis->step(950, BACKWARD, DOUBLE);
  xAxis->step(3025, BACKWARD, DOUBLE);yAxis->step(400, FORWARD, DOUBLE);

and that is just one drink! i have almost 50! please provide me an example snippet of code if you are able. thank you

Aaronkoe:
but adafruit provides one example for their shield and it is as follows:

I have never used any of their code myself but, from reading other Threads here, it seems to me Adafruit have complex and unusual ways of approaching things.

...R