Closed mbazzo closed 6 years ago
Hello! The following function documentation was accidentally left out of the README:
// set a single PWM channel with a 16-bit ON val and a 16-bit OFF val
int PCA9685_setPWMVal(int fd, unsigned char addr, unsigned char reg,
unsigned int on, unsigned int off);
Remember though, as with the other functions, only the low 12 bits of the 16-bit ON and OFF values are used on the PCA9685. Also keep in mind that this function does not use a combined transaction so it should be slower on a per-channel basis than the speedy PCA9685_setPWMVals()
.
Please let me know if this works for you or if your requirements are different.
Also, have a look at PCA9685demo
. That shows how to set individual channels while still using . You just keep track of all 16 of your values in an array and only change the values for the channels you want to adjust.
Edit: Must not have finished my coffee.. From the quickstart example:setAllPWM()
unsigned int setOnVals[_PCA9685_CHANS] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned int setOffVals[_PCA9685_CHANS] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// blink endlessly
while (1) {
// setup random values array (seizure mode)
int i;
for (i=0; i<_PCA9685_CHANS; i++) {
int random = rand();
int value = (float) random / (float) RAND_MAX * _PCA9685_MAXVAL;
setOffVals[i] = value;
}
// set the on and off vals on the PCA9685
PCA9685_setPWMVals(fd, addr, setOnVals, setOffVals);
}
If you check here you will see an example that worked: https://github.com/pvint/fade9685/commit/89578141407f9eb506f5fa170a79d237a063a882#diff-e1029dd5a7350ee44c988fd619e3baa4
(Note that this was just an early "proof of concept" and has since changed, but it worked)
Closing for lack of activity. Please open a new issue if you still require assistance.
Hello, I would like to know how to connect only one channel of PCA9685 through this code. I am using "PCA9685_setAllPWM", and connect all channels, I would like to control the independent channels. Test like that and it did not work. setPWMVals (_pca, 0x40, 0, 1, 2000);