1

I am running a Pololu A4988 Stepper driver with two (soon to be three) steppers using the AccelStepper library. I have wired 1/8th microstepping on both as smooth running is important.

The motors run fine however, when running simultaneously, if Stepper 1 finishes its move before the Stepper 2, there is a marked increase in speed in the Stepper 2 (evident audibly and visually).

The code I use to run the motors is:

void MoveAccelXY(int Xm, int Ym) // function 6
{
  X_Axis.moveTo(Xm);
  Y_Axis.moveTo(Ym);
  while(X_Axis.distanceToGo() !=0 || Y_Axis.distanceToGo() !=0)
  {
    X_Axis.run();
    Y_Axis.run();
  }
  Xpos = X_Axis.currentPosition();
  Ypos = Y_Axis.currentPosition();
  Serial.print("X" + Xpos);
  delay(50);
  Serial.print("Y" + Ypos);
  delay(50);      
  Serial.print("C");
}

I would like there to be no speed drop on any steppers. Increasing the input voltage does not have an effect.

Is the Arduino clock speed the culprit?

  • Do you set the maximum speed with setMaxSpeed() ? – Craig Aug 29 '18 at 16:34
2

Without seeing the rest of your code, the best guess - and I think it is quite likely - is the use of delay() and printing within the stepper function. With 2 motors running, and even ignoring the printing time, there will be a total of 200ms taken up by the delays. That means each motor gets serviced a maximum of 5x/sec. Stop one motor, and the other one can double that to 10x/sec.

Look at the Blink Without Delay example for one way of managing timed events without calling delay(). The SimpleTimer library provides another.

Update:

...run() events are triggered within a while() loop ...

Ah, yes, I see that. So it looks like only one motor could run at a time - the while() loop runs until this motor reaches its target. But you said you run two at a time. So yes, I think understanding the rest of the code will help.

  • This seems most likely. See the documentation for run() airspayce.com/mikem/arduino/AccelStepper/… – Craig Aug 29 '18 at 14:54
  • Thanks for the feedback. The function itself is called from the void loop() function when the correct format of bytes is received through the serial port. The actual run() events are triggered within a while() loop so the delay functions only trigger after the motors have moved. I can post the rest of my code if you think this will help? – MJ2507 Aug 29 '18 at 16:06
  • @MJ2507 You may have the max speed (max steps/second) set too high. If it is too high it will be limited by the MCU clock speed. You can try reducing the max speed until the second motor doesn't speed up after the first stops. – Craig Aug 30 '18 at 21:17
0

Why would the clockspeed change when driving multiple motors at the same time?

How do you power the motors and Arduino?

I suspect that your power supply is the problem. Running 2 motors likely doubles the current consumption. Try to measure the input voltage, does it drop when driving both motors?

You should check the current your motors can consume and compare with what your power supply may provide. (Also keep the 1A limit of the driver in mind)

  • I don't think this would be an issue with stepper motors. Since they move a fixed distance with every step they should only move as fast as the pulses arrive from the arduino. – Craig Aug 29 '18 at 14:52
  • it is powered by a 30V 2A DC power supply. There are no noticeable voltage drops when it is run. The maximum current of each stepper is 1A but i think both together I don't see anything higher than 1A total (running at around 12V). – MJ2507 Aug 29 '18 at 16:08

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.