Pages: [1] 2   Go Down
Author Topic: TLC5940, problems with leds staying on after they are faded  (Read 825 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone!
I'm experimenting with some tlc5940 ICs and some leds for a project i'm making.
After some trying, i found the perfect setup for me but also some problems.

This is my current configuration:


A - 1500µF 10V ELNA capacitor to minimize ripple
B1 and B2 - Resistors to limit current, two in series for each chip since i don't have exact values
C - Arduino NANO connected to USB @ Ubuntu Studio
D1 and D2 - TLC5940 daisy chained
E - 5v From arduino, this is not used right now, the power for leds and chips is from a separate 10A @ 5V power supply.
F - 5v From 10A @ 5V power supply, used to power leds and chips
Green Line - Ground, common for arduino and chips/leds

These are the voltages i get from each supply (E is Arduino, F is power supply)


This is the code i have on the Arduino (C):
Code:
#include "Tlc5940.h" // Include TLC5940 library
#include "tlc_fades.h" // Include animation library
int incomingByte; // Var for serial data
int led = 0; // Var for led
 
void setup() {
Tlc.init(); // Init TLC library
Serial.begin(9600); // Open serial port, 9600bps
}
 
void loop() {
incomingByte = Serial.read(); // Read the serial port and give its value to incomingByte
if(incomingByte > 0) { // If i receive something from serial
led = random(0,32); // Get a random led
tlc_addFade(led, 0, 4096, millis(), millis()+80); // Add to the queue a fade from 0 to 4095 brightness from now to now+80ms
tlc_addFade(led, 4096, 0, millis()+81, millis()+600); // Add to the queue a fade from now+81ms to now+600ms from 4095 to 0 brightness
}
tlc_updateFades(); // Update and display the fades.
}

Basically when i input something i get a fading led.

Now here's the problem. After a fade the led gets barely lit, as if i set the pwm to "1", you can't really see it, but some times it is very lit and you can notice it.
How can i resolve?

If i do a Tlc.Set(led, 0) after the fade the led stays off and the problem disappears, so i guess the problem is software, or maybe not working TLCs/Arduino?
Another thing i was thinking about, the data to the TLCs is sent via the pin 13. Could it be the led connected to that pin that messes up things?

Thank you and sorry for the poor English, i'm Italian smiley-wink
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I don't know the answer, but I congratulate you on a well detailed first post, including code with comments, inside code tags. This level of detail is rare for a first post.
Logged

Do not IM me. I will not respond. Ask questions in the forum.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If i do a Tlc.Set(led, 0) after the fade the led stays off and the problem disappears, so i guess the problem is software, or maybe not working TLCs/Arduino?

Sounds to me like a bug in the 'fade' functions.

But you already have a workaround for it...
Logged

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

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

Hi,

I don't know the answer, but I congratulate you on a well detailed first post, including code with comments, inside code tags. This level of detail is rare for a first post.

Thank you. Since i'm not English i try to make my posts detailed as i can, hoping that it will compensate my language mistakes.
See you on the forum smiley-wink

If i do a Tlc.Set(led, 0) after the fade the led stays off and the problem disappears, so i guess the problem is software, or maybe not working TLCs/Arduino?

Sounds to me like a bug in the 'fade' functions.
But you already have a workaround for it...


Hi,
The problem is that it works only if you give the command seconds after the fade. If you try it immediately after it will not work.
I think the library is still managing the led some milliseconds after the fade, blocking every external command.
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just had a look at the tlc_fades.h file of the library here:
http://code.google.com/p/tlc5940arduino/source/browse/trunk/Tlc5940/tlc_fades.h

It looks to me like tlc_updateFades() should be working correctly, and result in a Tlc.set(led,0); at the end of the fade.

Is this the library you are using? Are you sure you have the latest version of the libraries? In your library tlc_fades.h file, just check if the uint8_t tlc_updateFades(uint32_t currentMillis) is identical to the one here.

Logged

Do not IM me. I will not respond. Ask questions in the forum.

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

Hmm, let me check the library. It seems very old to me. I think it needs a rewrite.
I updated the library with the one you linked me but i have the same problems.
I found something new, though: the led that stays lit is not the one that fades, but the one adiacent to the fade.
Code:
00--03--05--07--09--11--13
--02--04--06--08--10--12--14

For example, if i fade the led 07, the leds 09 and 05 will stay lit.
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code you supplied only fades one led.

Can you post the complete code you are using?
Logged

Do not IM me. I will not respond. Ask questions in the forum.

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

The code you supplied only fades one led.

Can you post the complete code you are using?

Hi,
the code i'm using is the one in the main post, if i enter three chars, i will get three leds fading. If i enter one, i will get only one led.

EDIT: I think i found a fix

 
Code:
[missing code...]
void setup() {
        Tlc.init(); // Init TLC library
        Tlc.setAll(0);
        Tlc.set(0,0);Tlc.set(1,0);Tlc.set(2,0);Tlc.set(3,0);
        Tlc.set(4,0);Tlc.set(5,0);Tlc.set(6,0);Tlc.set(7,0);
        Tlc.set(8,0);Tlc.set(9,0);Tlc.set(10,0);Tlc.set(11,0);
        Tlc.set(12,0);Tlc.set(13,0);Tlc.set(14,0);Tlc.set(15,0);
        Tlc.set(16,0);Tlc.set(17,0);Tlc.set(18,0);Tlc.set(19,0);
        Tlc.set(20,0);Tlc.set(21,0);Tlc.set(22,0);Tlc.set(23,0);
        Tlc.set(24,0);Tlc.set(25,0);Tlc.set(26,0);Tlc.set(27,0);
        Tlc.set(28,0);Tlc.set(29,0);Tlc.set(30,0);Tlc.set(31,0);
[missing code...]
}
 
void loop() {
       [missing code...]
        tlc_updateFades();
        Tlc.update();
       
        if(millis() % 20 == 0) {
          Tlc.setAll(0);
        }
}

This will reset all leds every 20ms. You can still see the leds staying on, but after 20ms they go off.
The problem was the library sending wrong data to the tlc and forgetting about it.

I'm not very happy with the solution, though, the leds flick every 20ms, but that's better than the leds staying on. smiley
« Last Edit: December 12, 2013, 08:56:53 am by edocod » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

EDIT: I think i found a fix

Code:
        Tlc.setAll(0);
        Tlc.set(0,0);Tlc.set(1,0);Tlc.set(2,0);Tlc.set(3,0);
        Tlc.set(4,0);Tlc.set(5,0);Tlc.set(6,0);Tlc.set(7,0);
        Tlc.set(8,0);Tlc.set(9,0);Tlc.set(10,0);Tlc.set(11,0);
        Tlc.set(12,0);Tlc.set(13,0);Tlc.set(14,0);Tlc.set(15,0);
        Tlc.set(16,0);Tlc.set(17,0);Tlc.set(18,0);Tlc.set(19,0);
        Tlc.set(20,0);Tlc.set(21,0);Tlc.set(22,0);Tlc.set(23,0);
        Tlc.set(24,0);Tlc.set(25,0);Tlc.set(26,0);Tlc.set(27,0);
        Tlc.set(28,0);Tlc.set(29,0);Tlc.set(30,0);Tlc.set(31,0);

a) Didn't Tlc.setAll(0); already set them to 0
b) Ever hear of a thing called a loop?

This will reset all leds every 20ms. You can still see the leds staying on, but after 20ms they go off.
The problem was the library sending wrong data to the tlc and forgetting about it.

I'm not very happy with the solution, though, the leds flick every 20ms, but that's better than the leds staying on. smiley

Why don't you use the "tlc_isFading()" function to find out when a fade has finished and *then* set it to zero?

Logged

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

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

EDIT: I think i found a fix

Code:
        Tlc.setAll(0);
        Tlc.set(0,0);Tlc.set(1,0);Tlc.set(2,0);Tlc.set(3,0);
        Tlc.set(4,0);Tlc.set(5,0);Tlc.set(6,0);Tlc.set(7,0);
        Tlc.set(8,0);Tlc.set(9,0);Tlc.set(10,0);Tlc.set(11,0);
        Tlc.set(12,0);Tlc.set(13,0);Tlc.set(14,0);Tlc.set(15,0);
        Tlc.set(16,0);Tlc.set(17,0);Tlc.set(18,0);Tlc.set(19,0);
        Tlc.set(20,0);Tlc.set(21,0);Tlc.set(22,0);Tlc.set(23,0);
        Tlc.set(24,0);Tlc.set(25,0);Tlc.set(26,0);Tlc.set(27,0);
        Tlc.set(28,0);Tlc.set(29,0);Tlc.set(30,0);Tlc.set(31,0);

a) Didn't Tlc.setAll(0); already set them to 0
Yeah, but better be sure smiley-razz
Quote
b) Ever hear of a thing called a loop?
Yes, but it was faster for me writing every line. My editor does it automatically smiley-razz
Quote
This will reset all leds every 20ms. You can still see the leds staying on, but after 20ms they go off.
The problem was the library sending wrong data to the tlc and forgetting about it.

I'm not very happy with the solution, though, the leds flick every 20ms, but that's better than the leds staying on. smiley

Why don't you use the "tlc_isFading()" function to find out when a fade has finished and *then* set it to zero?



Because the adiacent leds are the ones that are lit, not the fading one.
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't believe this should be necessary.

I checked the tlc_updateFades() function in the library that I linked to, and at the end of the fade, it should automatically be calling setLed(Led,0).

So, something else is going on here. But, in order to fix it properly, we need you to post your entire code, not just parts of it.

If you want us to have a look at the problem, take out your hacks, and post the full code. And ideally, a link to the library you are using.

If you're happy with your solution and you don't want us to look, that's OK too.
Logged

Do not IM me. I will not respond. Ask questions in the forum.

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

I don't believe this should be necessary.

I checked the tlc_updateFades() function in the library that I linked to, and at the end of the fade, it should automatically be calling setLed(Led,0).
[...]
If you're happy with your solution and you don't want us to look, that's OK too.

Quote

#include "Tlc5940.h" // Include TLC5940 library
#include "tlc_fades.h" // Include animation library
int incomingByte; // Var for serial data
int led = 0; // Var for led
 
void setup() {
        Tlc.init(); // Init TLC library
        Serial.begin(9600); // Open serial port, 9600bps
}
 
void loop() {
        incomingByte = Serial.read(); // Get the serial
          if(incomingByte > 0) { // Has the user inputted a byte?
            led = random(0,32); // Choose a random led
            tlc_addFade(led, 0, 4096, millis(), millis()+80); // Light it up
            tlc_addFade(led, 4096, 0, millis()+81, millis()+600); //Shut it down
          }
          
       
        tlc_updateFades(); // Update everything
        Tlc.update();
        
        
          if(millis() % 20 == 0) { // Is the time a multiple of 20?
            Tlc.setAll(0); //Then shut down all the leds so we start with a clean memory
          }
}


And this is the library: http://code.google.com/p/tlc5940arduino/
I just edited the config of the library to make it work with two tlc (there is a var for that)
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something is very wrong.

Are you sure you've told the TLC library you have two chips connected?
Logged

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

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

Something is very wrong.

Are you sure you've told the TLC library you have two chips connected?


http://pastebin.com/hPHAffLU

This is my tlc_config.h, the only file i edited.
Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahhh. I understand now. Sorry, I didn't fully understand that was your entire code.

The problem seems to be in the Tlc.update(); function. The tlc_updateFades() looks like it should do the right thing, and it also calls Tlc.update(); at the end of the fade.

Unfortunately, I haven't worked with the TLC5940 and the Tlc.update() method is low-level chip stuff, so I can't really help you I'm afraid. I hope someone else here can help you though.
Logged

Do not IM me. I will not respond. Ask questions in the forum.

Pages: [1] 2   Go Up
Jump to: