Page 1 of 1

Pigpio PWM

Posted: Fri Jan 24, 2020 2:45 am
by Quantum6626
I'm new to the Raspberry pi (I have the Pi 4B) and I can't find an exact answer to this question in the forums. Pigpio on their website states:

Features:
hardware timed sampling and time-stamping of GPIO 0-31 every 5 us
hardware timed PWM on all of GPIO 0-31

I need 3 GPIO's with precise PWM control and the software PWM is really bad as it flickers making it unusable, but the hardware PWM is excellent. I have been using the code (variables assigned elsewhere in code):

GPIO.hardware_PWM(PinA, Frequency, PinADutyCycle)

The problem is this code only seems to work with pins 12,13,18,19 with 12,18 and 13,19 giving out the same signal so there is only 2 usable independent signals. I don't understand why Pigpio states there is hardware timed PWM on all GPIO's when I get an error message and 0 voltage out of any other GPIO that I've tried besides 12,13,18 and 19?

The error states pigpio.error: 'GPIO has no hardware PWM'

Is there a different code or process I need to use? Is the Pigpio documentation on their website incorrect? Thank you.

Re: Pigpio PWM

Posted: Fri Jan 24, 2020 10:57 am
by rpdom
There is a difference between "hardware timed PWM" and "hardware PWM". The first uses hardware timers to trigger the software that controls the PWM. It is pretty accurate. The second does everything in hardware. It should be very accurate.

Re: Pigpio PWM

Posted: Fri Jan 24, 2020 11:16 am
by joan
pigpio supports hardware timed PWM on all GPIO on the expansion header.

Use http://abyz.me.uk/rpi/pigpio/python.htm ... _dutycycle to set the dutycycle.

Use http://abyz.me.uk/rpi/pigpio/python.htm ... _frequency to set the frequency if you don't like the default 800 Hz.

Re: Pigpio PWM

Posted: Sat Feb 01, 2020 9:57 am
by Quantum6626
Thank you. I was able to get the code to work using both hardware and hardware timed methods. Both are much better than the software timed PWM.