Stepper no reverse control

Having extreme problems getting my stepper motor to go in reverse ! The problem I am having is getting my stepper motor to go from ClockWise (cw)to CounterClockwise (ccw)
Having tried numerous motors from known working units and various codes iot still only goes CW . The Setup I have is using an Arduino Uno coupled to TB6600 MicroStep Driver coupled to a Nema 17 (4Wire 17hdc4023-24b) variable DC power supply up to 9-24v 3Amp
I have used various codes by various composers which turns the Motor and i can control the speed and steps but only goes 1 way, I know the motor coils are set correct and by changing the A+ - around to B+- It will start and turn CCW but then wont change to CW
.


const int stepPin = 4;
const int dirPin = 6;
const int enPin = 11;

void setup() {
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enPin, OUTPUT);
  digitalWrite(enPin, LOW);
}

void loop() {
  digitalWrite(dirPin, HIGH);  // Enables the motor to move in a particular direction
  for (int x = 0; x < 800; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }
  delay(1000);                // One second delay
  digitalWrite(dirPin, LOW);  //Changes the direction of rotation
  for (int x = 0; x < 800; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}

I can't see how you have connected the Arduino, but there are two ways, common anode or common cathode.


1 Like

Looks like you don't have dir- and pul- connected at all...

1 Like

Hi it is wired as common cathode sorry if its not clear in the Pic, I did wonder if connecting it up as a Common anode would solve my problem , its the only thing i haven't tried,

wired as a Common cathode the dir and pul + are connected to digital 4 and 6

On your image it's missing dir- and pul-. No circuit is complete with just one wire.
Make a bridge from ena- to dir- and pul- , they all need to be connected to GND.

Trust me Kmin they are connected you cant see them because they are black.

Your code is simple, I don't see anything wrong. I would try connecting DIR+ direct to +5V to see if that changes direction. I have known jumper wires to be open circuit.

Ok if you say so. Then take your multimeter and verify that you get both 0 and 5V across dir pins while your code is running

I just ran the code with a stepper driver I have thats similar and I get CW and CCW rotation, so I would check you DIR pin and see as others have suggested

Are you absolutely sure that the coils are correct? When disconnected, is there continuity between the B-&B+ pair and separately between the A-&A+ pair? (And no continuity between the pairs?) Sometimes you can't go by color.
I can't follow the colors in the photo, and I don't have specs on you motor pins/colors anyway.

1 Like

very interesting

thats a good idea

double checked

you are fantastic , on checking i was getting 5v on the DIR PIN dropping down to 0v as it went low but what i found on the Pul pin was also 0v so i checked the continuity on the wire and low and behold it had a break so after replacing the wire it performs as it should, so the problem is solved thanks to you, I can now move on with my life, thank you. Sue

You are welcome.

It would be fair If you mark the post that helped you as solution, and not your own one.

Being a newbie I struggle to navigate the system, I thought i had marked the solution , in fact i KnoW i did but there must be another one some where, but thanks for the message.