Control a lot of RGB LEDs with TLC5940

Hi,

my project is a 10x10 "Pixels" LED Table.

I'm building a 2x2 prototype to test all different components I need.

I'm using an Arduino Mega 2560. All the RGB LEDs are connected to a TLC5940 (http://www.ti.com/lit/ds/symlink/tlc5940.pdf).
I use the folowing library for the TLC: Google Code Archive - Long-term storage for Google Code Project Hosting.

It all works very good.

But if I scale this into a 10x10 Matrix, I will have current Problems.
The solution could be toonly switch a cluster of LEDs at a time. (1 cluster = for example 5 LEDs)

I try to use the TLC library to do that, but I don't really know how.
The Idee was to do something like this:

(pseudo code)

for each LED
     Tlc.clear();
     Tlc.Set(...); // set color for the current LED
     Tlc.update();
endfor

But its flickering... Do someone know how I can do it?

Or do I need to use something like the 74HC154 to switch on/off the differents LED clusters?

Thank you very much for your help!

Why would you have current problems? Add an external 5V supply to power the LEDs, not the onboard regulator.
5V, 4A, drive lots of LEDs:
http://www.mpja.com/5-Volt-DC-Plug-Power-Supply-4A-Regulated/productinfo/18520%20PS/
100 * 3 * .02 = 6A
So use 2, 50 RGB LEDs powered from each one. Connect the GNDs to the Arduino Gnd.
300 channels = 19 chips.
Might also look at WS2811, with its 18 outputs (vs 16) could save a couple chips.

kass:

(pseudo code)

for each LED
     Tlc.clear();
     Tlc.Set(...); // set color for the current LED
     Tlc.update();
endfor




But its flickering... Do someone know how I can do it?

Try this:

(pseudo code)

Tlc.clear();
for each LED
     Tlc.Set(...); // set color for the current LED
endfor
Tlc.update();

CrossRoads:
Why would you have current problems? Add an external 5V supply to power the LEDs, not the onboard regulator.

This too.

Thank you for your answer.

@fungus: This sample is the same I already have. First clear the TLC, set the values for each LED, and then update. All the LEDs are simultaneously ON.

@CrossRoads: For each "cell" I have a RGB LED, an IR LED, and IR sensor. And when set the max PWM for each LED, I get for the 4 cells together 1,1A... This is why I'm scarred if I scale that to 100 cells.

kass:
@fungus: This sample is the same I already have.

Look again.

what I mean, is that I already implement it with the for loop between the clear and the update. Thats work pretty good, but all the LEDs are simultaneously ON;

The sample was, what I tried to get the LEDs ON one after the other. But it's flickering.

kass:
what I mean, is that I already implement it with the for loop between the clear and the update. Thats work pretty good, but all the LEDs are simultaneously ON;

The sample was, what I tried to get the LEDs ON one after the other. But it's flickering.

Then the bug must be in the Tlc.Set(...)

Without the complete code there's nothing anybody can do to help

The flickering code is:

for(LED led in _leds)
{
    Tlc.clear();

    Tlc.set(led.redChannel, 4095);
    Tlc.set(led.greenChannel, 4095);
    Tlc.set(led.blueChannel, 4095);

    Tlc.update();
}

The flickering code is:

YES!!!
Take the

Tlc.update();

OUTSIDE of the for loop.

kass:
The flickering code is:

for(LED led in _leds)

{
    Tlc.clear();

Tlc.set(led.redChannel, 4095);
    Tlc.set(led.greenChannel, 4095);
    Tlc.set(led.blueChannel, 4095);

Tlc.update();
}

How is that the same as my suggestion?

Tlc.clear();
for each LED
     Tlc.Set(...); // set color for the current LED
endfor
Tlc.update();

@Grumpy_Mike: if I put the update ouside the loop, only the last LED would get ON.

@fungus: I know that not the same as your suggestion, but I've already wrote, that I tried that (clear and update ouside the loop), and it work great since a week. What I want is the switch the LEDs one after the other so fast, that the impression is that all LEDS are ON. So, if I put the clear and the update outside the loop, the LEDs will get refreshed et switched on all at the same time.

@Grumpy_Mike: if I put the update ouside the loop, only the last LED would get ON.

No it would not.

What that call does is to transfer data from the buffer into the chip. The other calls the ones to set the LED value only change the buffer. As the Tlc.update takes time you will slow the whole thing down.

Ask yourself, why as a question if you are not prepared to accept an answer.

I will accept all answer because I know that you all have more experience as me.
But when you post youre answer, I immediately test it, and its whats happend, only the last cell switched on.

Or do I need to remove the clear call?
please say me if I'm wrong but the clear methode, clear the PWM values for each channel. so if I call the set methode, than the clear methode before I call the update methode, all set values would be overwritten from the clear methode calls?

Yes as fungus showed the clear method must also be outside the loop.
Try and read what the code is doing. The clear and set just affect memory inside the arduino, it is the transfer method that shifts this into the chip.

The code is doing exactly what you told it to, clear all memory, set one LED, then clear it again without ever displaying it. It is only the last time you see something happen because you have not cleared since setting.