PCA9685 LED never completely off.

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adammhaile
 
Posts: 77
Joined: Fri Sep 10, 2010 9:09 am

PCA9685 LED never completely off.

Post by adammhaile »

I'm using the PCA9685 to drive a bunch of LEDs but I noticed a really weird issue where the LEDs are never completely off.
The code below is simplified but I am driving some common anode RGB LEDs, so the PCA9685 is being used to sink the current on each of the LED's color channels. So, in theory, 0 should be on and 4095 should be off. This works mostly except that in the off state the LED is every so slightly still on.
It looks like since it's defaulting to low, it takes at least 1 of the 4096 steps before it switches to high (which would turn the LED off in my case).
I'd imagine this would apparently work for a common cathode setup, but I'd really like to use common anode.
Is there any way to get the LEDs to fully turn off?

Code: Select all

  //using the PCA9685 to sink the current to the LED
  pwm.setPWM(0, 0, 0);  //on
  delay(1000);
  pwm.setPWM(0, 0, 4095);  //off
  delay(1000);

User avatar
adammhaile
 
Posts: 77
Joined: Fri Sep 10, 2010 9:09 am

Re: PCA9685 LED never completely off.

Post by adammhaile »

BTW, I've also tried:

Code: Select all

  pwm.setPWM(0, 4095, 0);  //on
  delay(1000);
  pwm.setPWM(0, 0, 0);  //off
  delay(1000);

User avatar
adafruit2
 
Posts: 22145
Joined: Fri Mar 11, 2005 7:36 pm

Re: PCA9685 LED never completely off.

Post by adafruit2 »

its a trick! try setPWM(pin, 4096, 0);
does that work?

User avatar
adammhaile
 
Posts: 77
Joined: Fri Sep 10, 2010 9:09 am

Re: PCA9685 LED never completely off.

Post by adammhaile »

That worked! But, I'm confused as to why it worked. 4096 would overflow past the 12 bit input value, effectively making it 0 wouldn't it? Is this somewhere documented in the datasheet and I missed it? Any explanation of what's going on would be greatly appreciated.

Also, I added a helper to the library:

Code: Select all

void Adafruit_PWMServoDriver::setLED(uint8_t num, uint16_t val)
{
  if(val == 0)
    setPWM(num, 4096, 0);
  else 
    setPWM(num, 0, 4095 - val);
}

User avatar
adafruit2
 
Posts: 22145
Joined: Fri Mar 11, 2005 7:36 pm

Re: PCA9685 LED never completely off.

Post by adafruit2 »

4096 is a 'special number' for the chip to listen for - see datasheet for details!

If you name it 'setPin' and send a pull req on github we can merge it in

User avatar
adammhaile
 
Posts: 77
Joined: Fri Sep 10, 2010 9:09 am

Re: PCA9685 LED never completely off.

Post by adammhaile »

Ahh... makes much more sense now. Thanks for the explaination.
Pull request done: https://github.com/adafruit/Adafruit-PW ... ry/pull/10

User avatar
gregmote
 
Posts: 1
Joined: Fri Dec 27, 2013 5:53 pm

Re: PCA9685 LED never completely off.

Post by gregmote »

I am using the PWM and V+ (6v) pins to drive my (adafru.it/754) LEDs. I tried .setPWM(num, 4096, 0); but still do not see full off on my LEDs. Any clues or hints at where I should look to get these LEDs to shut off completely?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”