Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

raspberrypi pulses on scope Pi blaster Improves Software PWM on Raspberry PiWithout 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

Matt Richardson

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.


Related
blog comments powered by Disqus

Related Supplies at Maker Shed

Follow

Get every new post delivered to your Inbox.

Join 26,604 other followers