Hi everyone!
I am developing my thesis project and I need to make 24LEDs fade in and out. I was suggested in the forum to use 3 TLC 5940 to do so, fading the LEDs one by one. I will need also to made them fade in "clusters".
So my question is: is it possible to make more then one LED fade at the time with the TLC 5940s?
Something like this video...http://www.marcorighetto.it/videoArduinoForum.mp4
Thanks all!
In a such frustrating day for many issues with the project, this sounds just like a bless. Thank you. I'll keep posting when troubles with the code will occur. Thank you again.
Here I am again.
I finally got the TLC 5940s and I am trying now to write the right code to make the fading. But I think I have a main issue. Even though I use the addFade function and the fadeUpdate one, the LEDs start messing around.
I guess it might be for something I cannot entirely understand which is the buffer size and the buffer lenght. Can anyone please help me understand what they are and how they work? Thank you so much!
the LEDs start messing around.
Is that a description of something going wrong? Do they get fresh with each other? Is sex involved?
which is the buffer size and the buffer lenght.
Basically they are the same thing. A buffer is an area of memory that holds the data to be clocked into the chip each time. The buffer must be as big as the data you clock in. For a TLC5940 there are one and a half bytes for each LED or 24 bytes per device. If you chain two devices then you need twice the buffer size or length, then it goes to 24 + 24 = 48 bytes. You add 24 bytes to the buffer size for each TLC chip you have.
So the "messing around" meant that after a while (let's say 20something cycles) all the LEDs on my TLC start blinking very rapidly and - to me - without any reason.
I started with this very raw code just to understand how it all works. Any idea about the blinking of the LEDs? I can provide a video to make it better understand (and btw, sorry for my poor English :S).
/*
Fades a line down the channels, with max value and duration based on
the voltage of analog pin 0.
Try grounding analog 0: everything should turn off.
Try putting +5V into analog 0: everything should turn on.
See the BasicUse example for hardware setup.
Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */
#include "Tlc5940.h"
#include "tlc_fades.h"
int b;
int fadeUpStart;
int fadeUpEnd;
int fadeDownEnd;
int mode;
int counter = 1;
TLC_CHANNEL_TYPE channel;
void setup()
{
Tlc.clear();
Tlc.init();
}
void loop()
{
switch(mode){
case 0:
Tlc.clear();
mode = 1;
break;
case 1:
{
unsigned long time = millis();
unsigned long tempo = 2000;
unsigned long step1 = time + tempo;
unsigned long step2 = step1 + tempo;
int maxValue = 4000;
tlc_addFade(1, 0, maxValue, time , step1 );
tlc_addFade(1, maxValue, 0, step1, step2);
tlc_updateFades();
counter++;
if (counter>2){
mode = 2;
}
}
break;
case 2:
Tlc.clear();
mode = 1;
break;
}
}
So have you any decoupling on the chips?
I am not entirely sure I got the de-coupling, but if I am not wrong it's about having a resistence on the chip. I do have on pin "23 BLANK" 8 220[ch937] (going to buy a 2k ASAP) and a 220[ch937] on pin 20 going to ground.
So... I've done the decoupling.
Yesterday it was going just fine, but now I am trying to use the TLC and it just doesn't work. I double checked all connection. I wrote this code yesterday and tried it out: it worked.
Now I re-uploaded it to the board and I just get the LEDs on channel0 and channel1 sparkling for a couple of seconds and then they switch off...
I also tried to upload code from the examples but nothing works.
I don't understand why... Any suggestions? Please help, I can't understand this...
This is the code
#include "Tlc5940.h"
#include "tlc_fades.h"
TLC_CHANNEL_TYPE channel0;
TLC_CHANNEL_TYPE channel1;
int mode = 0;
int maxValue = 4000;
//int channel = 0;
unsigned long fadeMillis;
uint16_t duration = 1900;
uint32_t startMillis;
uint32_t endMillis ;
int counter = 0;
void setup(){
Tlc.clear();
Tlc.init();
Serial.begin(9600);
channel0 = 0;
channel1 = 1;
}
void loop(){
// Serial.println(mode);
switch(mode){
case 0:
{
if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
if (!tlc_isFading(channel0) || !tlc_isFading(channel1)) {
startMillis= millis() + 50;
endMillis = startMillis + duration;
tlc_addFade(channel0, 0, maxValue, startMillis, endMillis);
tlc_addFade(channel1, 0, maxValue, startMillis, endMillis);
counter++;
}
}
tlc_updateFades();
if (counter>1){
mode = 1;
}
break;
}
case 1:
{
Tlc.clear();
Tlc.set(channel0, maxValue);
Tlc.update();
Tlc.clear();
break;
}
}
}
Please do not consider the previous post. Looks like everything got back to normal.. Still I don't know why...