Arduino and TLC5940

Hello everyone,

I'm Nicolas and a beginner in electronic.
I'm looking for arduino examples with scheme and wiring diagram as clear as possible to run a TLC and some RGB leds on it.
On playground i find a example but understand nothing.
I installed a library from here : Google Code Archive - Long-term storage for Google Code Project Hosting.

after that I don't know where to find a good and EXTREMLY well explained tutorial to wiring with arduino MEGA.
If anyone can help me, I appreciate to much. I've spend some money to control some RGB led.

Can you propose a simple tutorial for change color of xx RGB leds with TLC chips (one or several)

Thanks !

On playground i find a example but understand nothing.

OK so ask questions about what you don't understand.
Have you got the data sheet for that chip? You need it.
Yes it might be difficult to understand to start with but if you ask about what you don't understand then you can start to learn.

Hi,

Well, I'm confused because some examples are so hard to me.
I can change color with arduino PWN pins, that's ok, but with the TLC after load the library and try to wire this circuit :
http://wiki.t-o-f.info/Arduino/ExempleDémultiplexeurPWMTLC5940?from=Arduino.TLC5940

I want to erase all informations of this page from my mind and find someone who can help me with basic example for use TLC to turn on and off several LED (simple blue LED for example).

Possible ?

I want to erase all informations of this page from my mind and find someone who can help me with basic example for use TLC to turn on and off several LED

No you don't.
The TLC5940 is a medium complex chip. That page looks like a good start.
Basically it gives you 16 PWM outputs, just like the PWM outputs on the arduino. However, better than the arduino it has a constant current output, that means you don't have to have resistors in the LEDs.

To get the data into this chip you need to shift it in one bit at a time. If you don't know that concept then look the shift out tutorial. Unlike the arduino which has only 8 bits to control the PWM this chip has 12 bits that control each one. This means to fully load the chip with data you need to feed it with 16 * 12 = 192 bits of information. Once fed in this will then control the brightness of the LEDs by PWM. Do you understand PWM? If not look here http://www.thebox.myzen.co.uk/Tutorial/PWM.html. The PWM signal is produced by a clock signal, the arduino has to supply this clock signal. So it needs feeding with two things, the PWM clock and the data.
Solder one up and get the examples working.
They can be found in the library -> TLC5940 -> Examples

Have a look at this http://www.buildcircuit.com/experiments-with-tlc5940-and-arduino/

I test with this example, look more clear to me :

http://tronixstuff.wordpress.com/2010/07/19/review-–-texas-instruments-tlc5940-16-channel-led-driver ic/
http://code.google.com/p/tlc5940arduino/wiki/ArduinoMegaHardwareSetup

I do this wiring :

Required Pins

Mega pin 51 (MOSI) -> SIN (Tlc pin 26)
Mega pin 52 (SCK) -> SCLK (Tlc pin 25)
Mega pin 11 (OC1A) -> XLAT (Tlc pin 24)
Mega pin 12 (OC1B) -> BLANK (Tlc pin 23)
Mega pin 9 (OC2B) -> GSCLK (Tlc pin 18)

so that mine : - Casimages.com

the code :
////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Warning //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////// You need external power for your Arduino board - USB is not enough!!/////////////
///////////// TLC5940 + 16 LEDs draw over 300 mA at full brightness! ///////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
#include "Tlc5940.h"
void setup()
{
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 - 4095) for all channels./
Tlc.init();
}
void knightrider()
/
This loop will create a Knight Rider-like effect if you have LEDs plugged
into all the TLC outputs. NUM_TLCS is defined in "tlc_config.h" in the
library folder. After editing tlc_config.h for your setup, delete the
Tlc5940.o file to save the changes. /
{
int direction = 1;
for (int channel = 0; channel < NUM_TLCS * 16; channel += direction) {
/
Tlc.clear() sets all the grayscale values to zero, but does not send
them to the TLCs. To actually send the data, call Tlc.update() /
Tlc.clear();
/
Tlc.set(channel (0-15), value (0-4095)) sets the grayscale value for
one channel (15 is OUT15 on the first TLC, if multiple TLCs are daisychained,
then channel = 16 would be OUT0 of the second TLC, etc.).
value goes from off (0) to always on (4095).
Like Tlc.clear(), this function only sets up the data, Tlc.update()
will send the data. /
if (channel == 0) {
direction = 1;
}
else {
Tlc.set(channel - 1, 1000);
}
Tlc.set(channel, 4095);
if (channel != NUM_TLCS * 16 - 1) {
Tlc.set(channel + 1, 1000);
}
else {
direction = -1;
}
/
Tlc.update() sends the data to the TLCs. This is when the LEDs will
actually change. */
Tlc.update();
delay(50);
}
}
void breathe(int qq) // qq is number of times to breathe :slight_smile:
// displays all LEDs and alters the brightness
{
Tlc.clear();
for (int q=0; q<qq; q++)
File: Unsaved Document 1 Page 2 of 2
{
for (int p=0; p<4096; p+=10) // increase brightness
{
for (int l=0; l<16; l++)
{
Tlc.set(l, p);
}
Tlc.update();
delay(5);
}
for (int p=4095; p>=0; p-=10) // decrease brightness
{
for (int l=0; l<16; l++)
{
Tlc.set(l, p);
}
Tlc.update();
delay(5);
}
}
}
void randomled(int m)
// displays random LEDs for m times
{
randomSeed(analogRead(0));
for (int qq=0; qq<m; qq++)
{
Tlc.clear();
Tlc.set(random(16), 4095);
Tlc.update();
delay(200);
}
}
void loop()
{
randomled(100);
delay(1000);
breathe(3);
delay(1000);
knightrider();
}
////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Warning //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////// You need external power for your Arduino board - USB is not enough!!/////////////
///////////// TLC5940 + 16 LEDs draw over 300 mA at full brightness! ///////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////

=> But i can't compile, so i can't transfert it in ARDUINO. (just for transfert)

Because this wiring require 5V external supply do to the current who can't provide by ARDUINO BOARD.

I need help to run my 15 LEDs with this TLC.
Thanks for helping :slight_smile:

=> But i can't compile, so i can't transfert it in ARDUINO. (just for transfert)

You get error messages so what were they.
Please post the code correctly so people can try it for themselves. Look at what the forum does to code, that is not what you posted. Read the how to use this forum sticky post and modify that last post with the real code you have.
You do not need an external supply for testing just make the maximum current drawn 10mA by doubling the size of that one current setting resistor.

"'TLC' was not declared in this scope"

how to declared this kind of thing ? just a declaration ?

This means it hasn't seen the libary files. It needs to be installed in the libaries folder.

Ok, I had this in my librairy look good now.
Soon as possible I test this example to see how TLC5940 react.
Thanks, I stay tuned.

Hello a toi.
alors des news de ton TLC5940 ?
:stuck_out_tongue:

Les miens sont OK.
si tu veux des infos ... je suis aussi débutant et mes 2 tlc5940 sont OK.
j'attaque la partie forte puissance.

2 tlc + leds 10W
Arduinolement.

je suis trop tarte pour réussir seul, j'ai besoin d'aide : )

Quel genre de montage fais tu exactement ?

As tu une photo et le but de ton montage et si tu pouvais m'expliquer j'aimerai comprendre comment ça "fonctionne"

à bientot j'espère !

I have a quick wiring question -

In my application, I have two blocks of LED strips that I would like to have do the same things at the same time... I'll be using a total of 4 TLC5940's, two per block.

All the application stuff I've seen say to wire the chips with the Arduino feeding TLC1's Sin pin (26), and then daisy chain from the Sout pin (17) of each chip to the Sin pin of the next.

Since I want the two blocks to behave the same, is there any reason I can't go from the Arduino to Sin of the first chip in each block, so that they are essentially in parallel rather than in series?

Seems like that would make the code I'll need much simpler as I'd only be dealing with half the channels...

More details about what I'm trying to do in this thread - http://forum.arduino.cc/index.php?topic=168620.0

Thanks,
ex-Gooserider

Since I want the two blocks to behave the same, is there any reason I can't go from the Arduino to Sin of the first chip in each block, so that they are essentially in parallel rather than in series?

Yes I think that should work.
Don't forget your decoupling capacitors on each chip.

Anyone can post one basic example or your circuit diagramm, just want to understand how it works, i go to many site buyt don't understand properly.
Thanks

Hi there,

I did it, I use Knight rider example from here http://tronixstuff.wordpress.com/2010/07/19/review-–-texas-instruments-tlc5940-16-channel-led-driver ic/

Code is in PDF file before middle of the page

my wiring