The TLC5940 is a 16 channel PWM unit with 12 bit duty cycle control (0 - 4095), 6 bit current limit control (0 - 63), and a daisy chainable serial interface. It is handy for expanding the number of PWM outputs available. The datasheet is available at http://www.ti.com/lit/gpn/tlc5940.
Some details about issues discovered using the chip and Eagle footprint for TLC5941: tlc594x and Arduino
New sources on GitHub: https://github.com/search?q=tlc5940&s=stars
Old library source is on Google Code. See source/downloads at: http://code.google.com/p/tlc5940arduino/
Unzip the Tlc5940 folder to <Arduino Folder>/libraries/
Open the BasicUse example in the Arduino IDE (1.6.5). It should be in File→Sketchbook→Examples→Library→Tlc5940.
Normal setup and wiring by [acleone]:
A hardware setup adding TIP122 transistors to the TLC5940 to achieve higher currents can be found here:here
The library can (as of r8) drive servos off the PWM channels. This means you can drive up to 16 servos at once, as well as use any spare channels for your other PWM needs! See File→Sketchbook→Examples→Library-Tlc5940→Servos for an example.
When using with RGB LEDs, you should purchase LEDs with common anode. Using common cathode LEDs will not work properly.
The link may not work correctly, so... Usage: Tlc.init(); 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.update(); updates all pins Tlc.set(channel, value); channel is pin number. As of December 7, 2011, pin number just keeps going up as you go to more and more daisy-chained chips. So, if you have two chips, and you want to talk to the last pin on the second chip, you address it to channel 32. Like so: Tlc.set(32, x); x can be from zero to 4095. It appears that you have to tell the library how many chips you are using.
Also see this post in the forum for the latest information.
This doesn't pertain to the library above, but it's still helpful.
There are a couple of wrinkles to using one with an Arduino, but nothing that can't be overcome.
First, for a serial interfaced part it has a rather large number of signals. Fortunately, we can ignore many of them if we wish.
The GSCLK and BLANK signals need to be stable and accurate or the outputs of the TLC5940 will be erratic. By using the hardware timers we can make those be solid no matter what is going on in the sketch. Besides, it costs you 3 to 4 8 bit PWMs and gets you 16 to 640 12 bit PWMs. It's a fair trade.
Yes. If you leave the current limiters wide open you shouldn't have a problem unless you are trying to light a room. Even then, probably not. But when you turn the current limiters down to the point that they are dropping significant voltage and you are running significant current you can overheat the package. There is a section in the datasheet on this, but if you don't want to worry about it then just set all the DC registers to 63 and stick your finger on the package now and again to see if it gets hot.
Hobby servos are driven by short, high, pulses every 10-40ms. The constants have been chosen in the following sample code to allow you to drive servos as well as LEDs or motors. Because the servos use high pulses and the TLC5940 is active low on the outputs the useful servo values are all at the upper end.
That will drive my cheap HS-311 through about 180 degrees. Do be careful not to hold your servo past its limits. It will probably use a lot of power and possibly burn up its motor if you try to hold it there. Remember: the outputs only sink current, you will want a pull-up resistor on here.
I suppose you can drive DC motors with this. Do put bypass diodes on your motor to protect the output stage of the TLC5940 from the inductive kick at motor turn off.
This device has a nifty EEPROM for storing individual current limits so you could set that once then let it be. The default value is 63, so just use this on a default chip/default hardware setup.
If you want to program them individually, then it takes a 22 volt level on VPRG to do that. If you do not need individual limiting (correction) then, just use the default setting, and set the general current limit by selecting the right ohm value.
For an older example of interfacing with this chip, see: OldCode