# Stepper motor controlled by turning only in one direction and stalling in opposite direction

I am controlling a high-torque stepper motor (23Y204S from Anaheim Automation with 8 lead-wire) using a microstepping driver (MBC15081) and Arduino.

The winding wiring is connected as bipolar series connection. The Arduino was programmed and the motor works fine in one direction, however, it stalls when trying to rotate in the opposite direction (it is possible to feel the pulsing/jerking) and it does not rotate.

I am currently using the driver in the sinking mode and it says that to control the direction of the rotation, it is necessary to change the signal from Logic '1' to Logic '0' and vice-versa. As you can see in the code below, in the forward motion (when directionPin is HIGH) the motor rotates, but in the reverse direction (when directionPin is LOW - in the code below it is highlighted with "stars" ****) the motor stalls.

Arduino Code:

P.S: The Serial.Read is receiving data from Visual Studios. Does not affect the problem here.

int clk = 27;
int directionPin = 34;
int MS2 = 42; //dip switches for step setting
int MS1 = 43;
int power = 35; // ON/OFF

const int revSteps[] = {3200, 800, 400, 200};
const int MS2switch[] = {LOW, LOW, HIGH, HIGH};
const int MS1switch[] = {LOW, HIGH, LOW, HIGH};

void setup()
{
Serial.begin(9600);
pinMode(clk, OUTPUT);
pinMode(directionPin, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(MS1, OUTPUT);
pinMode(power, OUTPUT);
}

void loop()
{

while (Serial.available() > 0)
{
char cat;

if (cat == '1') //Forward
{
digitalWrite(power, HIGH); //Turn motor ON
digitalWrite(directionPin, HIGH); //counter clockwise
digitalWrite(MS2, MS2switch[0]); //full/half/quarter/eighth of step
digitalWrite(MS1, MS1switch[0]); // ""
for (int x = 0; x < revSteps[3]; x++)
{
digitalWrite(clk, HIGH);
delayMicroseconds(3000);
digitalWrite(clk, LOW);
delayMicroseconds(3000);
}
digitalWrite(power, LOW); //turn off motor
}

else if (cat == '2') //Backward
{
digitalWrite(power, HIGH); //Turn motor ON
digitalWrite(directionPin, LOW); //clockwise - DOES NOT WORK  *************************************************
digitalWrite(MS2, MS2switch[0]); //controlling speed of motor
digitalWrite(MS1, MS1switch[0]); // ""
for (int x = 0; x < revSteps[3]; x++)
{
digitalWrite(clk, LOW);
delayMicroseconds(3000);
digitalWrite(clk, HIGH);
delayMicroseconds(3000);
}
digitalWrite(power, LOW); //turn off motor
}
}

}

• I trust you don't have mechanical biased loads and are using 12VDC minimum to 24VDC maximum. Also micro-stepping has inherently less torque. – Tony Stewart EE75 Apr 27 '19 at 0:49
• Can you try hardwiring the direction input of the driver to GND and see if that works? Have you double checked that the windings are correctly connected to the driver output? – Guille Apr 27 '19 at 11:23

• "as i know multiple if else if statement should end with else in the end" Not true. It is perfectly allowed for there to be no final else statement e.g. if that else statement would be empty. You said: "I can see the problem here". So please specify the exact problem which you believe you can see, instead of giving a general explanation of if-else-if programming. In the question, since 1 and 2 are the only values of cat, what do you believe is missing from a final else statement (e.g. if cat == 3) and how does that explain the reported problem when cat == 2? Thanks – SamGibson Apr 30 '19 at 1:38