This is my first post on this forum so please be gentle, I am new to the dark arts of Arduino.
I have encountered this issue and it is driving me mad I have replicated it on an Uno and a Mega 2560, two different CNC v3 Clones and two sets of drivers (A4988 and DRV 8825) and I have removed and reinstalled the accesStepper library.
I have simplified the code as much as possible and just cannot see what the cause is.
When I run this code all 4 motors run, when I use setSpeed(1000) the X motor runs clockwise and all the others run anti-clockwise. When I use SetSpeed(-1000) everything goes anti-clockwise.
#include <Arduino.h>
#include <AccelStepper.h>
const byte PIN_X_STEP = 2;
const byte PIN_X_DIR = 5;
const byte PIN_X_LIMIT = 9;
const byte PIN_Y_STEP = 3;
const byte PIN_Y_DIR = 6;
const byte PIN_Y_LIMIT = 10;
const byte PIN_Z_STEP = 4;
const byte PIN_Z_DIR = 7;
const byte PIN_Z_LIMIT= 11;
const byte PIN_SPINDLE_EN = 12;
const byte PIN_SPINDLE_DIR = 13;
const byte PIN_COOL_EN = A3;
const byte PIN_ABORT = A0;
const byte PIN_HOLD = A1;
const byte PIN_RESUME = A2;
AccelStepper _stepper;
void setup()
{
pinMode(PIN_X_LIMIT, INPUT_PULLUP);
pinMode(PIN_Y_LIMIT, INPUT_PULLUP);
pinMode(PIN_Z_LIMIT, INPUT_PULLUP);
pinMode(PIN_SPINDLE_EN, INPUT_PULLUP);
pinMode(PIN_SPINDLE_DIR, INPUT_PULLUP);
pinMode(PIN_COOL_EN, INPUT_PULLUP);
pinMode(PIN_ABORT, INPUT_PULLUP);
pinMode(PIN_HOLD, INPUT_PULLUP);
pinMode(PIN_RESUME, INPUT_PULLUP);
pinMode(PIN_Y_STEP, OUTPUT);
pinMode(PIN_Y_DIR, OUTPUT);
pinMode(PIN_Z_STEP, OUTPUT);
pinMode(PIN_Z_DIR, OUTPUT);
digitalWrite(PIN_Y_STEP,0);
digitalWrite(PIN_Y_DIR,0);
digitalWrite(PIN_Z_STEP,0);
digitalWrite(PIN_Z_DIR,0);
AccelStepper _stepper(AccelStepper::DRIVER,PIN_X_STEP,PIN_X_DIR);
}
void loop()
{
_stepper.setMaxSpeed(1000);
_stepper.setSpeed(1000);
_stepper.runSpeed();
}
Any help would be gratefully received.