Stepper Motor Refuses to go CCW

I am trying to turn a NEMA 34 stepper motor both CW and CCW. I have a microstep driver and am using the AccelStepper library. I am using Arduino MEGA 2560.

I have PUL+ & DIR+ connected to Pin 8. I have PUL- connected to digital GND. I have DIR- connected to Pin 9.

It refuses to turn CCW no matter what number (pos or neg) I feed into moveTo.

#include <AccelStepper.h>
AccelStepper stepper(1, 8, 9);  // 1=Stepper driver option, 3=Step pulse pin, 2=Direction

void setup() {
   stepper.setMaxSpeed(2000); // Set max speed. Steps per second
   stepper.setAcceleration(2000);  // set motor acceleration
}

void loop() {

  stepper.moveTo(-5000);
  stepper.runToPosition();
}

I have PUL+ & DIR+ connected to Pin 8. I have PUL- connected to digital GND. I have DIR- connected to Pin 9.

This is a strange arrangement. Usually, DIR is used to set direction and rarely changes state.

I would connect DIR- to digital ground, DIR+ to pin 9 and use pin 9 for direction.

Now it only goes CCW lol.

So.. DIR- goes to Digital GND DIR+ goes to PIN 9 PUL- goes to PIN 9 PUL+ goes to PIN 8 ?

The PUL- and DIR- terminals are almost always grounded.

Check the options on accelstepper to make sure you have selected the correct ones.

If you expect informed help, post links to ALL the details of the motor, the motor power supply, the driver, and a hand drawn (not Fritzing) wiring diagram.

AccelStepper (1, 8, 9) means:

1 = using a stepper driver with step/dir inputs 8 = step pulse being used 9 = dir pin being used

Then connect your driver as follows: Arduino -> Driver: 8 -> PUL+ 9 -> DIR+ GND -> GND GND -> DIR- GND -> PUL-

That's how it always works in my project(s) - using "common cathode" drivers only. With "common anode" drivers you will have to modify the connections; so first check what kind of driver you are using. Post a detailled description or exact product name of your driver if you are not sure what kind of driver you have and need further assistance..

It worked! Thank you so much! I was sweating bullets. Phew!

I am glad that you got it. For the future: remember the "common cathode / common anode" advice ;-)

greesonbrad: I was sweating bullets. Phew!

If your motor was going in 1 direction (either ccw, or going cw), then there shouldn't be anything to sweat about - due to the fact that it actually stepped consistently in 1 direction - regardless of cw direction or ccw direction. It would just mean that something wasn't quite correct with the driving of the motor.