0
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
Sketch
