1
\$\begingroup\$

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.

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

}
\$\endgroup\$
  • \$\begingroup\$ I trust you don't have mechanical biased loads and are using 12VDC minimum to 24VDC maximum. Also micro-stepping has inherently less torque. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Apr 27 at 0:49
  • \$\begingroup\$ 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? \$\endgroup\$ – Guille Apr 27 at 11:23
0
\$\begingroup\$

I can see the problem here . And as i know multiple if else if statement should end with else in the end to tell the arduino if all the statement above is false then else{do this}. if-else-if ladder: Here, a user can decide among multiple options.The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed. Do this If(){ im true don't go to the else if and if im false go down} else if (){im true so go out and if I'm false go down} else{ i know everything above me are false so let me tell YOUre microcontroller that every thing is false so check again .} this link will help you .enter link description here

\$\endgroup\$
  • 2
    \$\begingroup\$ "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 \$\endgroup\$ – SamGibson Apr 30 at 1:38
0
\$\begingroup\$

Pulsing/jerking can be a symptom of trying to accelerate too fast. Your pulse rate doesn't seem very fast, but if your inertia is high, you could be marginal and you just got lucky that the one direction worked. Increase your delays and see what happens.

If you need to reach a high angular velocity and the inertia won't allow you to instantly go to that velocity, you need to increase your velocity with a constant acceleration.

See the acceleration portions of this app note: http://ww1.microchip.com/downloads/en/AppNotes/doc8017.pdf

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.