I've got a serious problem about Pi. It is - I can play sound just fine with a python script either with:

import pygame


import os
os.system("aplay ...")

I can also mess around with my PWM servo like a boss:

from RPIO import PWM
servo = PWM.Servo()
servo.set_servo(pin, 1000)

Funny things happen when you want to connect these two things:

  1. Sound doesn't work at all
  2. Servo does random moves till I shut the program down. Even after servo.stop()

Is it me not noticing something obvious? I really need to make it work, but nothing helps. How can I solve that?


4 Answers 4


RPIO, like pigpio, servoblaster, piblaster, and possibly others, use DMA to time the servo pulses. In effect the pulses are hardware timed. In contrast to software PWM they suffer little if any jitter.

The DMA timing is achieved by pacing transfers from a Broadcom SOC peripheral. There are only two which may be used, PWM and PCM. Initialising the peripherals for use in DMA pacing conflicts with their use in audio applications and vice versa.

I know pigpio and servoblaster allow you to choose the peripheral during initialisation. pigpio defaults to the lesser used PCM.

Perhaps check the RPIO documentation to see if it has an option to select PCM?

  • I switched to PIGPIO and it works great, thanks! :) Unfortunately I couldn't find PCM support for RPIO
    – Michał
    May 9, 2014 at 14:50

I talk by head but I think that the internal modulator of the sound procesing and the hw PWM module are somehow interconnected. you might want to check that. You can try a USB sound card (2€, free shipping) or use software PWM


The BMC2835 has 2 independent PWM channels, which are used for analog audio output via a simple filter. The PWM can be routed to 2 GPIO pins (only 1 of which is accessible on the Pi - BMC18) in one of the alternate modes.

As other respondents have indicated there are a number of "solutions" for software PWM (with varying limitations). I have not actually used any of these.

If you need to use hardware PWM in conjunction with audio, then some audio board is necessary. There are quite a few options, ranging from simple USB sound to high quality audio using I2S interface.


I've solved that with servoblaster using --pcm option in /etc/init.d/servoblaster as reported here https://github.com/richardghirst/PiBits/tree/master/ServoBlaster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.