TLDR; how to smoothly run two or more independent stepper-motors from a raspberry?

I have been reading, testing, monitoring and finally now asking to figure this out.

I am attempting to control two stepper motors (Nema 23) through Igus dryve D8 motor controllers. Controlling the motor is fairly straight forward. The controller expects a square wave input where the frequency controls the motor speed.

Using the fantastic pigpio-library from joan I am, at last, confidently able to run a motor smoothly - including ramped acceleration for start/stop. I start the motor by sending a wavechain consisting of a 250ms ramp-up wave followed by a repeating "steady wave" at the desired frequency/RPM.

So happy to finally seeing everything work! Well, not everything... just the single motor for testing. It turns out while adding the second motor+controller my waves won't run simultaneously. I've confirmed with piscope that the second wave stops the first one, allowing only one motor to run at a time.

Back to reading which confirms my findings - pigpio can only send a single wavechain at a time. I've been all over the place trying to solve this. I am slowly starting to understand that although it works just fine with a single motor, controlling two or more simply can not be done on a sole raspberry pi. Right???

At this point I'm simply looking for someone with the know-how to confirm that yes, my conclusions are correct - I'm losing it trying to figure this out. I've played with the PWM-functions but I don't see how that could work with my start/stop frequency ramps over a 250ms window for example.

I think I need to start looking for some external GPIO-interface that can send the pulse waves on behalf of the raspberry. Hopefully there's something reliable that can even do "automatic" rampup/down etc given a start and target frequency, for example so that the raspberry can only do simple one-off commands.

Thanks for your patience.

2 Answers 2


This seems like using a sledgehammer to crack a nut. Waves is overkill.

All you need to do is generate a square wave using gpioPWM(user_gpio, dutycycle) which you can do on multiple pins.

Set frequency using gpioSetPWMfrequency(user_gpio, frequency) and ramp up in a few steps after a short delay.

  • Thanks for your time. Me overcomplicating this is a very real possibility. However, with waves I am able to very precisely ramp starts/stops smoothly from frequency X to frequency Y, say 10 RPM to 400 RPM. Additionally, this transition can be programmed to happen over 250ms or X steps quite precisely. I'd not be able to precisely do the same with PWM, it'd rather have to be app-level timing (right?). And what's worse is that these PWM-functions can only operate on a few preset frequencies, so I'd have to jump between static speeds rather than the smooth transition I'm aiming for..
    – anrola
    Commented Feb 1 at 11:55
  • @anrola I suggested pigpio because that is what you used. If you use hardware PWM you can use any frequency (up to 100MHz with period to 10nSec precision) and frankly this is easier than trying to program waves - which is normally used for complex waveforms not simple square waves.
    – Milliways
    Commented Feb 1 at 12:27
  • Right, in which case I'd be able to control 2 separate PWM outputs - good enough for now. However, the precision issue still remains, right? I'd not be able to "move exactly 3200 steps" for instance.
    – anrola
    Commented Feb 1 at 13:00

I solved this problem, PWM didn’t cut it for me, as I wanted motors to run independently, potentially being of different kind and max PPS and torque. I also needed to reach max speed as soon as possible which no available solution did for me. So wrote a library to do that: Smooth (de-)acceleration with multiple strategies. Linear, exponential and custom (to feed the custom one you need to benchmark your motor with the benchmark module). You can add a hypothetically max 13 motors exhausting 26GPIO pins for 13 step and direction sets (or less with stepping modes & sleepPin connected to GPIO pins).

It also responds to sudden, unplanned, changes in direction smoothly.

I use setOutput HIGH and LOW, to manage each motor, the results are super smooth.

Checkout multiprocess section in README.


demo videos: 2 steppers https://www.youtube.com/watch?v=3OWGrZM90M8

4 steppers https://www.youtube.com/watch?v=WprF3Dy7BbE

Your Answer

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

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