laurb9 / StepperDriver

Arduino library for A4988, DRV8825, DRV8834, DRV8880 and generic two-pin (DIR/STEP) stepper motor drivers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug. Two motors nema 17 do not rotate at the same time.

EugenGavrisciuc opened this issue · comments

Describe the bug
So, if I want to use at the same time two different nema 17 motors and two different drivers (A4988 and DRV8825), the motors don't work correct. So, instead of rotating at the same time both motors, one of them is doing half of rotation and then stop. While the first stepper is "stopping" the second motor is doing too a half of rotation and then stops.

To Reproduce
Steps to reproduce the behavior:
#include <Arduino.h>
#include "DRV8825.h"
#include "A4988.h"

#define MOTOR_STEPS_R 200
#define RPM_R 120
#define MOTOR_STEPS 200
#define RPM 120

#define MICROSTEPS_R 1
#define DIR_R 48
#define STEP_R 12
#define MICROSTEPS 1
#define DIR 49 // Pin 49
#define STEP 9 // Pin 10

A4988 stepper(MOTOR_STEPS, DIR, STEP);
DRV8825 stepper2(MOTOR_STEPS_R, DIR_R, STEP_R);

void setup() {
stepper2.begin(RPM_R, MICROSTEPS_R);
stepper.begin(RPM, MICROSTEPS); // Motorul pas cu pas
}

void loop() {
stepper.rotate(360); // Rotire jos
stepper2.rotate(360); // Rotire jos
}

Expected behavior
At the same time, nema motors to rotate without problem.

Platform Setup (please complete the following information):

  • Arduino IDE version 1.8.13
  • Arduino Mega 2560
  • A4988 and DRV8825
  • Pin 9 step and dir 49 for A4988;
  • Pin 12 step and dir 48 for DRV8825

Thank you for providing the code and setup. The rotate() function in this library is blocking, it will wait to complete the motion before allowing the next step to continue. The motors moving in sequence is what should happen. If they are moving half-way only, it means the hardware microstep set for the board is most likely 2 and not 1.

There are two ways to move the motors together. The easiest is using the MultiDriver or SyncDriver shown in the MultiAxis example. The other is the Nonblocking example

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.