Questions about using TLC5940s w/ strip LED's

This is a mix of hardware and software questions, if it belongs more in programming, feel free to move…

First the hardware - application and questions…

I’m working on building some side lighting arrays for use on my power chair - I’ve seriously modified it, so I want to take off the manufacturer’s badges on the fenders, and replace them with a bunch of LED strips. The size of the badge recess dictates 8 strips of 6 5050 RGB LED’s on each side. They are “dumb” strips that control all the LED’s in a strip, not individually addressable, so I get 24 channels per side. The strips are 12V automotive strips, with resistors built into them, and each LED channel draws between 30 and 40 mA according to the bench supply I tested them on. 40ma x 16 channels = 640ma with all the channels on full, which should be well within the working range of a TLC5940, especially since I’m planning on having the strips cycling through colors so they won’t ever all be on at the same time…

Power will be 12V from the lighting output on the chair controller, though right now I’m using an 11V 2.3A laptop supply brick for development. I’m running the 12V through a 7805 regulator to make power for the Arduino and the TLC5940’s. I may switch that to a DC-DC buck board eventually, not sure if I’d save enough power to justify it though… The rest of the 12V goes to the common lead on the strips.

Since I have two blocks of 24 channels each, I’m planning on using 4 TLC 5940’s as I don’t want to have to run 25 drive wires for the second set around the chair. I plan to have the Arduino and 2 TLC’s in one fender, and run a control cable (probably using CAT5 ethernet wire, since it has about the right number of conductors, and is small and flexible) to the second two TLC’s in the other fender, which will keep the wiring to the LED strips as short as possible. The control cable would probably carry everything but the 12V power for the LED’s. Are there any special considerations I’d need to do circuit wise to drive over that cable (probably 2-3 feet long)

At the moment I’m working on breadboards, trying to get the 24 channels working on one side, and will then add the second block. When I get everything working I’ll probably spin dedicated boards, and possibly go to a bare AVR chip rather than a full Arduino since I don’t need most of it’s functions…

Since I sort of want the two blocks to be doing the same things at the same time (it isn’t an absolute requirement, but would be nice) is it possible / practical to connect the two sets of 5940’s in parallel to the Arduino rather than daisychaining them like most of the documentation suggests? Seems like that would simplify the code since I’d only need to write it for 24 channels rather than 48…

I’m currently wiring the first 16 channels to the first TLC, and the remaining 8 to the second one, so my code would be talking to channels 0-23 if I understand the library docs correctly. Any reason not to do that? If I should spread the load more evenly (presumably 0-12 on each chip) how would I deal with that in the code?

Now for the code questions…

I’m using the TLC5940 library from https://code.google.com/p/tlc5940arduino/ which seems like the most popular one. Is there any other library that might be better?

The sample code seems to work fine with just one chip with 16 channels wired. (I’m using the “Basic use” program from the library - it’s more or less what I’m going to want for an effect…)

If I try to use two chips I run into problems -

1st - the documentation says I need to modify tlc_config.h and delete tlc5940.o… I had no problem modifying tlc_config.h, but I can’t FIND tlc5940.o - where does it hide??? (I’m running on Kubuntu Linux if that matters) I can’t find any *.o files in any of the places I’ve looked…

2nd - If I try running the sample code I get long pauses as it appears the code is trying to work channels 24-31 that aren’t connected to anything… Every discussion I’ve seen seems to assume that all 32 channels are in use, but I can’t do that in my application.

I’m having problems getting the code to work with just 24 channels how do I do that?

I tried creating a number of channels variable, and simply replacing the code for number of TLC’s with that variable, but that gives me strange patterns not the “knight rider” effect… It appears to go back and forth on the first chip, then do stuff on the second one more randomly, then go back to the first…

Sketch below w/ most comments stripped for length reduction…

    /* Modified by ART to specify the number of channels actually used, as opposed to the number of TLC's x 2 */
    

#include "Tlc5940.h"

const int chan_no = 24;

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

/* 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. */

void loop()
{
  int direction = 1;
//  for (int channel = 0; channel < NUM_TLCS * 16; channel += direction) {
  for (int channel = 0; channel < chan_no; channel += direction) {
    Tlc.clear();
    if (channel == 0) {
      direction = 1;
    } else {
      Tlc.set(channel - 1, 1000);
    }
    Tlc.set(channel, 4095);

      Tlc.set(channel + 1, 1000);
//    if (channel != NUM_TLCS * 16 - 1) {
    if (channel != chan_no - 1) {
    } else {
      direction = -1;
    }

    Tlc.update();

    delay(750);
  }

}

If you only need 24 channels I'd set NUM_TLCs to 2 and just ignore the top 8 channels. IIRC with 2 TLCs, the channel numbering is 0-15 on the SECOND one, then 16-31 on the FIRST. i.e "first" being the one the arduino goes to.

Have you dble checked your wiring? SOUT from TLC1 -> SIN on TLC2 etc?

I'm currently wiring the first 16 channels to the first TLC, and the remaining 8 to the second one, so my code would be talking to channels 0-23 if I understand the library docs correctly.  Any reason not to do that?

No, that's fine.

If I should spread the load more evenly (presumably 0-12 on each chip) how would I deal with that in the code?

Simply do Tlc.set(0-12) and then Tlc.set(16-24); You could roll your own "set" fn so you could call "set(0-24)", and your fn would translate that into the TLC calls.

You haven't mentioned anything about wiring. I'm new to all this, but have done something similar to you. How are you switching the 12V using the 5V from the arduino? I used ULN2803 with pull up resistors. See this thread - TLC5940, ULN2803 and 12v RGB strips - LEDs and Multiplexing - Arduino Forum - for more info.

1st - the documentation says I need to modify tlc_config.h and delete tlc5940.o...  I had no problem modifying tlc_config.h, but I can't FIND tlc5940.o - where does it hide??? (I'm running on Kubuntu Linux if that matters)  I can't find any *.o files in any of the places I've looked...

.o are the object files that are compiled from the source. The Arduino IDE should automatically recompile any that have changed, so you shouldn't need to delete it. I have a feeling that the Arduino IDE recompiles everything everytime anyway, so you should be good. I never deleted the .o file, and it always picked up my changes.

Your code should be fine, can you stick normal LEDs into all the channels, then you will be able to see exactly what is going on.

Thanks for the reply -

If you only need 24 channels I'd set NUM_TLCs to 2 and just ignore the top 8 channels. IIRC with 2 TLCs, the channel numbering is 0-15 on the SECOND one, then 16-31 on the FIRST. i.e "first" being the one the arduino goes to.

Have you dble checked your wiring? SOUT from TLC1 -> SIN on TLC2 etc?

I've double checked the wiring repeatedly, and all looks good - doesn't guarantee that it is, but... I was having trouble with bad connections in the breadboard sockets so I got a bunch of header pins and have been soldering my wire ends to those to make jumpers that connect solidly. that got rid of a lot of odd issues.

Where did you see that info on the channel numbering? I've been under the impression that it was linear from the Arduino -> TLC1 (0-15) -> TLC2 (16-31) -> TLC3 (32-47) etc...

The problem I have with just ignoring the top channels is that I get a big pause in the cycling of the LED's as it (presumably) tries to light up the empty channels. I want to have a non-stop cycle through 0-23 with no pauses...

You haven't mentioned anything about wiring. I'm new to all this, but have done something similar to you. How are you switching the 12V using the 5V from the arduino? I used ULN2803 with pull up resistors.

Very simple - The way the TLC1540 works is that it's internal circuitry runs off the 5V supply, but the output pins are essentially logic level FETs connected to ground. Per the data-sheet you can have up to +19V connected to the LED cathodes, with the anodes connected to the TLC output pins. The Arduino tells the TLC which pins to turn on, which turns on the FET, connecting the +V on the LED to ground, w/ current allowed per the setting resistor.

This means that any voltage not being dropped by the LED (or any attached resistor) is dropped across the TLC, with resultant heat, so the usual suggestion is to use as low a LED supply voltage as possible. Since we already have to provide 5V for the Arduino and TLC, it makes sense to use that as the LED supply as well most of the time. However I need 12V to drive the strips (which have an internal resistor) so that is what I use.

.o are the object files that are compiled from the source. The Arduino IDE should automatically recompile any that have changed, so you shouldn't need to delete it. I have a feeling that the Arduino IDE recompiles everything everytime anyway, so you should be good. I never deleted the .o file, and it always picked up my changes.

OK, so I won't worry about the *.o files then....

Your code should be fine, can you stick normal LEDs into all the channels, then you will be able to see exactly what is going on.

I can't do normal LED's easily because of the 12V supply and 40mA current setting, but it would be easy enough for me to do some more sections of LED strip...

ex-Gooserider

Quick update - played with the wiring some more today, and after much puzzling, suddenly realized what my problem was, at least in part...

Because of the way I'd laid out my bread board, I was mis counting the output pins, so that what I had thought was "0" not doing what it was supposed to, it was really 16, and I had also plugged into 31 down, instead of 16 up... :blush:

Once I rearranged my LED connections, it seems to be working almost right - just going from channels 1-25 instead of 0-24, which I'm pretty sure has to be a code issue.

But at least I'm making progress...

ex-Gooserider

Good stuff! So you have connected your 12v ribbon directly into the TLC? Maybe I've just soldered 10x ULN2803s together for no reason....! I'm new to electronics and was advised I needed to use them.

How many meters of ribbon are you using? i.e. how much power can go through the TLC?

I’m only using very short segments - 6 LED’s per strip, or two sections… They are the 5050 type LED’s and when I was checking them on a bench power supply, it said I was pulling between 30 and 40 mA per color / per strip. This current draw goes up fast as the strips get longer - 4 sections (or 12 LED’s) doubles that value, and so on. The reason that the close spaced 5050 LED strips don’t come in more than 5 meter lengths is that you can’t reliably power a longer strip by connecting at just one end as you are pushing the limits on how much current the traces in the strip can carry…

I’d need to recheck the TLC datasheet for the exact numbers, (and they vary with the package type and mounting) but IIRC, you can sink about 1500 mA per chip in the DIP package, slightly more in the surface mount package with the heat sink pad on a PC board with the right copper pattern.

The sheet is a little misleading as the puff section gives a much higher value per output pin, but doesn’t tell you that driving all the pins that hard exceeds the total the chip can handle…

I just dug the sheet back up - it says 60mA / channel w/ VCC @ 3.3v and 120mA w/ VCC @ 5v on the first page, but on page 3 it tells you that the DIP package can only dissipate 1270 mW @ 70*C. This divides to about 80 mw / channel, At 12V, this is about 60mA before you start getting overly hot…

Bottom line is that you can use higher voltages on the TLC drive pins, but you need to watch both the individual pin currents, and the total power for the chip…

You need to calculate this stuff based on “worst case” scenarios - all the pins on and at maximum brightness…

ex-Gooserider

Ah yes, I have about 8 meters of the ribbon, in 10 seperate sections. I’d be drawing something like 166mW on all pins…think the ULNs were probably needed after all!

It’s useful to know the TLCs can drive 12v though. Although if I was doing short sections I’d probably use the addressable ribbon anyway as it’s much easier to control, just a lot more expensive!

markvr:
Ah yes, I have about 8 meters of the ribbon, in 10 seperate sections. I'd be drawing something like 166mW on all pins...think the ULNs were probably needed after all!

It's useful to know the TLCs can drive 12v though. Although if I was doing short sections I'd probably use the addressable ribbon anyway as it's much easier to control, just a lot more expensive!

Definitely, with that much ribbon you'd be overworking the chip to try and drive it directly...

Actually per the datasheet, the TLC's can have up to 17V on the drive pins. Perhaps even more if you put enough LED's in series to drop the voltage the TLC sees to 17V or less. (I think I saw an app-note saying this was acceptable) However the more voltage one is actually dropping across the TLC, the less current you can get away with, so IMHO it is best to keep the LED drive voltage down to the lowest value that will do the job...

ex-Gooserider