I am developing a camera tracker to follow objects identified via OpenCV in a dedicated environment on mt Pi3. Currently the two SG90 servos are controlled by software PWM using RPi.GPIO - but the tracking is jittery and unstable.
I am considering implementing hardware PWM to improve stability. I am aware of pigpio, wiringpi and RPIO that offer hardware PWM, but as far as I can tell(?) they currently support only up to Python 3.3 and I am using Python 3.5.
Any suggestions for a library to work with Python 3.5 or 3.6? So far I have stumbled on pwmpy that requires a kernel overlay: https://github.com/scottellis/pwmpy
Results of software PWM vs hardware PWM on servo stability
After sorting out the Python version issues (thx @joan), I can now report back on the performance of the two tracking servo's using software and hardware PWM.
Software PWM implemented via
Hardware PWM implemented via
Comparing the Standard Deviations clearly shows the improved stability of hardware PWM. Since the image processing is taking a lot of CPU resources, software PWM suffers and is visibly jittery with occasional big jumps. None of that with the hardware PWM and the bit of variation reflected in the numbers is probably due to slight variations in the image object identification and not the PWM server.