7

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.

Peter Zhu
  • 278
  • 3
  • 12

1 Answers1

10

hardware_PWM >>> set_PWM_dutycycle >>> software PWM

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

hardware_PWM

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

set_PWM_dutycycle

  • 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
joan
  • 71,852
  • 5
  • 76
  • 108