Go Down

Topic: Control a lot of RGB LEDs with TLC5940 (Read 1 time) previous topic - next topic

kass

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: http://code.google.com/p/tlc5940arduino/

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:

Code: [Select]

(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!

CrossRoads

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.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

fungus



Code: [Select]

(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:

Code: [Select]

(pseudo code)

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus


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


This too.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

kass

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.

fungus

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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.

fungus


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
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

kass

The flickering code is:

Code: [Select]

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

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

    Tlc.update();
}

Grumpy_Mike

Quote
The flickering code is:

YES!!!
Take the
Code: [Select]
Tlc.update();
OUTSIDE of the for loop.

fungus


The flickering code is:

Code: [Select]

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?

Code: [Select]

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


No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

kass

@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

Quote
@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.

kass

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?

Grumpy_Mike

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.

Go Up