2 TLC5940 problem, possible overload?

Hello!

I have a very big project that needs to be done soon and i have encountered a massive issue and I need help!
I am using 2 TLC5940's to drive 32 LED's and it is wired up like this except the resistors.
I have a 470 ohm resistor on the IREF instead of the 2.2k pull up like i'm supposed to, those are still on order.
the other resistor i don't have.
http://tlc5940arduino.googlecode.com/svn/wiki/images/breadboard-arduino-tlc5940.png

Next is the link to my video
MUTE YOUR SPEAKERS!! (I didn't know my camera recorded audio, yay!)

That was a more stable run, although sometimes they'll blink a few times on the off right away, then stop.

So here is my code, I don't think that the code is making it do it, I think it is something to do with how its setup.

#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;

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

void loop()
{
  int channelOne = random(15);
  int channelTwo = random(15);
  int channelThree = random(15);
  int channel = 0;
  int maxValue = 4095;
  if (channelOne == channelTwo || channelThree)
  {
    channelTwo = random(15);
    channelThree = random(15);
  }
  
  if(channelTwo == channelThree)
  {
    channelThree = random(15);
  }  
  
  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
    if (!tlc_isFading(channel)) {
      uint32_t startMillisOne = millis();
      uint32_t endMillisOne = millis() + 10000;
      uint32_t startMillisTwo = millis() + 5000;
      uint32_t endMillisTwo = millis() + 15000;
      uint32_t startMillisThree = millis() + 7500;
      uint32_t endMillisThree = millis() + 17500;
      tlc_addFade(channelOne, 0, maxValue, startMillisOne, endMillisOne);
      tlc_addFade(channelOne, maxValue, 0, endMillisOne, startMillisOne);
      tlc_addFade(channelTwo, 0, maxValue, startMillisTwo, endMillisTwo);
      tlc_addFade(channelTwo, maxValue, 0, endMillisTwo, startMillisTwo);
      tlc_addFade(channelThree, 0, maxValue, startMillisThree, endMillisThree);
      tlc_addFade(channelThree, maxValue, 0, endMillisThree, startMillisThree);
    }
  }
  tlc_updateFades();
}

funkyguy4000:
I have a 470 ohm resistor on the IREF instead of the 2.2k pull up like i'm supposed to, those are still on order.

I don't think you want to do that really. According to the page you linked too, you're pushing 80mA's to each channel (39.06/470=0.083) vs (39.06/2200=0.017).

I'd think that's a really bad thing.

Not sure 100% that's the problem but there is a huge difference between the IREF value you're using and the one you wanted to use.

I hope this helps,

Brad.

EDIT: Perhaps you've got more than a single 470 Ohm resistor? You can add several in series to get closer to your desired output (see http://www.learnabout-electronics.org/resistors_20.php)

Also your power supply may not be supplying enough power.

  if (channelOne == channelTwo || channelThree)

Actually you want something like

  if (channelOne == channelTwo) || (channelOne == channelThree)

Should work better as well.

Brad.

Have you tried the examples that come with the library? Do they work? If they do, it's a code issue, if not, it's a setup issue.
You don't need the Blank resistor, it's just handy if you want the LEDs to go off when the Arduino resets. The other is quite important! Normal LEDs will run at 20Ma, so giving them 80 will cause them to blow, eventually.
You don't have any decoupling capacitors, the tutorial should really include those.
Have you tried disconnecting DCPRG from +5v? It causes issues for me.
Are you powering this all directly from the Arduino? That wont work as it can't output enough power and the drain will cause it to lockup and occasionally reset. You'll need a proper 5v supply for the LEDs.
I have the same setup so, if you want, post some pics and I'll compare it against mine.

Cheers

Wow thanks for all the replies!
I will try these tonight since i'm in classes right now until 5:30 pm (central).

Wow i feel stupid that I didn't think about linking them up in series. to get the higher resistance. I know it isn't good for what i'm pushing through, the chip was getting a little hot.

Also i realized the example code thing to check if it was a code issue while i was taking a shower not 15 minutes ago, haha.

Thank you! i'll be sure to let you know how it all goes.

Okay! so I wired them up with the proper resistors and now it lasts longer, although there is still lotsa flickering, i'm very confused. I'm using the same code as the code at the beginning of this thread.
I took another video

The lights still turn off eventually but it isn't captured in this. They just turn off, like BLANK was activated or something?

Turn off your speakers if you are under 18 please.

I don't really have much room for capacitors on this build, does anybody have any sort of code solution?

I had a very similar problem with my TLC's. Unfortunately I fixed my issues with a 101 cap between the SCLK and GSCLK pins. My thread is here http://arduino.cc/forum/index.php/topic,66126.0.html. There are quite e few youtube videos there describing my problems. They were all fixed with the simple placement of the cap.

unhappyelf:
They were all fixed with the simple placement of the cap.

While I wouldn't rule out this being the problem, the OP never did say how the example code ran (there are several threads with the same code) and there are several issues with the code as shown that could cause problems.

I'd suspect the problem is that the OP isn't calling tlc_updateFades enough... note the last if statement is adding new fades even if the current fades are still in progress (due to the "if" statement not checking the correct variables - 'channel' vs 'channelOne', 'channelTwo', and 'channelThree').

Brad.

True my bad......I have never used the Fades library for the TLC5940 so I would have no idea.

Well the example code seemed fine although no LEDs ran from the 2nd TLC5940 that was daisychained.

funkyguy4000:
Well the example code seemed fine although no LEDs ran from the 2nd TLC5940 that was daisychained.

You need to modify NUM_TLCS in tlc_config.h in the library folder (read the text at http://tlc5940arduino.googlecode.com/svn/wiki/images/breadboard-arduino-tlc5940.png)

I hope this helps,

Brad.

Ok so i changed up the code
Here it is:

#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channelOne, channelTwo, channelThree;

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

void loop()
{
  int maxValue = 4095;
  if (channelOne == channelTwo || channelOne == channelThree)
  {
    channelTwo = random(15);
    channelThree = random(15);
  }
  
  if(channelTwo == channelThree)
  {
    channelThree = random(15);
  }  
  
  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
    if (!tlc_isFading(channelOne) && !tlc_isFading(channelTwo) && !tlc_isFading(channelThree)) {
      uint32_t startMillisOne = millis();
      uint32_t endMillisOne = millis() + 10000;
      uint32_t startMillisTwo = millis() + 5000;
      uint32_t endMillisTwo = millis() + 15000;
      uint32_t startMillisThree = millis() + 7500;
      uint32_t endMillisThree = millis() + 17500;
      tlc_addFade(channelOne, 0, maxValue, startMillisOne, endMillisOne);
      tlc_addFade(channelOne, maxValue, 0, endMillisOne, startMillisOne);
      tlc_addFade(channelTwo, 0, maxValue, startMillisTwo, endMillisTwo);
      tlc_addFade(channelTwo, maxValue, 0, endMillisTwo, startMillisTwo);
      tlc_addFade(channelThree, 0, maxValue, startMillisThree, endMillisThree);
      tlc_addFade(channelThree, maxValue, 0, endMillisThree, startMillisThree);
    }
  }
  tlc_updateFades();
}

Here is the link to the video of it"

and here is another of it a few minutes later, started doing some funky thing.

...
  if (channelOne == channelTwo || channelOne == channelThree)
  {
    channelTwo = random(15);
    channelThree = random(15);
  }
  
  if(channelTwo == channelThree)
  {
    channelThree = random(15);
  }

So are you using one TLC5940 or two? By setting your channel values to between 0-15 you're only picking LEDs from the first TLC5940. LEDs on the second TLC5940 will have channel values between 16-31.

Just so you know :slight_smile:

I assume you didn't add VBLANK resistors?

You've also got some LONG fades... as written, the code will setup 3 LEDs from the first TLC5940 to fade, then wait until all the fades are done before going on. It looks like you've got some long delays in there.

What effect are you trying for? Have you considered just trying one fade at a time and see if you can make that work first?

Something like this:

...

void loop()
{
  int maxValue;

  channelOne = random(31);            // pick any one LED from 0 to 31
  maxValue   = 3584 + random(512);    // don't always use the same brightness

  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
    if (!tlc_isFading(channelOne))  {
      uint32_t startMillisOne = millis();
      uint32_t endMillisOne = millis() + 1000;
      tlc_addFade(channelOne, 0, maxValue, startMillisOne, endMillisOne);
      tlc_addFade(channelOne, maxValue, 0, endMillisOne, startMillisOne);
    }
  }
  tlc_updateFades();
}

This will give you a 1 second fade from a random LED, and with a little variation in brightness (you might want to tweak the values used a bit). I didn't test this, but it might work :slight_smile:

Or maybe better is something like this (I think it's easier to understand):

...

void loop()
{
  int maxValue;

  channelTwo = random(31);            // pick any one LED from 0 to 31
  maxValue   = 3584 + random(512);    // don't always use the same brightness

  uint32_t startMillisOne = millis();
  uint32_t endMillisOne = millis() + 1000;

  tlc_addFade(channelOne, 0, maxValue, startMillisOne, endMillisOne);
  tlc_addFade(channelOne, maxValue, 0, endMillisOne, startMillisOne);

  // now run the fade until it completes
  while (tlc_isFading(channelOne))
    tlc_updateFades();
}

Maybe this helps?

Brad.

I'll try those out, i'm using two tlc5940s and i went into the config file and changed the NUM_TLCS from 1 to 2, it was at 1 already for some reason and so i changed it to two. I couldn't find the Tlc5940.o file so yea. I assumed it wasn't there and yea.

I'll upload the code and report back in a few

Okay so i tried the 2nd code you submitted and here is the result

In response to the wiring, i have it wired up exactly as how it was before.

Heres the 1st code post you gave me.

funkyguy4000:
In response to the wiring, i have it wired up exactly as how it was before.

So that means no 10k on VBLANK then? Sorry, I was just asking.

This is closer to what I had in mind... can you see the differences from the code I posted before?

void loop()
{
  int maxValue;

  channelOne = random(15);            // pick any one LED from 0 to 31
  maxValue   = 3584 + random(512);    // don't always use the same brightness

  uint32_t startMillisOne = millis() + 50;
  uint32_t endMillisOne = millis() + 1000;

  tlc_addFade(channelOne, 0, maxValue, startMillisOne, endMillisOne);
  tlc_addFade(channelOne, maxValue, 0, endMillisOne, endMillisOne + 1000);

  // now run the fade until it completes
  while (tlc_isFading(channelOne))
    tlc_updateFades();
}

A problem in your code that I missed is you have an error with the 2nd tlc_addFade (you need to make sure the fade is set to end after it starts).

I finally added more LEDs to my TLC5940 board so I could see exactly what the code was doing.

Brad.

EDIT: Removed bogus error comment here... note the other code is much more visually interesting once you correct the errors - that 50 millis delay before the fade starts allows the fade buffer fill up a bit and is probably more along the lines of what you want. I do wonder if you should be checking to make sure you don't have multiple fades on the same channel (since random could return a dupe).

EDIT2: You should use 31 not 15 in the code fragment - I've only got one TLC5940 wired in to my board.

I don't understand why my 2nd tlc5940 won't work.

So the code seems to work fine although i still don't have any communication through the 2nd tlc5940(the daisychained one). and every once in a while an led will flicker a bit, seems like i would need a .1 micro farad cap although i dont have enough room for that.

Here is the video

I changed the channelOne = random(15);            // pick any one LED from 0 to 31

to channelOne = random(31);            // pick any one LED from 0 to 31

so that it would encompass all the leds avaliable

funkyguy4000:
I don't understand why my 2nd tlc5940 won't work.

Have you ran the BasicUse example against your hardware? Either make sure you modify NUM_TLCS (which I think you've done) OR change the example code itself.

This example will do a "night rider" sort of fade along all the LEDs available.

If that doesn't work you need to double-check your wiring.

(the code you're running will have an extra delay with no-LEDs lit every so often - I assume because there isn't actually 512 levels of brightness for LEDs - but your video has too many "holes" where I think it's trying to fade LEDs on the 2nd TLC5940).

Brad.