Has anyone considered porting AccelStepper to Raspberry PI

1,758 views
Skip to first unread message

Aaron Newsome

unread,
Sep 7, 2021, 12:53:01 PM9/7/21
to accelstepper
I'm having a real hard time finding a decent C++ library for controlling steppers on a Raspberry PI.

After a few days of googling, I've found many people looking for the same thing but no good solutions.

Most of the responses say stuff like, "don't bother with C++, just use Python" or something like that. I also see a lot of responses with something like, just use the PI to talk to an Arduino via serial since there's C++ stepper libraries already for the Arduino (like AccelStepper).

I also see a lot of responses trying to convince the original poster that it's just wrong and dumb to try and control multiple stepper motors with a PI and they should use the best tool for the job, and so on.

None of these options really work for me so I thought I'd post here and see if anyone has ported AccelStepper to the PI or if anyone knows of a C++ library that exists already for the PI.

I'd like functionality to what AccelStepper already does, acceleration, multi-stepper, blocking and non-blocking moves, etc. AccelStepper already has most of what I'd like in a library.

Mike McCauley

unread,
Sep 7, 2021, 5:28:36 PM9/7/21
to accelstepper, Aaron Newsome
Hello,

AccelStepper was designed for use in a dedicated, embedded processor such as
Arduinos etc. It is CPU bound, and depends (at lteast for fast stepping) on
not sharing the processor with other processes. I dont think that (as written)
it would make a good candidate for a process in a multiprocessing system such
as Linux.

Maybe there are some parts of Linux CNC you could use?

Cheers.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com 5R3MRFM2+X6
Phone +61 7 5598-7474



Aaron Newsome

unread,
Sep 7, 2021, 6:39:00 PM9/7/21
to accelstepper
Thanks for that response Mike. I hadn't considered LinuxCNC for years but it got me thinking about how I have my laser cutter and CNC machines setup. Both are setup exactly how I'm looking to avoid with my original post here. That is, both my Laser and CNC are using a Raspberry PI for the front end software, UI, networking, disk storage, etc and they both have an Arduino doing the pulses to the stepper controllers. In my case I'm using GRBL running on the Arduino.

So maybe I'm on a fool's errand. Maybe it really is just easier to run the front end on the PI and run the stepper control on the arduino or like my present project, using an ESP32.

The main goal here is to get more pulses to the stepper controller. Another poster here in the forum got me thinking to dedicate an Arduino to each stepper, which I've also been thinking about.

Also Mike, I wasn't necessarily considering writing a stepper program to run under Linux on the PI. I was thinking more along the lines of running the stepper code directly on the bare metal with something like the Circle project that I've been looking at. If I could manage to get that working, I'd have a PI that essentially worked like a microcontroller, a really fast one at about 5 times the speed of the ESP32 with a heck of a lot more ram and storage, for basically no cost since I already own plenty of PIs. 

Seth Perkins

unread,
Oct 14, 2021, 6:42:07 PM10/14/21
to accelstepper
Hello, I know this forum is slightly old but I have ported mikems accel stepperAccel library to work with the raspberry pi pico. I am not a great cpp programmer but I managed to get it working on an RP2040. I haven't exhaustively tested to  ensure full functionality of the library but everything I have tried has worked so far including the accelerations. Hats off to mikem for the fantastic library. Let me know if you want to try. I have not ported the multi stepper library.

Aaron Newsome

unread,
Oct 14, 2021, 8:29:42 PM10/14/21
to accels...@googlegroups.com
This is awesome Seth. Thanks for posting this. I haven't tried the
Raspberry Pi Pico yet but I've been meaning to give it a try for some
other projects.

If you'd rather not post your port of the library, please contact me
directly via email. I'll check out the specs on the Pico and order a
few ASAP.

On Thu, Oct 14, 2021 at 3:42 PM Seth Perkins <se...@planetrider.org> wrote:
>
> Hello, I know this forum is slightly old but I have ported mikems accel stepperAccel library to work with the raspberry pi pico. I am not a great cpp programmer but I managed to get it working on an RP2040. I haven't exhaustively tested to ensure full functionality of the library but everything I have tried has worked so far including the accelerations. Hats off to mikem for the fantastic library. Let me know if you want to try. I have not ported the multi stepper library.
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/Wxy6cNKM3U4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/82f632cf-7282-498b-aa0b-ab3a4f076624n%40googlegroups.com.

Seth Perkins

unread,
Oct 15, 2021, 7:21:23 PM10/15/21
to accelstepper

It can drive motors very quickly! I was at about 30000 steps/sec I believe with accel and decel when my drive went into protection mode.

Aaron Newsome

unread,
Oct 25, 2021, 11:20:20 AM10/25/21
to accelstepper
I'd really like to give the Pico port a try. Any chance you can send me a link to the code?

Vaughn Varma

unread,
May 5, 2022, 1:59:34 PM5/5/22
to accelstepper
did you get ahold of that ported library? 
I am about to start porting it myself if I can't find it, but really don't want to if I can help it, as I'm already behind on my projects.

A. Craig West

unread,
May 5, 2022, 2:58:42 PM5/5/22
to accels...@googlegroups.com
I've been running accelstepper on the pico with pretty much no porting required at all. I made a PR recently to make it easier to implement accelstepper with interrupts, but it wasn't necessary for it to work

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/2f42f882-18c3-4bfa-9f5f-4346d0cba469n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages