PWM Output

Has anyone measured the actual pulse width of the PWM outputs? Using the example servo code provided by Emlid, I’ve found that the value specified in the program does not match the output as shown by an oscilloscope.

Navio Input, Oscilloscope (microseconds)
1000 866
1100 952
1200 1042
1300 1126
1400 1216
1500 1300
1600 1390
1700 1474
1800 1564
1900 1648
2000 1736

Lars,

Do you have the latest version of examples? PCA9685 uses an external oscillator and support for it in the driver was added on 15 Dec.

Could you please provide scope shots so that we can investigate it further? You can send them to support@emlid.com

I downloaded the latest drivers and examples and that significantly reduced the difference between input and output. It appears to still be off, at most by 1.5%. Not sure what the maximum acceptable error is but I would imagine for most applications, this is probably good enough.

1000 1012
1100 1112
1200 1216
1300 1316
1400 1420
1500 1520
1600 1624
1700 1722
1800 1826
1900 1926
2000 2030

I wasnt really bothered about pwm output as the chip should be accurate to 1/4096. I dont have an oscilloscope but on the arduino I dithered the pwm output and it was less acurate than that. (see old graphics stuff for dithering examples)

I remember your previous post about improving it to 0.15% at 1000 and I’ve implemented the changes, but I’ve found it disagrees with the center of my ESC’s (now the ESC could be wrong of course) they say they should center at 1460 but I’m finding the center closer to 1475 which is around a 1% difference.

I don’t remember if you checked more than just 1000 micro seconds but it might be an idea to check up to 2000 too. I can of course modify my implementation to center correctly but without an oscilloscope I cant check the upper and lower end’s.

Another driver for the same chip multiplies the PWM frequency by 0.9 instead of altering the clock frequency (adafruit) but don’t know if that’s accurate either.

If you pull latest updates from the repository you will see improved results. PWM is accurate to 3uS now.

Thank you :slight_smile: