Go Down

Topic: Problem with multiple tlc5940 (Read 9504 times) previous topic - next topic

quizz_kid

Hi. For starter, I´m a real n00b reg arduino. I´m using two tlc5940 units for 30 LEDs... I want them to sort of "glow" individually in different duration. It works fine, but as soon as I add more than 11 LEDs in the code, the LEDs from 12> are first delayed, and then the whole "stripe" get messed up. They are sort of ramdomly switching between fading very smooth and not fading at all. I´ve connected everything exactly like this scheme: http://electronics.stackexchange.com/questions/42540/tlc-5940-pwm-driver-blank-input-and-pull-up-resistor

Is there something wrong with my code? Can you help me out here?

Note: The code below is for 16 LEDs, not the hole stripe of 30.

Code: [Select]
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;

void setup()
{
  Tlc.init();
}

void loop()
{
  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
   
     if (!tlc_isFading(0)){
      uint16_t duration = 4900 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(0, 50, maxValue, startMillis, endMillis );
      tlc_addFade(0, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(1)){
      uint16_t duration = 4700 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(1, 50, maxValue, startMillis, endMillis );
      tlc_addFade(1, maxValue, 50, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(2)){
      uint16_t duration = 4800 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(2, 50, maxValue, startMillis, endMillis );
      tlc_addFade(2, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(3)){
      uint16_t duration = 4500 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(3, 50, maxValue, startMillis, endMillis );
      tlc_addFade(3, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(4)){
      uint16_t duration = 4100 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(4, 50, maxValue, startMillis, endMillis );
      tlc_addFade(4, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(5)){
      uint16_t duration = 4200 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(5, 50, maxValue, startMillis, endMillis );
      tlc_addFade(5, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(6)){
      uint16_t duration = 4300 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(6, 50, maxValue, startMillis, endMillis );
      tlc_addFade(6, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(7)){
      uint16_t duration = 4400 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(7, 50, maxValue, startMillis, endMillis );
      tlc_addFade(7, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(8)){
      uint16_t duration = 4600 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(8, 50, maxValue, startMillis, endMillis );
      tlc_addFade(8, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(9)){
      uint16_t duration = 5000 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(9, 50, maxValue, startMillis, endMillis );
      tlc_addFade(9, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(10)){
      uint16_t duration = 5100 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(10, 50, maxValue, startMillis, endMillis );
      tlc_addFade(10, maxValue, 50, endMillis, endMillis + duration);}
     
     
     
     
     
     
     
     
      if (!tlc_isFading(11)){
      uint16_t duration = 4700 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(11, 50, maxValue, startMillis, endMillis );
      tlc_addFade(11, maxValue, 50, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(12)){
      uint16_t duration = 4800 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(12, 50, maxValue, startMillis, endMillis );
      tlc_addFade(12, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(13)){
      uint16_t duration = 4500 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(13, 50, maxValue, startMillis, endMillis );
      tlc_addFade(13, maxValue, 50, endMillis, endMillis + duration);}
     
     
       if (!tlc_isFading(14)){
      uint16_t duration = 4700 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(14, 50, maxValue, startMillis, endMillis );
      tlc_addFade(14, maxValue, 50, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(15)){
      uint16_t duration = 4800 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(15, 50, maxValue, startMillis, endMillis );
      tlc_addFade(15, maxValue, 50, endMillis, endMillis + duration);}
     
       if (!tlc_isFading(16)){
      uint16_t duration = 4500 - (analogRead(0) * 2);
      int maxValue = 1000;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(16, 50, maxValue, startMillis, endMillis );
      tlc_addFade(16, maxValue, 50, endMillis, endMillis + duration);}
     
     
   
     
     
     
   
   
   
    if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
  tlc_updateFades();
}

Grumpy_Mike

There are no decoupling capacitors in that schematic. Add. 0.1uF ceramic capacitor across the power and ground of each chip.


quizz_kid

#3
Jan 13, 2013, 01:03 am Last Edit: Jan 13, 2013, 01:08 am by quizz_kid Reason: 1
The capacitors doesnt seem to do the trick... Any other ideas?? I put the capacitors next to the tlc5940's vcc and gnd on breadboard. Also, when I try the examples>tlc5940>fades, the flow is bad, not smooth at all.

Grumpy_Mike

Make sure the capacitor leads are as short as possible. Make sure the wiring is as short and neat as possible. Try adding one largish cap about 47uF to the supply as well.
Basically the circuit does work but it can be layout sensitive.

quizz_kid

I really tried to keep the wiring as short and neat as possible.

This is how it looks like.


And here´s another one, same problem on this one.



You are sure there´s not a software issue?

Grumpy_Mike

Quote
You are sure there´s not a software issue?

I was sort of assuming that you get the same problem on the sample code do you not?

Shorten the leads on the decoupling caps, they need to be as short as possible, you should see no wire.

Hippynerd

I was having a problem with the 5940s, then added some 104 caps, and continued to have similar problems. I decided to re-send the sketch, and it worked fine. I dont quite understand how that fixed it, but it only took a minute to do, and since then, the problem has not re-occurred.
https://sites.google.com/site/rgbledcubes

fungus


Quote
You are sure there´s not a software issue?

I was sort of assuming that you get the same problem on the sample code do you not?

Shorten the leads on the decoupling caps, they need to be as short as possible, you should see no wire.


I'd add some more capacitors on the +5V lines near the LEDs, too. 30 LEDs switching on simultaneously at the start of every PWM cycle is a big change in current for the PSU to adapt to. I'm fond of 1uF polyesters for this - they respond a bit faster than standard electrolytics and they're not too big to add a few of them around the circuit.

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

quizz_kid

Grumpy_Mike:

Yeah, I was just thinking if I might had done something wrong when editing the config file for two tlc5940's. But I´m going to try shortening those wires.


Hippynerd:

With "re-send the sketch" you mean upload I guess?


fungus:

You say "on the +5V lines near the LEDs"... Where is that exactly? Sorry, I´m a total n00b...

fungus


fungus:

You say "on the +5V lines near the LEDs"... Where is that exactly? Sorry, I´m a total n00b...


Between ground and 5V, near the LEDs (again, the +5V wires need to be as short as possible...)

Try one on either end of that row of LEDs. The idea is to try to stop the +5V line from sagging when those LEDs all switch on at the start of the PWM cycle (which can freak out the logic chips).

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

quizz_kid

Like this?



Btw, here's a video of how it looks. Notice the flickering and blinking after that somewhat struggled start. Also know that the code I used for this is for 22 LEDs, but only 19 of them are switched on. So it stops at 19. Why is that?
http://www.youtube.com/watch?v=fKd5IA52HyY

And here´s with a 11 LEDs code. Works smoothe and nice.
http://www.youtube.com/watch?v=t2taav30Ofw

fungus


Like this?


That's the general idea. I can't see what the other leg of the capacitor is connected to though (it should be GND...)

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

quizz_kid

Well it doesn´t seem to work... Any other ideas?

fungus


Well it doesn´t seem to work... Any other ideas?


Maybe the "tlc_fades" demo doesn't work with multiple chips. Did you look in the header file to see if there's anything that might need adjusting?

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

Go Up