Go Down

Topic: New library for the PCA9685 16-channel PWM driver module, feedback welcomed! (Read 122 times) previous topic - next topic

NachtRaveVL

Hello,

In the past month, I have forked and rewritten a library to control the PCA9685 16-channel PWM driver board. The library can be found and downloaded here: https://github.com/NachtRaveVL/PCA9685-Arduino

The module that I'm referring to can be viewed/bought here: https://www.amazon.com/Adafruit-16-Channel-12-bit-Servo-Driver/dp/B00E4WEXO4 (although there are a lot of different manufacturers that make the same module).

The reasoning behind rewriting this library had much to do with just the fact that many of the existing ones were poorly coded and did not handle the entire functionality of the chip.

For example, with the popular Adafruit library (available here), you absolutely must set the PWM frequency in order for the library to even work - if you do not do that then it never sets the auto-increment value correctly for the other functions to work. It also sets the prescaler value incorrectly, and when it sets it it uses extra commands that are unnecessary and makes for a delay of 3ms instead of the 0.5ms clearly stated in the datasheet (for the oscillator to get up and running). Additionally, it does not do load distributing across the entire phase width, thus causing a large sink across all channels at the start of the phase cycle. It also forces you to use Wire1 for the Due/Zero/etc. instead of allowing you to specify which i2c line you wish to use.

Other libraries seem to also have these as well as various other issues, so I took it upon myself to fix things up and make them a lot happier. The library I have adapted from and modified fixes a lot of those issues while exposing the entire functionality that the chip provides, as well as providing additional assistants (such as Servo control) and other goodies.

Additionally, the library supports the SoftwareI2CLibrary interface for processors like the ATtiny85, which don't have standardized i2c ports. So long as the processor can run at a minimum of 4Mhz to run the minimum required 100kHz baud rate of the module (in standard i2c mode), you can set up those boards to talk to this module.

Feedback is of course welcomed, as is requests for additional functionality, etc.

On a side note, I also have replaced the 10v 1000uF capacitor pre-installed on the board with a 10v 3300uF capacitor, which seems to have helped with the larger 2A servos I've been playing around with.



Thanks for looking!

roboticboyer

Hi NachtRaveVL

Please could you add the examples inside a directory named "examples" inside the Github?
This could help, and it's more compliant with the Arduino library structure.

I also suggest to activate the Issues on Github. It could help you to track the issues and to receive feedback by others.

Giorgio   
Il mio blog: http://roboticboyer.wordpress.com
GitHub: https://github.com/roboticboyer

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy