From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper motor turning only in one direction, stalling in opposite direction

Hello,

 

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. Please share your feedback about this. Thank you. 

 

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;
cat = Serial.read();

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
}
}

}

0 Kudos
Message 1 of 30
(3,537 Views)

Is your question in any way related to LabVIEW?

 

You posted Arduino code.  If you are using an Arduino and are having problems, you should find an Arduino forum somewhere on the web to post your question.

0 Kudos
Message 2 of 30
(3,529 Views)

Which arduino are you using? Is it one that has a 3v3 or 5v logic levels?

 

Assuming 5v:

You should set the driver to sourcing mode.

Sourcing mode on that driver will have a logic 0 when your arduino pin is low and and logic 1 when you set the pin high

 

Assuming 3v3

Sinking mode BUT via a transistor or optocoupler pulling the driver's (internally pulled up) lines to ground... This would also work for the 5v versions but requires the extra components.

 

0xDEAD

0 Kudos
Message 3 of 30
(3,471 Views)

Hello,

 

Thanks for replying and giving your feedback. I am using the Arduino Mega. I set the driver to the sourcing mode and I still have the same problem. The only difference is that the digitalWrite(directionPin, LOW) works and the digitalWrite(directionPin, HIGH) stalls. It is clear that the direction pin stalls when it is active, but I have no idea why... Do you have any other suggestion?

0 Kudos
Message 4 of 30
(3,456 Views)

The mega is 5v logic level, so sourcing is correct. I cant see anything wrong with your code either.

 

Since the driver works with whatever its pullup (sinking) /pulldown (sourcing) is directing towards, can you try another pin or verify the output of the arduino pin with a scope or multimeter?

 

There is a possibility the pin was damaged by pulling to ground through it when you were set in sinking mode.

 

0xDEAD

0 Kudos
Message 5 of 30
(3,445 Views)

You can also eliminate the arduino from this by directly connecting that direction pin of the driver board to either 5V or GND and see if it works as it should, 

 

If this works OK, the issue is the arduino (probably just that DIO pin), if not the issue is in the motor driver board.

 

0xDEAD

0 Kudos
Message 6 of 30
(3,443 Views)

When I connected the Direction Pin directly to GND, the motor moved (but not entirely correctly, it moved around 1/10 of what it was supposed to and with much more vibration). When I connected to the 5V output of the Arduino, the motor did not even move.

 

I reset the Arduino and I measured the 5V output pin of Arduino. It gave me around 5V, but after I ran the program trying to rotate the motor, the same pin gives me 1.3V...

0 Kudos
Message 7 of 30
(3,435 Views)

But it shouldn't be the Arduino since I am also controlling the other pins on the driver...

0 Kudos
Message 8 of 30
(3,433 Views)

Is the Gnd of the arduino commoned with the Gnd on the motor driver?

 

 

0 Kudos
Message 9 of 30
(3,428 Views)

Yes, it is. And I just tested with a different driver (same model) and same thing happened. I am attaching a picture of the motor driver pin out in the sourcing mode and the motor 8 lead wire configuration. I imagine it is something wrong with my wiring, but I cannot see what it is. The wht/org & wht/blck are in series to each other, same thing with wht/red & wht/ylw. In the four pins to the right, I have from top to bottom: blck, org, red, and ylw. Meaning that phase A is black and orange and phase B is red and yellow. Besides the direction pin, it looks like all the rest of the pins to the left are working fine (MS1, MS2, ON/OFF, clk, and external power).

 

Thank you so much for trying to help me out. Please let me know if you have any other suggestion. I'm trying all I can to make this work...

 

 

Download All
0 Kudos
Message 10 of 30
(3,423 Views)