Library for TLC5940 16-channel PWM chip

how do you like it ?

thx acleone for library

how about some details of the build
especially the equalizer effect?

So my main goal is to build a 16x7 matrix for a coffee table. so i wrote a program to control it and also made a demo board

So right now im testing my program to control a 4x4 led matrix.

untill i figure out a faster interface method from computer to arduino the most led's i can support at 25 fps is about 125 or so

Heres the pictures of the demoboard

And heres the youtube video of the board and program working

@joe912: cool stuff! care to share your program/build?

I'm sorry ahead of time if I am doing something stupidly wrong here :slight_smile:

first off,
using a Duemilanove
using version 11 of the tlc library
using the arduino software, v 13
everything connected as shown in BasicUse.pde w/2.2k resistor to pin 20
BasicUse.pde works fine

when i try to connect a servo and use the servo example it doesn't move at all

servo connected as follows
brown - ground
red - +5v
orange - pin 28 (out 0) and a resistor going to +5v
I have tried a 4.7k as well as a 2.2k resistor

maybe I have the resistor codes wrong?
4.7k is yellow / violet / red
2.2k is red / red / red

also a pull-up resistor is just a resistor used in a special way correct?

Thank you for any help

Josh

here is an image

ive never tried servos but you could always try hooking up a led to the output, it should appear to blink or atleast do something.

also have you tried another servo library or in a rc model to verify that the servo works

also looking closer at your photo i cant tell if the breadboard ground has a ground connected to the arduino ground

I haven't been following this thread but has anyone actually posted some code that makes that chip work with servos.

this thread may help you get your servos working: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

ive never tried servos but you could always try hooking up a led to the output, it should appear to blink or atleast do something.

also have you tried another servo library or in a rc model to verify that the servo works

also looking closer at your photo i cant tell if the breadboard ground has a ground connected to the arduino ground

led doesn't do anything that I can see besides a very faint light

the servos work fine with the regular arduino servo library

yup, all the grounds are connected to the arduino ground

I haven't been following this thread but has anyone actually posted some code that makes that chip work with servos.

this thread may help you get your servos working: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

yeah, back a page or 2 the op made a post about this now supporting servos, and an example is included in the zip file

great link, all my servo searching and I never came acrossed that one, i'll have to read those further

thanks guys for the quick responses

Has anyone had an issue with "long-term" running of fades?

I have 4 RGB LEDs hooked up to the TLC, set to fade every 15 seconds to a randomly selected color. When I power the circuit up (I have the arduino set up as a stand-alone, on a PCB) everything runs fine. But when I came back to the board after a day or so, the whole thing was "frozen", and nothing worked -- no fades, and my inputs weren't responding.

I double-checked my code, and I don't see anything that might cause an issue. The only thing I could think of is the "old" millis issue where it rolls back to 0 after a while. So if X is the millis rollover point, and your timer was looking for X+10, you would never actually hit that point.

I found a post from this year saying that the rollover occurs after 55 days, as opposed to 9 hours (which was what I was familiar with). Maybe I'm using an old bootloader? I'm using Arduino 0012, and my chip I bought in July 2008.

I am very grateful for this library, makes what I want to do a lot easier.
Right now I have it working, I have these RGB led strips that I can control the way I want.

However, I noticed that the color differs a bit per strip, I think that is due to perhaps a difference in leds or the inaccuracy of the resistors. I would like to correct for that using a calibration. Can I do that using the built in dot correction of the tlc 5940?

And then how should I do that with this library, my idea is now:

  • set "#define VPRG_ENABLED 1" in in tlc_config.h
  • connect Arduino digital pin 6 to TLC pin 27 in stead of GND
  • use tlc_setDCfromProgmem(dcArray1); to set all the pins at once

Questions:

  • is this correct? (or do you think there is a better way)
  • is it also possible to set just 1 pin at once? and can I only do it from progmem? (tlc_setDCfromProgmem is the only function that sets dot correction, right?)
  • is this data automatically stored in the EEPROM memory of the tlc5940? Or should I always have VPREG enabled and send the final calibration array every time I want to use it?
    Is it simply a matter of setting tlc's DCPRG pin high to store it?

second question:
the drive capability of the 5940 is 120 mA, is that per channel? so can it do the 16*0.12=1.92Ampere? Does that require additional cooling? what are your experiences?

Yes i'd like to do this too. My channel 0 is outputting a lower voltage to my 8x8 array.

is it possible to set the Dot Correction value on just one channel individually? I see the example shows how to set ALL of them to the same value, but I don't see the point in that function. How can just one channel be adjusted on it's own please?

According to the datasheet: VPRG :Multifunction input pin. When VPRG = GND, the device is in GS mode. When VPRG = VCC, the device is in DC mode. When VPRG = V(PRG), DC register data can programmed into DC EEPROM with DCPRG=HIGH

Each dot correction register is 6 bits, so you need to shift in 96 bits and then latch the data into the register.
Basicly it's the same MO as shifting in Greyscale bits, but you now do it while VPRG = high

I'm working on a project where I have 12 TLC's with 5 RGB leds each, all TLC's on separate boards connected through 10cm ribbon cable (power external). I'm trying to drive them with one arduino and this library. I've been able to get 10 boards to work however the last two give problems. As soon as they are connected the first 10 still work but the first one (the one connected to the arduino) starts to flicker and the last two boards just give some random colors. The config file has been changed and the .o file deleted. When I put my finger on the flickering board the flickering gets less. As soon as the two boards get removed the flickering is gone.
Anybody have an idea on how to fix it or what the cause is? Maybe too long leads?
I haven't got my DSLR and camcorder here, but if required I can make a few pics later.

Maybe the Arduino is not providing enough power to drive all the chips? Have you tried to power the chips from an external supply?

The TLC's are connected to an external power supply (4,4 V) both the VCC and VLED.

Chronoless:
The flickering you describe sounds like it's being caused by long wires. If you have a scope, see if you're getting ringing on the control lines. Try putting resistors in series with SCLK and XLAT and one of the tlc's.
For example,
Put a 1k between the ribbon cable SCLK and the 10th tlc's SCLK (and same with XLAT). 1k is pretty arbitrary so try other values.

nphillips:
The new millis rollover was introduced with 0013(?) - it's not part of the bootloader. I updated tlc_fades again, try downloading r012 (Google Code Archive - Long-term storage for Google Code Project Hosting.).

TimoRozendal:

  1. Yes, that looks correct. See the documentation for tlc_setDCfromProgmem.
    The funny-looking
prog_uint8_t dcArray1[NUM_TLCS * 12]

gets stored in program memory, which is where your sketch goes (if you comment out the array, the sketch size would go down).
You don't have to set DCPRG high - tlc_setDCfromProgmem does this for you.

  1. Yes, it's 120 mA per channel. You will need cooling if you try to drive that much current - see the datasheet.

Mike Mc:
No, as ReSiStAnCe pointed out, you have to set all the dot-correction at once.

Josh18657:
Nothing looks wrong. The pull-up resistor value doesn't matter much, so 2.2k or 4.7k will work. If you have access to a scope, see if the tlc is generating pulses to the servo.

Sorry to have been inactive lately - I'll try to check the forums more often.

Thanks, AC! This came just in time :wink:

I'll give it a whirl tonight!

Thx for the quick reply!

I just tried putting the resistors in. The 1k resistors didn't do much. I searched around a bit on the internet and apparently it's called termination. To calculate the proper resistance I need to know the impedance of the 12 ribbon cables + 12 boards + connectors. I now used 4 x 100 ohm resistors because on some websites they were talking about 50 - 135 ohm resistors all the time. These worked a lot better. I can drive all LEDs however during quick updates (<10ms) the last boards flicker. So hopefully I can finetune the flickering by trying out some other resistors.
Does anybody have tips or tricks on how to estimate the exact correct resistance?
Is it possible to reduce the speed of the tlc clock? Because decreasing the speed would lengthen the maximum allowed length of the leads as far as I've been able to get out of the online stuff which is too complicated for my designer electronics skills :).

Chronoless:

You can lower the update speed by commenting out
SPSR = _BV(SPI2X); // double speed (f_osc / 2) in Tlc5940.cpp (line ~327). That will reduce the speed by half. If you need to go even slower, see "SPI clock rate select" on pg 170 of the datasheet.

Where are the resistors connected?

Everyone:

I finally got around to replacing my horrible ascii pin-out diagram! This is my first time using inkscape: anything I should change with my png? (inkscape svg source)

I got the breadboard from follower.