TLC5940 Daisychain glitch

Hi

I have a breadboard circuit with Arduino NEO and two TLC5940s controlling 5RGB LEDs each. The program uses the TLC5940 library. I had to use capacitors to settle the flicker which worked great. The software makes a new colour fade across the LED row periodically.

When I connect the SIN of each chip direct to the Arduino, the sequence works perfectly, if I connect the SIN of both, in parallel they both work perfectly.

BUT If I connect the SOUT of the first 5940 to the SIN of the second 5940, the first chip's LEDs work well, but on the second chip, the first LED operates in parallel with the first LED of the first 5940 and the rest of the LEDs stay in a fixed bright state.

I have the code feeding in the full 32-value data set, and I changed the number of chips in TLC_config.h to #define NUM_TLCS 2

Is there some other setup I need to do to get the daisy-chain working?

Hi, no I theory there is nothing else to wire up. Post your sketch and a close up pic of the breadboard. Perhaps we can spot something.

Check the following:

Swap the order of the two chips in the chain. Anything different?

Check breadboard wiring. Some breadboards have power rails where the gnd rail goes all the way along but the positive rail has a break half way along and a wire link is needed.

Paul

I had to use capacitors to settle the flicker which worked great.

Where were these?

Is there some other setup I need to do to get the daisy-chain working?

Hard to tell without a schematic. This project shows three chips chained. http://www.thebox.myzen.co.uk/Hardware/Hexome.html

Thanks for replies Paul and GM

I have tried all the variations of switching the chips and switching the data inputs, a-b, b-a kinda thing - same issues. Also, I was puzzled by the rail-split earlier but jumped across it. I could post a pic, but I used the standard ~25cm jumpers so its a bit of a spaghetti pile...

The circuit was very flickery before capacitors - the one across the +/- rails made a huge difference, but not 100% .. with the smaller caps near each chip it is steady as a rock. I used the little round brown ones (?ceramic).

The small capacitors are near each of the chips at 19/20 (DCPRG/IREF) .. after checking that, I thought I would try 21/22 (GND/VCC) but just as good, but with the same daisychain glitch.

Next, I will have a look at that link of the 3x daisychain (Thanks again!)

I checked that URL and my setup looks good.

I thought it might be my code, and the way I address the second chip using the library commands . . .

        //  ** This is just a snippet where I could have an error in how I address each LED
        //Do loop iterating through   J= 0 to <10    -where J is the LED number
       // if J>4 then P=0 --> P=1      This allows for the 16 outputs on the chip, but only 15 being used

     r = (3 * j) + 0 + p;       // Calculating the pin number required
     g = (3 * j) + 1 + p; 
     b = (3 * j) + 2 + p; 
     
     Tlc.set(r,red);            // Clocking in the data for each pin, loop back to next LED
     Tlc.set(g,green);
     Tlc.set(b,blue);

   }                                      // End of DoLoop setting each pin's data

     Tlc.update();              // Latching the data to display the frame

Each TLC5940 has 16 outputs (0 → 15)
Is it right to just continue with a Tlc.set(14,), <skip pin 15> , Tlc.set(16,) , Tlc.set(17,) or is there another command for the second chip?

If this appears correct I will try to post a pic fwiw, but I think the wiring is OK as I said, each chip-circuit works fine individually and with both in parallel.

  • But with with Neo(11) → SIN(26Chip1) then SOUT(17Chip1) → SIN(26Chip2) the second chip output misbehaves as detailed above.

Is it right to just continue with a Tlc.set(14,), <skip pin 15> , Tlc.set(16,) , Tlc.set(17,)

Yes.
It sounds like you have not got the buffer big enough but we would need to see all the code to make sure. Or maybe you could just code up something simple that shows the problem.

Start2222: I have tried all the variations of switching the chips and switching the data inputs, a-b, b-a kinda thing - same issues.

But when you say the same, do you mean the same phyical chip has the problem, or the problem moves to the chip that's now second in the chain? (I guess it must be the latter, if it was the former you would have worked out that you have a faulty chip by now!)

OK, this is the entire sketch copied from Arduino 1.0.5-r2

Code works well, except when daisychaining . . . . .

   // LED sketch adapted from: http://lizarum.com/assignments/physical_computing/2009/leds/tlc5940.html


#include <Tlc5940.h>   // Set <#define NUM_TLCS    2> in <TLC_config.h>
  int i = 0;  // Defining the variables .. and some spares
  int c = 0;
  int j = 0;
  float n = 0;
  int X = 0;
  int Y = 0;
  int h = 0;
  int d = 0;
  int d2 = 0;
  float p = 0;
  int red = 150;
  int green = 150;
  int blue = 150;
  int r = 0;
  int g = 0;
  int b = 0;
  int oldred = 150;
  int oldgreen = 150;
  int oldblue = 150;
  int newred = 0;
  int newgreen = 0;
  int newblue = 0;
  int LED[2][4];
  int valmin = 0;
  int valmax = 0;
  
  
void setup(){   // Main program loop
  Tlc.init();   // Initialise the TLC59402 to blank
}

void loop(){

  do {          // Select the next colour to fade to
   valmin=255;
   valmax=0;
   newred = random(254);
   if (valmin > newred) valmin = newred;
   if (valmax < newred) valmax = newred;
   newgreen = random(254);
   if (valmin > newgreen) valmin = newgreen;
   if (valmax < newgreen) valmax = newgreen;
   newblue = random(254);
   if (valmin > newblue) valmin = newblue;
   if (valmax < newblue) valmax = newblue;
   i = valmax- valmin;
  } while (i < 240);      // Just checking for a definite colour, not off-white
   
   
   for (p = -1; p < 12; p = p + 0.03){  // Loop for each 'frame'

   for (j = 0; j < 10; j++){            // Loop for each LED
     if (p < j) { 
      red = oldred;                     // Not at fade yet
      green = oldgreen;
      blue = oldblue;
       }
       else if (p > j+1.5) {            // Fade complete, show new colour 
      red = newred;
      green = newgreen;
      blue = newblue;
       }
      else {                            // Fade sequence
      n = p-j;                          // How far into fade
      red = oldred + (n * (newred - oldred) / 1.5);  // Fade increment
      constrain(red, 0, 254);           // In case of math error
      green = oldgreen + (n * (newgreen - oldgreen) / 1.5);
      constrain(green, 0, 254);
      blue = oldblue + (n * (newblue - oldblue) / 1.5);
      constrain(blue, 0, 254);
      }
       
     //LED[0][j] = red;   // Array not required in this sketch
     //LED[1][j] = green;
     //LED[2][j] = blue;
     h=0;                // Chip number
     if (j>4) h=1;       // Second daisychained chip starting at 16
         
     r = (3 * j) + 0 + h;   // 
     g = (3 * j) + 1 + h; 
     b = (3 * j) + 2 + h; 
     
     Tlc.set(r,red * 4);
     Tlc.set(g,green * 4);
     Tlc.set(b,blue * 4);

   }
     Tlc.update();
     d = random(2,10);
     delay(d);   
     
   
   }
     Tlc.update();
     d = random(1000, 10000);
     delay(d);   
     
     oldred = newred;
     oldgreen = newgreen;
     oldblue = newblue;
}

And just to comment.. I know that the multiplier in the set statement should be 16 rather than 4 , but 4 looks bright enough for this demo - and I'm not exactly sure of my IREF resistor value, so I don't want to overload the Arduino. So values result at 0-1024 rather than 0-4096. It even works the same (but dimly) with no multiplier.

Everything is powered by Arduino 5V and works great with the two chips in parallel, or either separately.

It looks like you are not setting the second string of LEDs

if (j>4) h=1;       // Second daisychained chip starting at 16       
     r = (3 * j) + 0 + h;   // 
     g = (3 * j) + 1 + h; 
     b = (3 * j) + 2 + h;

You want to address the second lot of memory so h needs to be an increment of 16. Try:-

if (j>4) h=1;  else h=0;      // Second daisychained chip starting at 16
         
     r = (3 * j) + 0 + (h * 16);   // 
     g = (3 * j) + 1 + (h * 16);
     b = (3 * j) + 2 + (h * 16);

Hi Mike, Thanks for reading my code, I appreciate that. J is set to loop from 0 to 9 , h changes from 0 to 1 above 4 (second chip). Your answer tells me the code is essentially correct, I didn't miss a command. I think next step is checking the wiring . . . .


r = (3 * j) + 0 + h; --> {0,3,6,9,12,16,19,22,25,28}

r = (3 * j) + 0 + (h * 16); --> {0,3,6,8,12,31,34,37,40,43}

PaulRB:

Start2222: I have tried all the variations of switching the chips and switching the data inputs, a-b, b-a kinda thing - same issues.

But when you say the same, do you mean the same phyical chip has the problem, or the problem moves to the chip that's now second in the chain? (I guess it must be the latter, if it was the former you would have worked out that you have a faulty chip by now!)

Thanks for the reply Paul - forgot to reply earlier :./

Yes tried all that - physically switched the chips, and switched the SIN from chip1 to chip2 and re-arranged the SOUT/SIN linkup, funny that its the exact same glitch which makes me think its in the wiring somehow as I ruled out a code fault.

Still a schematic and a photo would help.