Pi-blaster Improves Software PWM on Raspberry Pi

Matt Richardson is a San Francisco-based creative technologist and Contributing Editor at MAKE. He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.

Matt Richardson is a San Francisco-based creative technologist and Contributing Editor at MAKE. He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

We respect your privacy and take protecting it seriously

Without an external digital to analog converter circuit, getting pulse width modulation out of more than a single PWM pin on the Raspberry Pi could be achieved by writing your own code to set the pins high and low at the appropriate time (i.e. bitbanging). The solution isn’t perfect, however. Since you’re sharing the CPU of the Raspberry Pi with other processes that are running simultaneously, you can’t rely on getting the clock cycle you need to change the state of the pin at just the right time. This means that pulsing pins for fading LED effects, mixing colors with RGB LEDs, or controlling servos will have unexpected effects.

Thomas Sarlandie from TB Ideas needed PWM for a project but didn’t have the time to wait for the circuitry he needed. While exploring his options with software PWM, he came across ServoBlaster, which cleverly offloads the task of switching the pins to the direct memory access (DMA) controller. Since ServoBlaster was meant for controlling hobby servo motors using pulses, it didn’t give Thomas the full 0 to 100% PWM control he sought. After making some adjustments to the code, he had what he wanted: PWM control on the GPIO pins of the Raspberry Pi. His code, pi-blaster, is now available to all of us so that we can pulse the pins on our Pis all we want! [via Hack A Day]

Matt Richardson is a San Francisco-based creative technologist and Contributing Editor at MAKE. He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.

Matt Richardson is a San Francisco-based creative technologist and Contributing Editor at MAKE. He’s the co-author of Getting Started with Raspberry Pi and the author of Getting Started with BeagleBone.