Juan Manuel Fernandez's Python Library Aims to Improve Stepper Motor Handling on the Raspberry Pi
Now available as a stable release, the StepperMotors library provides multi-motor control, event notifications, and more.
Software developer Juan Manuel Fernandez has released a Python library designed to make it easier to control stepper motors from a Raspberry Pi single-board computer (SBC) or other multi-tasking computer: the aptly-named StepperMotors library.
"Although Python and PC [Personal Computers] in general (RPI [Raspberry Pi] in particular) are not optimal for accurate timing of stepper motor pulses (OS [Operating System] scheduler + Python sleep inaccuracies and, ATM [At The Moment], Global Interpreter Lock [GIL])," Fernandez explains, "this library aims at providing a versatile tool for managing a set of stepper motors (through their drivers) in several ways that might fit specific scenarios."
Developer for a personal dynamic event-driven turret control project, the StepperMotors library is claimed to be able to max out motor acceleration curves, provides a high-level application programming interface (API) to send stepping jobs as a queue to dedicated workers, synchronizes stepping across multiple motors β dedicating a CPU core to pulsing drivers to minimize disruption, Fernandez says β and provides an event dispatcher that allows applications to be notified when stepping jobs are near completion or have finished.
In its current release the library supports a range of popular stepper motor drivers, including Adafruit's DC & Stepper Motor HAT, and is designed to be easily extended to support additional drivers in the future. Fernandez has also included linear and exponential acceleration profiles β alongside a custom acceleration profile that benchmarks motors to determine their maximum acceleration.
The library is available through the pip
package manager, with the source code published to GitHub under the permissive MIT license; additional information is available on Fernandez's Reddit post.