Synchronized stepper motors

Hello all,
can you help me with a little problem? I have arduino mega with CNC shield V3 with two A4988 drivers connected to nema17 stepper motors. I would like to synchronize steps. One motor can run 360°, second one 720°. I need these two motors start at same time and end too. But motor with 720° ends early, then the motor with 360° ends later (after +/- 0.5 seconds). Both motor runs requested angle.

My code:

#include <Arduino.h>
#include "Stepper.h"
#include "BasicStepperDriver.h"
#include "MultiDriver.h"
#include "SyncDriver.h"

#define MOTOR_STEPS 100
#define MOTOR_X_RPM 90
#define MOTOR_Y_RPM 90
#define DIR_X 5
#define STEP_X 2
#define DIR_Y 6
#define STEP_Y 3
#define EN 8
#define MICROSTEPS 32
BasicStepperDriver stepperX(MOTOR_STEPS, DIR_X, STEP_X, EN);
BasicStepperDriver stepperY(MOTOR_STEPS, DIR_Y, STEP_Y, EN);
SyncDriver controller(stepperX, stepperY);

void setup() {
    Serial.begin(9600);
    Serial.println("INIT start");
    stepperX.begin(MOTOR_X_RPM, MICROSTEPS);
    stepperY.begin(MOTOR_Y_RPM, MICROSTEPS);
    stepperX.setEnableActiveState(LOW);
    stepperY.setEnableActiveState(LOW);
    stepperX.enable();
    stepperY.enable();
    Serial.println("INIT end");
}

void loop() {
    controller.rotate(360,720);
    delay(2000);
}

Where can be the problem? :slight_smile: When the bigger angle motor ends, the second one is faster for a time. When both motors has same angle, both ends at the same time.

Thank you very much for your help, and I'm sorry for my english. :slight_smile:

Requested is linear moving, not a "L" or "hockey stick".

you are defining for both motors the same rotational speed

#define MOTOR_X_RPM 90
#define MOTOR_Y_RPM 90

and define the same amout of steps per revolution for both motors

#define MOTOR_STEPS 100
BasicStepperDriver stepperX(MOTOR_STEPS, DIR_X, STEP_X, EN);
BasicStepperDriver stepperY(MOTOR_STEPS, DIR_Y, STEP_Y, EN);

and then you expect that both motors start and stop at the same time
when motor 1 shall
drive 360 steps
and
moto 2 shall drive 720 steps?

not possible at all.

But I'm still not sure if this is what you want. So please give a description in normal words what do you want to achive that both motors do. Same rpm or same start-stop?

best regards Stefan

I know how to do this without a library but I have no knowledge of the libraries you are using.

Based on what @StefanL38 has said it seems as if you need to calculate an appropriate speed for each motor so they can move different numbers of steps in the same time.

...R