RGB LED C/A Strips on PCA9685

Hello,
I'm tinkering with a project where I've got 14x common anode RGB LED strips that I'm trying to drive brightness and color via a single Arduino. I'm attempting this via PWM outputs driving IRF540N MOSFETs (one MOSFET for each color color trace on each strip), giving me a grand total of 42 MOSFETS and 42 PWM outputs. The LED strips are 12vdc, with the circuit being identical to that shown in Step 2 of the following Instructable - https://www.instructables.com/Driving-RGB-LED-strips-off-an-Arduino/.

Because I need so many PWM outputs to complete this project, I have connected 3x PCA9685 boards using I2C communications (16ch PWM breakout board). While intended for servo use, the PWM output shouldn't care what it's driving, so the IC should work regardless of LED or servo connected. Each PCA9685 has a different I2C address, as outlined in the provided code. I've been following the Adafruit PCA9685 tutorial for guidance on connections and programming - Overview | Adafruit PCA9685 16-Channel Servo Driver | Adafruit Learning System.

I'm having limited success with this so far - I've been able to drive individual colors on each strip fairly well, but seem to be getting a "bleed over" from one strip to the next. For instance, the following code is intended to turn Strip 1 (address 0x40, outputs 0, 1, 2) to purple by turning on RED and BLUE segments of the RGB LED. However, Strip 2 has RED LEDs turned on, even though I'm not calling for them on address 0x40, output 3. This seems to a common theme regardless of which strip I attempt to power.

For power input, I've got a benchtop power supply giving me 12vdc, so current draw shouldn't be a problem. All grounds are connected between everything, and I've not identified any short circuits anywhere. I'm hoping someone has come across a similar issue with this type of project and might be able to give me some advice on what to take a look at.

/*********************************************************************************************
** Declare required libraries to include                                                    **
*********************************************************************************************/
#include <Wire.h>                                     // Include library for I2C Comms      //
#include <Adafruit_PWMServoDriver.h>                  // Include library for PCA9685 board  //
/*********************************************************************************************
** Declare all program constants                                                            **
*********************************************************************************************/
Adafruit_PWMServoDriver pwmBoard_1 = Adafruit_PWMServoDriver(0x40, Wire);
Adafruit_PWMServoDriver pwmBoard_2 = Adafruit_PWMServoDriver(0x41, Wire);
Adafruit_PWMServoDriver pwmBoard_3 = Adafruit_PWMServoDriver(0x42, Wire);
/*********************************************************************************************
** Method Setup(). This is an Arduino IDE method which is called upon boot or restart.      **
** It is only called one time and then control goes to the main loop, which loops           **
** indefinately.                                                                            **
*********************************************************************************************/
void setup() {                                        // Arduino standard setup method      //
  Serial.begin(9600);                                 // Initialize serial communications   //
  Wire.begin();                                       // Initialize I2C communications      //

  pwmBoard_1.begin();                                 // Initialize PWM on Board 1          //
  pwmBoard_1.setPWMFreq(1600);                        // Set PWM frequency for Board 1      //

  pwmBoard_2.begin();                                 // Initialize PWM on Board 2          //
  pwmBoard_2.setPWMFreq(1600);                        // Set PWM frequency for Board 2      //

  pwmBoard_3.begin();                                 // Initialize PWM on Board 3          //
  pwmBoard_3.setPWMFreq(1600);                        // Set PWM frequency for Board 3      //
} // of method setup()                                //------------------------------------//
/*********************************************************************************************
** This is the main program for the Arduino IDE, it is an infinite loop and keeps on        **
** repeating.                                                                               **
*********************************************************************************************/
void loop() {                                         // Arduino standard loop method       //
  
  pwmBoard_1.setPWM(0, 0, 4095);
  pwmBoard_1.setPWM(1, 0, 0);
  pwmBoard_1.setPWM(2, 0, 4095);
  
  pwmBoard_1.setPWM(3, 0, 0);
  pwmBoard_1.setPWM(4, 0, 0);
  pwmBoard_1.setPWM(5, 0, 0);
  
  pwmBoard_1.setPWM(6, 0, 0);
  pwmBoard_1.setPWM(7, 0, 0);
  pwmBoard_1.setPWM(8, 0, 0);
  
  pwmBoard_1.setPWM(9, 0, 0);
  pwmBoard_1.setPWM(10, 0, 0);
  pwmBoard_1.setPWM(11, 0, 0);
  
  pwmBoard_1.setPWM(12, 0, 0);
  pwmBoard_1.setPWM(13, 0, 0);
  pwmBoard_1.setPWM(14, 0, 0);
  
  pwmBoard_2.setPWM(0, 0, 0);
  pwmBoard_2.setPWM(1, 0, 0);
  pwmBoard_2.setPWM(2, 0, 0);
  
  pwmBoard_2.setPWM(3, 0, 0);
  pwmBoard_2.setPWM(4, 0, 0);
  pwmBoard_2.setPWM(5, 0, 0);
  
  pwmBoard_2.setPWM(6, 0, 0);
  pwmBoard_2.setPWM(7, 0, 0);
  pwmBoard_2.setPWM(8, 0, 0);
  
  pwmBoard_2.setPWM(9, 0, 0);
  pwmBoard_2.setPWM(10, 0, 0);
  pwmBoard_2.setPWM(11, 0, 0);
  
  pwmBoard_2.setPWM(12, 0, 0);
  pwmBoard_2.setPWM(13, 0, 0);
  pwmBoard_2.setPWM(14, 0, 0);
  
  pwmBoard_3.setPWM(0, 0, 0);
  pwmBoard_3.setPWM(1, 0, 0);
  pwmBoard_3.setPWM(2, 0, 0);
  
  pwmBoard_3.setPWM(3, 0, 0);
  pwmBoard_3.setPWM(4, 0, 0);
  pwmBoard_3.setPWM(5, 0, 0);
  
  pwmBoard_3.setPWM(6, 0, 0);
  pwmBoard_3.setPWM(7, 0, 0);
  pwmBoard_3.setPWM(8, 0, 0);
  
  pwmBoard_3.setPWM(9, 0, 0);
  pwmBoard_3.setPWM(10, 0, 0);
  pwmBoard_3.setPWM(11, 0, 0);

} // of method loop()                                 //------------------------------------//

I'm no MOSFET guru, but my first suspicion, IRF540N MOSFET isn't a logic-level FET, is it? Not sure how that would cause the symptom, but I'd be suspicious.

Second suspicion for these projects is, this supply isn't giving you enough current, or your wiring is using insufficient gauge wire. What is your sum total current for each string? If you can, reduce your load by temporarily shortening all the strings(allows full scope of the software to be worked on, but reduces the load).
Third query - why so high a PWM frequency?
None of these, by the way, feel to me like a smoking gun, they're just observations.

Same here - I'm really very green when it comes to MOSFETs. But I've been doing some reading since your comment, and I think you're on to something...

If you can wade through the bickering of this forum post, I believe it looks like MOSFET datasheets use a term called V_GS(th) (Gate-Source Voltage Threshold). For logic level MOSFETs, you want something that is very low, i.e. 1 - 2vdc. The IRF that I'm using right now calls out 2 - 4vdc for the V_GS(th), which very well might be causing the problem. My issue now is that I don't quite know how to test that theory other than get some different MOSFETs and give them a shot.

I think I might try something like the FQP30N06L, which is called out in this Sparkfun tutorial (something I wish I had found before I embarked on this project...). The V_GS(th) on that one is 1 - 2vdc.
https://learn.sparkfun.com/tutorials/non-addressable-rgb-led-strip-hookup-guide?_ga=2.80318676.23339252.1677209837-1129489803.1676815999

Logic level was just a marketing buzzword that means nothing. Voh for TTL, CMOS, F, CD are all different. Vgs(th) is the point where the MOSFET just starts to turn on, Rds may still be in the megohm range at that point.

You need a MOSFET that specifies an Rds at 5V or less. If it doesn't, then it probably won't work with a 5V gate voltage.

It's not clear if adafruit sets the output mode correctly

Place: pwmBoard_N.setOutputMode(true); at the end of setup()

Thanks Jim! I’ve ordered some IRLB8721 MOSFETs based on my reading of the Adafruit guide here. It shows Rds value of 4.5vdc, so I hope that might be the trick here.
https://learn.adafruit.com/rgb-led-strips?view=all

Good choice. You are guaranteed that the Rds on will be less than 16mohms at 4.5V under all conditions.

Also don't forget about setOutputMode(true)

Yessir I’m going to add that once I get the new MOSFETs connected. I was going to ask you if that was something necessary on the PCA9685 that I’m using, or if you’re familiar with that breakout. I suppose my assumption was that the PWM on that PCA9685 were by default output. But, it is my first time ever using it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.