2

I was working on a project where I needed 4 different hardware PWM signals to control actuators using PWM drivers. I know that Raspberry pi has four PWM pins but the BCM2711 datasheet shows each pair [GPIO (12,13), (18,19)] is connected to the same channel. Is it possible for me to generate 4 different hardware PWM signals with different duty cycles on each pin at the same time? I use pigpio python library to generate PWM but can do c driver if necessary.

1
  • As per joan's answer the PCA9685 is certainly worth a try if a software solution does not work out. Just beware while it has 16 channels, they all share the same frequency, just the duty cycle for each one is indepenedent. If you are controlling 4 of the same thing that should be fine.
    – goldilocks
    Aug 26, 2022 at 14:04

1 Answer 1

4

The Pi has only two accessible hardware PWM channels. GPIO 12 and 18 share one setting, GPIO 13 and 19 the other. So if you set GPIO 12 to 15% dutycycle at 400Hz that will come out of GPIO 18 as well (when in PWM mode).

What sort of frequencies and dutycycles do you actually NEED?

For instance pigpio can generate hardware timed PWM at 400 Hz with 250 dutycycle steps (between off and fully on) independently on all of GPIO 0-31.

If that is not good enough you could buy one of those PCA9685 based servo drivers. They are actually general PWM drivers. They might be suitable depending on your requirements.

1
  • Thank you for answering.I need 10-15khz frequency which can vary between 25-75% duty cycles. Sep 22, 2022 at 9:48

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.