Jerky Motion in Stepper using S-Curve acceleration

Hello all.

I am experiencing jerky behaviour while accelerating my stepper. The stepper seems to skip or jump to the nearest full step when getting up to speed. I have developed my own ‘S-Curve’ profiles to make sure that jerk is minimized. I’ve attached an image of the shapes (but the units are meaningless and arbitrary)

The strange thing is that the stepper skips fairly inconsistently. Sometimes it ramps up to speed perfectly and has perfect motion, other times it skips 2 or 3 times in a single acceleration.


  • Using a Nema 17 stepper motor - 0.9 degree per step.
  • DRV8825 Pololu stepper driver. Calibrated to 1.5 A per coil
  • Load: Small 3mm aluminum plate connected via timing belt and pulley.


  • Using a timer interrupt to toggle the step pin.
  • Adjust stepperspeed by varying the timer counter on the fly.
  • Capable of 32 microstepping but 8 microstepping seems to be the most promising performance.

When I accelerate, I transition between 200 different ‘speeds’ (timer counters) in about 0.5 seconds. The final speed is not ridiculously fast and the system seems to handle it no problem. The issue is getting up to speed. I have tried microsteps of 32 and 16 but it doesn’t seem to help.

I experience no issues when decelerating using the same 200 different speeds. If anybody could impart some wisdom on me it would be greatly appreciated.

Probably you are getting a resonance - adding mechanical damping can make a difference (is the
motor connected to its actual load? - you can only really measure performance when it is).

First though check that the driver isn't overloading, DRV8825 will get hot at 1.5A - total on resistance
of hi and lo-side drivers is about 500 milliohms, so probably dissipating at least 2.5W in the chip. Thermal
cut-out will cause the motor to stutter.

You can independently experiment with max velocity and max acceleration... Very slow acceleration allows
you to see (hear) the various resonances.

Thanks for the reply MarkT - resonance wasn’t the issue but stretching out the accelerations as you suggested helped find another bug ;). I found the source of my issues and I am documenting it here in case someone else benefits from it.

The step pin of my stepper is toggled by a timer interrupt. Whenever I want to change speed I update the timer counter (OCRxA) to its new value. When I update the timer counter (OCRxA = MY_NEW_VALUE) I assumed that the timer would raise an interrupt and trigger if the timer counter (TCNTx) was greater than OCRxA.

What I found out is that the timer doesn’t in fact clear when TCNTxA > OCRxA. Instead TCNTxA will keep on counting until it overflows at 65536 and then start from zero. The extra overflow is a delay of ~3 ms and is enough to cause jerky motions in the stepper but it is only an issue if TCNTx is larger than my new OCRxA value.

It might be easier to explain with an example . Assume the following scenario/configuration:
TCNTx : 800 ← The timer is currently at 800
OCRxA : 1000 ← The timer will interrupt when it reaches 1000

Update OCRxA : 500 ← Update OCRxA to 500 at some point.

TCNTx = 801 ← Timer increases to 801 and continues to increment to 65536
OCRxA = 500 ← The timer will interrupt when TCNTx overflows and reaches 500 again.

The solution was to set the timer to zero (TCNTx = 0) everytime I change the stepper speed.

Yes, that would explain it. Had you considered just using a regular interrupt and testing in the ISR for whether to step or not?
Then straightforward DDS techniques apply.

I wouldn't worry about smoothing the acceleration, just discover the max acceleration and stick within it, resonances
are more of a problem perhaps. Finer microstepping can help with that, mechanical damping can help.