Controlling multiple steppers with joystick

Hey everyone!! :slight_smile:

I’m kinda scratching my head on this project I’m on right now since I cannot figure out how to make it work. Hopefully you can help me a little bit…

I have three stepper motors (with Big Easy Drivers) and two joysticks in the following setup.

Joystick1 controls:
Stepper1 (Tilt, X)
Stepper2 (Shift, Y)

Joystick2 controls:
Stepper3 (Rotate, Z)

However let’s forget Joystick2 and Stepper3 for a second.

I want to control Stepper1 and Stepper2 accordingly to the position of Joystick1.
So if I went for a diagonal movement on the stick both motors should start running simultaneously. If I were to move up the stick only Stepper1 should move, etc. You get the deal :slight_smile:

Here’s a video which describes it quite well (forget the XBOX controller):

I understand that a real simultaneous movement of multiple steppers is not possible at all. Rather microsteps are made “nearly” at the same time to make it look both are running at the same time.
Therefore I want to use the Accelstepper.h library which did a great job in the past for me.
However I never encountered the need of using two or more motors at the same time and there’s where my problem is.

Here’s my current code which just rotates the steppers (very slow btw) but the input of my joystick is not considered at all.
I feel there’s something I’m missing as this program seems nearly too simple for it to work…

In this case the steppers “rotate” and “tilt” should move accordingly to the position of my joystick.

#include <AccelStepper.h>  

AccelStepper            // Initializing the stepper motors
#define JoyX1     A8  //Init Joysticks
#define JoyY1     A9
#define JoyX2     A10
#define JoyY2     A11

    joyX1 = analogRead(JoyX1),
    joyY1 = analogRead(JoyY1),
    joyX2 = analogRead(JoyX2),
    joyY2 = analogRead(JoyY2);

void setup()  





void loop()  

  joyX1 = analogRead(JoyX1);
  joyY1 = analogRead(JoyY1);      
  joyX2 = analogRead(JoyX2);
  joyY2 = analogRead(JoyY2);      

  Serial.print( joyX1 ); Serial.print( ' ' );                //Values displayed on Serial are correct
  Serial.print( joyY1 ); Serial.println( ' ' );

    rotate.moveTo(joyX1*50);      //I feel this is too simple... 
    rotate.setSpeed(joyX1);         //Value of joystick to set the speed according to the position of the joystick.;
    rotate.setSpeed(joyY1);    ;

Thanks a lot for reading and any help in advance!

supermaRiio: I understand that a real simultaneous movement of multiple steppers is not possible at all.

That is not correct. If you send a step instruction to each motor in turn the motion will be simultaneous for all practical purposes.

The AccelStepper library is not intended for synchronized movement of multiple motors and it is not difficult to control the motors without a library as your stepper drivers just require step and direction signals.

I'm guessing that you want the position of the joystick to represent the interval between steps - i.e. the speed of the motor.

Have a look at this Simple Stepper Code. It should be easy to adapt it for several motors.

...R Stepper Motor Basics