I have a 24BYJ48 stepper motor, and my main problem is that I cannot make it rotate quickly. I've understood that in order to achieve a high speed I must start at a low speed and carefully accelerate the motor to higher speeds.

I'm not quite sure how this acceleration ought to be done, though. My idea is to execute the control sequences with an initially long delay, and then decrease the delay between each time I change the sequence for the motor wires.

Below is the code I have written. When I run it, the motor accelerates for a little while, but then all of a sudden it just stops and makes a high pitched noise. code

  • tigoe.com/pcomp/code/circuits/motors/stepper-motors
    – laptop2d
    Jan 31, 2017 at 19:45
  • 1
    The Arduino manual says, that delay() function only excepts long ints > Arduino Delay.
    – auoa
    Jan 31, 2017 at 20:03
  • 1
    You didn't include your entire program. Try including it as text, not an image. Stack exchange has some syntax highlighting. Also, as auoa said, delay() only excepts long integers. Use delayMicroseconds() instead for more precision (which still uses integers).
    – Bort
    Jan 31, 2017 at 20:42

2 Answers 2


The basic technique is as you have tried to program. The time between stepper pulses if shortened to cause acceleration and lengthened to slow down. A real solution typically uses an "S" curve type acceleration profile that starts out with a slow ramp up to the acceleration rate and then as it nears the target rotational speed it slows the acceleration rate back down.

In your case you may be getting to the point where you have increased the acceleration rate too much and the motor cannot respond to it.

  • Does this mean the motor cannot go any faster? If so, are there any workarounds?
    – user2157416
    Jan 31, 2017 at 19:22
  • @user2157416 - I cannot answer your question for you. I do not know your motor characteristics nor am I in a position to unthread your code to see where any weakness that may exist. For all I know maybe the fact that you set the four output drive signals one at a time could be a problem, you may have a completely unsuitable power supply or even a stepper driver circuit that is not up to the job. Jan 31, 2017 at 19:34
  • Also the motor driver circuit can be a problem, does it handle the dead time for you? If not your code can produce short circuits within a half bridge. Or the motor current is not sufficient for high speeds.
    – auoa
    Jan 31, 2017 at 19:59
  • @auoa - the upper and lower drivers are not being distinctly controlled by software, so software can neither cause nor prevent short circuits. Dead time from the perspective of what is being controlled would merely be time when there is no applied voltage difference across a coil from the drivers, however there may still be current flow through the catch diodes from inductive decay. Feb 1, 2017 at 2:50

There are several things going on here....

  1. If the load is purely inertial and small (~ equal to the rotor inertia), acceleration typical takes only a few steps. No need to drag it out. Try some different delays after the first step.

  2. If you have a torque load (you are pushing something), at some point, during acceleration, the currents in the winding will be too small to generate the required torque. As the speed increases, the currents will decay, due to the motor back-EMF and inductance (which is very significant).

  3. Sometimes, at particular speeds, step motors exhibit a dynamic instability. That is, they start hunting...faster, slower, faster, slower, etc. until the motor "stalls". The resistance seen by the motor, looking back into the drive circuit, is the key factor here. At high speeds, the current regulator runs out of voltage and the effective resistance drops...leading to instability.

So, do some experimentation!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.