Justin Grimes' Robot Motion Turns a Raspberry Pi Into a Python-Powered MOSFET-Style ESC

If you need to control brushless DC motors but don't have an ESC to hand, this handy Python application will work in its place.

Developer Justin Grimes has released a handy tool, which turns any model of Raspberry Pi with 40-pin general-purpose input/output (GPIO) header, including the low-cost Raspberry Pi Zero family, into a two-channel electronic speed controller (ESC).

"This application is intended to turn any Raspberry Pi with a 40-pin GPIO header into a two channel Electronic Speed Control (ESC) for brushed DC motors arranged in a skid-steer configuration," Grimes explains of the Python-based project. "Perfect for skid steer robots or other electric vehicles. This application assumes the user will attach the GPIO pins to external relays that are capable of handling the load requirements of the specific electric motors being used [and] will supply a signal to the relays via GPIO output that causes the relays to emulate the behavior of a MOSFET-style ESC."

In its initial release, the ESC software is programmed to listen out for input from the keyboard: the WASD cluster, familiar to anyone who's played a first-person shooter in the last few decades, handles basic movement, with QEZC providing control over individual motor channels. The number keys provide access to ten-step speed control, though Grimes notes the speed is applied to both channels equally.

The software wars written with a Raspberry Pi 2 Model B in mind, but Grimes suggests it's applicable to any model with one key caveat: it has to be configured to run at the correct speed. "After installation of this application the timing of DefaultDwellDuration must be adjusted to match the attached hardware," Grimes explains. "Running the relays too quickly will result in reduced relay performance and longevity. Running the relays too slowly will provide poor performance and throttle response."

"The GPIO [pins] of most Raspberry Pi computers can achieve higher frequencies than most relays, but every configuration is different. It is best to look up the datasheet for the relays being used and set the DefaultDwellDuration configuration variables to align with the capabilities of your relays."

The software and instructions for its use are available on Grimes' GitHub repository, under the reciprocal GNU General Public License 3.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Get our weekly newsletter when you join Hackster.
Latest articles
Read more
Related articles