Pages: [1]   Go Down
Author Topic: Control a lot of RGB LEDs with TLC5940  (Read 1342 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 524
Posts: 26473
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Code:
(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:
(pseudo code)

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

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

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

This too.
Logged

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

France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Look again.
Logged

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

France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The flickering code is:

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

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

    Tlc.update();
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33385
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The flickering code is:
YES!!!
Take the
Code:
Tlc.update();
OUTSIDE of the for loop.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5350
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The flickering code is:

Code:
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:
Tlc.clear();
for each LED
     Tlc.Set(...); // set color for the current LED
endfor
Tlc.update();

Logged

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

France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33385
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

France
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33385
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: