TLC5940 and TIP120 to control LED strips

Hello All! First time poster, long time reader!

I have been playing around with arduino for about a year or so now and want to try something with a little more juice than ive done in the past.

Project:
Use TLC5940 to control 10 sets of 12v LED strips common anode, using PWM

As i understand the TLC5940 has 16 outputs so id need 2 5940s and 30 TIP120 Darlington transistors right? Should i be using a mosfet instead?

I attached some code i found from kevin darrahs awesome youtube tutorial. I am trying to get this code to work with my setup but it doesnt seem to be working. I am wondering if I just have it wired wrong. I have it wired similar to this but with TLC5940s instead of the 74hc595s. Can someone point me in the right direction, what am i missing?

_5940_with_rgb_strip_and_Moffset.ino (11.3 KB)

You are missing a schematic.

The TLC5940 can only sink current unlike the 595 which can both source and sink it.

The signal is inverted from the 5940 and so you can never turn the strips fully off.

Please read ALL of the how to use this forum sticky post.

Whoops! :o

heres the diagram

I am fine with them still being slightly on, i have read that about the 5940s.

I'm not sure why you told me to read ALL of the sticky? Because i attached the code instead of inserting? If it's because you think i haven't searched, I have been searching this for weeks and I thought id finally ask for some assistance. I'll be happy to tailor the post more, i didn't mean to break any rules or anything. Thanks for any advice!

Well i have tried to post that diagram couple different ways and it seems to be messing up, probably because its a google drive doc. here is a direct link to the image

Sorry but that is not a schematic, it is a physical layout diagram which is useless for communicating what the circuit is.

I'm not sure why you told me to read ALL of the sticky?

Because it contains very good information about how to ask a question and how to get the most out of this forum.

I am trying to get this code to work with my setup but it doesnt seem to be working.

So what did the advice say about this sort of comment?

Grumpy_Mike:
Sorry but that is not a schematic, it is a physical layout diagram which is useless for communicating what the circuit is.
Because it contains very good information about how to ask a question and how to get the most out of this forum.
So what did the advice say about this sort of comment?

I could have been a little more specific, when I run the code nothing happens other than my lights on my Arduino UNO signal that it receives the code. Other than that I did post the code I'm trying to use.

I can try to draw out the circuit later tonight if I can get to it. I guess the main wiring question i have is with the TIP120, I am confused by the datasheet. I understand that my output from the 5940 should go to the first pin of the TIP120 but im not sure about the other two. Data sheet linked below

TIP120 Datasheet

Then just draw that bit out.
As I said the TLC5940 can not source current it can only sink it. So connecting the output to the base of a transistor is not going to do anything for you.

You should connect the output directly to the base ( not through a resistor ) and then connect a resistor from the base to +5V.

Just get one working first before you try and build lots.

Grumpy_Mike:
Then just draw that bit out.
As I said the TLC5940 can not source current it can only sink it. So connecting the output to the base of a transistor is not going to do anything for you.

You should connect the output directly to the base ( not through a resistor ) and then connect a resistor from the base to +5V.

Just get one working first before you try and build lots.

Aw ok I will definitely give that a shot, I've never used the 5940s before and current sink kinda confuses me. I appreciate your help a lot, I know I am a noob and ask some stupid questions!!! Sorry! =/

Current sinking is like a switch to ground inside the chip. Current sourcing is like a switch to +5V in the chip.

Some outputs source and sink, that is like a switch inside the chip connecting the output to +5V or ground depending on if the output is high or low.

Grumpy_Mike:
Current sinking is like a switch to ground inside the chip. Current sourcing is like a switch to +5V in the chip.

Some outputs source and sink, that is like a switch inside the chip connecting the output to +5V or ground depending on if the output is high or low.

Ok that makes sense! I will draw up a schematic and hopefully just drawing it all out will help me better understand the +5v and resistor from the base.

just drawing it all out will help me better understand the +5v and resistor from the base.

Like doing lines at school :slight_smile:

Grumpy_Mike:
Like doing lines at school :slight_smile:

Its how I got through college! haha jk

I apologize for disappearing, we had a death in the family and I was out of town for a week. I have attached a schematic of how I am trying to wire them up. I tried to add the 5v to the base pin but it didnt work. Does that schematic look correct?

I tried using kevin darrahs code when i first started working with the tlc5940. But it's needlessly complicated. His video is great for understanding everything about the chip. but you just dont need to know all that. Install the tlc5940 library. In the setup you just put Tlc.setup, then in the loop you do Tlc.set('pin', 'duty cycle'); It's far easier to program the chips this way. there's a wiring diagram for most arduino boards.
http://playground.arduino.cc/Learning/TLC5940

Check first to see if an led connected directly to the chip works. This tests out the software and basic wiring.
Otherwise it looks fine apart from the symbol you have used for the led strips. You just put an led and that implies you need resistors but you don't because they are included in the strip.

Grumpy_Mike:
Check first to see if an led connected directly to the chip works. This tests out the software and basic wiring.
Otherwise it looks fine apart from the symbol you have used for the led strips. You just put an led and that implies you need resistors but you don’t because they are included in the strip.

Thank you for the replies!! Sorry about that Mike, very new so I am trying to learn as I go, any suggestion on how i should have drawn it? Maybe just include the internal resistors in the drawing? I found a post by you (mike) about the tlc5940 with external power that has proven to be pretty helpful, thanks for that!! If memory serves correctly, i have tried connecting the LED directly to the chip and that didnt work.

I believe my wiring for the chip is wrong. I’ll be honest, i was heavily relying on Kevins video and I think that’s my problem. I have started to really dig through that datasheet and i already know i have part of it wrong. I will try to fix it tonight and see where that gets me!

griffin175:
I tried using kevin darrahs code when i first started working with the tlc5940. But it’s needlessly complicated. His video is great for understanding everything about the chip. but you just dont need to know all that. Install the tlc5940 library. In the setup you just put Tlc.setup, then in the loop you do Tlc.set(‘pin’, ‘duty cycle’); It’s far easier to program the chips this way. there’s a wiring diagram for most arduino boards.
http://playground.arduino.cc/Learning/TLC5940

Yes I have been trying to understand his code and I understand most of it but some of it i have zero comprehension. If i can get my lights to react from the TLC5940 then I will rewrite all the code for what i want to do exactly.

Thanks again for all the help!!!

Here’s the basic bare bones code you need for using the tlc5940 library if you decide to use it.

#include <Tlc5940.h>
 
void setup() {
 Tlc.init();

}

void loop() {
  Tlc.clear();
  Tlc.set(0, 0);       //(pin # 0 to 15, duty cycle 0 to 4095)
  Tlc.update();

}

i have tried connecting the LED directly to the chip and that didnt work.

That is the first step you must do before trying any external driving.

It is important to realise that the wiring of a TLC5940 depends on the library you are using. This is because in order to drive it you have to use specialized hardware in the chip. Depending on what choices made in writing the library determines how it has to be wired up. In the evolution of what is now the widest used library the wiring has changed at least twice.

any suggestion on how i should have drawn it?

The LED strip is a sub assembly and as such has no universally recognised symbol. When faced with that sort of thing what you do is draw a rectangle, put the part number in it and label the connections.

Thanks guys!! I have decided to go ahead and use the code that came with the TLC5940nt library to alleviate any wiring differences that may have been an issue. This is the code and exactly how i have it wired to my arduino. The LED strip will now light up if i connect it directly to the TLC5940 rather than through the TIP120. For some reason i am still getting nothing out of the strip if i am going through the TIP120s, I did draw this out if you want me to post it but the code below does a pretty good job of showing how its wired.

/*
    Basic Pin setup:
    ------------                                  ---u----
    ARDUINO   13|-> SCLK (pin 25)           OUT1 |1     28| OUT channel 0
              12|                           OUT2 |2     27|-> GND (VPRG)
              11|-> SIN (pin 26)            OUT3 |3     26|-> SIN (pin 11)
              10|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 13)
               9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
               8|                             .  |6     23|-> BLANK (pin 10)
               7|                             .  |7     22|-> GND
               6|                             .  |8     21|-> VCC (+5V)
               5|                             .  |9     20|-> 2K Resistor -> GND
               4|                             .  |10    19|-> +5V (DCPRG)
               3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
               2|                             .  |12    17|-> SOUT
               1|                             .  |13    16|-> XERR
               0|                           OUT14|14    15| OUT channel 15
    ------------                                  --------

    -  Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
         (cathode) in OUT(0-15).
    -  +5V from Arduino -> TLC pin 21 and 19     (VCC and DCPRG)
    -  GND from Arduino -> TLC pin 22 and 27     (GND and VPRG)
    -  digital 3        -> TLC pin 18            (GSCLK)
    -  digital 9        -> TLC pin 24            (XLAT)
    -  digital 10       -> TLC pin 23            (BLANK)
    -  digital 11       -> TLC pin 26            (SIN)
    -  digital 13       -> TLC pin 25            (SCLK)
    -  The 2K resistor between TLC pin 20 and GND will let ~20mA through each
       LED.  To be precise, it's I = 39.06 / R (in ohms).  This doesn't depend
       on the LED driving voltage.
    - (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
                  all the LEDs will turn off when the Arduino is reset.

    If you are daisy-chaining more than one TLC, connect the SOUT of the first
    TLC to the SIN of the next.  All the other pins should just be connected
    together:
        BLANK on Arduino -> BLANK of TLC1 -> BLANK of TLC2 -> ...
        XLAT on Arduino  -> XLAT of TLC1  -> XLAT of TLC2  -> ...
    The one exception is that each TLC needs it's own resistor between pin 20
    and GND.

    This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
    Do not use analogWrite(...) on these pins.

    This sketch does the Knight Rider strobe across a line of LEDs.

    Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */

#include "Tlc5940.h"

void setup()
{
  /* Call Tlc.init() to setup the tlc.
     You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
  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) {

    /* Tlc.clear() sets all the grayscale values to zero, but does not send
       them to the TLCs.  To actually send the data, call Tlc.update() */
    Tlc.clear();

    /* Tlc.set(channel (0-15), value (0-4095)) sets the grayscale value for
       one channel (15 is OUT15 on the first TLC, if multiple TLCs are daisy-
       chained, then channel = 16 would be OUT0 of the second TLC, etc.).

       value goes from off (0) to always on (4095).

       Like Tlc.clear(), this function only sets up the data, Tlc.update()
       will send the data. */
    if (channel == 0) {
      direction = 1;
    } else {
      Tlc.set(channel - 1, 1000);
    }
    Tlc.set(channel, 4095);
    if (channel != NUM_TLCS * 16 - 1) {
      Tlc.set(channel + 1, 1000);
    } else {
      direction = -1;
    }

    /* Tlc.update() sends the data to the TLCs.  This is when the LEDs will
       actually change. */
    Tlc.update();

    delay(75);
  }

}

I went ahead and tried a regular LED directly attached to the TLC output 0 pin and it works as the code is designed, so I know for sure its not the code or the TLC5940nt. Any ideas?