I am working on a some time-critical system that will run image processing and controlling 4 SG90 servo motors. In short, I will do visual-servoing.

Since I will do visual servoing, I don't want to use software pwm for controlling & driving the servo motors. I am using Raspberry Pi 4 4GB.

According to my researches, there is two PWM channels on Pi 4, which are available on GPIO12, GPIO13, GPIO18, GPIO19. (See official Raspberry Pi Documentation)

Here, there are some questions;

  • Can I control 4 servo motors independently by using this PWM pins. I mean, for example, GPIO12 for servo1, GPIO13 for servo2, GPIO19 for servo3 and GPIO10 for servo4. Is this possible ?
  • There some libraries, pigpio and wiringpi. Which one is suitable for using pure hardware pwm?

1 Answer 1


You can only control two servos independently with the Pi's hardware PWM.

GPIO 12/18 share a channel. GPIO 13/19 share a channel.

The same settings apply to GPIO which share a channel.

E.g. If servo1 is on GPIO12 and servo2 on GPIO18 they will get the same signal (same frequency, same pulsewidth).

pigpio supports the hardware PWM features of the Pi. So you could control two servos with hardware PWM.

pigpio C hardware PWM.

pigpio also supports hardware timed PWM on all GPIO. This is suitable for servos. It is not as flexible as fully hardware PWM but is pretty much the same as using a servo HAT with a PCA9685 PWM chip.

pigpio C hardware timed servo PWM

  • Is the hardware timed PWM is the same as the software pwm? I think no. Does it uses DMA ? I don't want to face with servo jitters & noise things while I am doing hard image processing stuff. Is the hardware timed pwm is suitable for handling 4 servos ?
    – tango-1
    Apr 7, 2021 at 9:56
  • 1
    I have answered the question. If you have new questions ask a new question.
    – joan
    Apr 7, 2021 at 10:24

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.