1

I'm working with an Arduino UNO and a stepper motor NEMA 17. I would like to know how to avoid the stepper motor to revert its spin direction when I apply a load in the shaft. The motor works as I spect without any load, here is the code I'm using.

I think I'm missing something in the code, not in the connections.

// Define pin connections & motor's steps per revolution
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 45;//115

void setup()
{
  // Declare pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}
void loop()
{
  
if(true){
    // Set motor direction counterclockwise
  digitalWrite(dirPin, HIGH);

  // Spin motor quickly
  for(int x = 0; x < stepsPerRevolution; x++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(700); //670
    digitalWrite(stepPin, LOW);
    delayMicroseconds(700); //670
  }
  
  }
}

External voltage: 12 v 3A max

Motor's datasheet: 17HS4401S

Driver: DRV8825

Guide:https://lastminuteengineers.com/drv8825-stepper-motor-driver-arduino-tutorial/

Sketch

Resource: https://lastminuteengineers.com/drv8825-stepper-motor-driver-arduino-tutorial/

3
  • What's the load on the motor? Did you set the current limit? Have you checked the fault pin? – Dave Newton Jun 12 at 19:28
  • The load on the shaft is 0.3 kg cm, I’ve already set up the potentiometer (this is why the motor works fine) and since it’s not stop working the driver is always running ( no fault) it only reverse its spin direction – CoronelV Jun 12 at 19:39
  • How is the load connected to the shaft? In other words are you sure it's the motor and not the mechanicals? Have you tried with something needing lower torque? I'd also double-check the coil wires--don't just rely on wire color. – Dave Newton Jun 12 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.