Problem with I2C and PCA9685 writing all 16 outputs in one go...

Hi,

in the current project, i used a pca9685 pwm ic via I2C. To speed up the communication i used the adafruit pwm library for the pca9685 and modified it, so i can write all registers for the 16 outputs in one go. The library use a 400kHz I2C communication. So, after the main register settings i set the adress of the led0 output, auto increment is enabled, writing 4 bytes for led0, writing 4 bytes for led1, writing 4 bytes for led2, etc...

This works fine, but i can only write 7 outputs with this method, outputs 8 to 16 don't work.

Writing just 6 outputs, end the I2C transmission, start it again with output 7 and writing 6 outputs in one go, etc. works. So, it looks like that the pca9685 or the arduino is running "out of sync" or similar using long I2C communication? But, I2C is a synchron protocol, with a clock line, so this shouldn't be the problem.

Does anyone know if there is problem with the autoincrement on the pca9685 with more than around 30 registers? Or does anyone have a suggestion why it doesn't work that way?

Thanks!

Ciao Martin

Where is your code? The Wire library has a 32-byte maximum transmission size for one packet, if that answers your question.

Ah... that explains my problems. Thanks for your answer, i increased the Buffer in the Wire.h and TWI.h file to 96 Bytes. Now it works beautifully... :-)

Hi Machtl,

could your help with your modified Adafruit libary. I would like to drive 6 step motors with an PCA9685 I2C and Arduino Mega.

I used setPWM with 30 us delay and so they work fine, but with delay. I would like to drive them at one, but without delay they donot work.

Could you help me where I should modify the Adafruit_PWMServoDriver.ccp code?

Thanks

Balint