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? 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.
Requested is linear moving, not a "L" or "hockey stick".