What is the difference between the set_PWM_dutycycle function and the hardware_PWM function in the pigpio python library when assuming the same frequency is set for both the functions. Will I get a more stable output from one versus the other? I'm using the Pi 2 Model B and need 4 separate PWM signals with different outputs but same frequency.

1 Answer 1


hardware_PWM >>> set_PWM_dutycycle >>> software PWM

where >>> is orders of magnitude better pulse stability.


  • rock solid pulses
  • large choice and range of frequencies
  • large number of steps between off and fully on


  • very stable pulses, unlikely to be affected by anything other than sustained heavy network traffic.
  • 18 different frequencies (8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320, 250, 200, 160, 100, 80, 50, 40, 20, 10)
  • limited steps between off and fully on (25 at 8000Hz, 250 at 800Hz, 4000 at 50Hz)

software PWM

  • stability depends on system activity, will be better on the four core Pi2 compared to single core Pis. Servos will jitter and LEDs will flash when the system is busy.
  • infinite choice and range of frequencies
  • infinite number of steps between off and fully on
  • Thanks for this great answer. Can you explain briefly how hardware_PWM and set_PWM_dutycycle differ internally? Like, how do they work internally?
    – Peter Zhu
    Commented Dec 30, 2015 at 14:23

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.