Library for TLC5940 16-channel PWM chip

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.

Reducing the speed didn't help to prevent the flickering.
I've connected the resistors between the last (12th) tlc board and the arduino pins (so that it makes a circle). That was most convenient to test. Should I put them somewhere else?

Hi
I am trying to get the TLC5940 to work with a DMX-512 receiver project.
And I am out of luck :frowning:
I think the problem is that TIMER2 is used in both project. Does anyone have any suggestions??

Here is a link to the receiver project

http://blog.wingedvictorydesign.com/2009/03/20/receive-dmx-512-with-an-arduino/

I made myself a 8x11 rgb matrix with 3 tlcs and made a new library variant, Tlc5940Mux. Still alpha, needs documentation, and I'll probably write some more documentation for the main library.

I multiplex 8 rows: all anodes (+) of each led in the row are connected together, and each column goes to a tlc. All the red leds in the first column go to channel 0 of the first tlc, all the blue leds to channel 0 of the second tlc, and all green columns go to the third tlc.

There's two examples, a Matrix example that displays a diagonal line, and a Serial example that uses 0.5M baud serial (and a python program) to scroll an image ("Arduino Rocks My Socks!!!" in rainbow colors) at 60 fps. Youtube coming soon when I get a chance to edit the video.

acleon, that's quite impressive! How often are you refreshing the TLC with new data and changing columns? How much does this affect the LEDs brightness, since they're effectively getting 1/11th as much power sent to them?

It's switching rows every 512us (microseconds), and an update for 3 tlc's takes ~160 us. I'm using cheap leds from ebay, which are pretty bright.

The image:

What it looks like in the dark behind a piece of paper (the blending between pixels makes it look better when the text scrolls):

Without the paper:

First off...I must say that your 8x11 matrix is one beautiful ratsnest of wires. I love seeing stuff like that :wink:

Second, this couldn't have come at a more opportune time! I'm currently in the process of building a larger version of Tinkerlog's 64pixels to mount on my newly made satchel/man-purse. But to have a full color matrix rather than one-color...now you're cookin' with gas!

Do you have a schematic for that setup? It looks like you have some transistors in there, as well as some current regulators.

Hello!

I'm kinda new to this electronics stuff and I'm having a bit of an issue. I multiplexed 3 TLC5940 chips like it is done on te arduino playground example. For the IREF used a 560 Ohm resistor. I'm trying to drive 24 groups of 5 RG LEDs (with common anode ofc). So that's 48 times 5 LEDs with 3 TLC's.

The chips are powered by the Arduino. The LEDs are powered with a power supply of 3V and 1.4A. This is a bit low I was told, but I was expecting some result. Yet nothing seems to happen when I run the BasicUse example of the TLC5940 library.

I'm not good with power supply numbers and currents and stuff like that, and for this reason I've already destroyed a batch of TLC chips :). Does anybody have any clue what kind of power supply I should use? The schematic once again is the same as the one of the arduino playground, only with 560 Ohms on the IREF. Many thanks in advance!

Jeuv

Hi,
first, thanks for a great library for the tlc5940!
I had no problems getting it to work with 16 leds and using the basic use sketch.
I want to use it for LEDs which draw more current than what the tlc5940 can handle, and after some research here in the forums I found two solutions, either using a mosfet or a NPN transistor.
I decided to go with the NPN solution.

I hooked up 5 high current leds (3W, drawing 700mA each) on the first five channels, and used normal leds for the rest of the channels.
I used a 10k pull-up resistor for each of the high current channels, each channel connected to a tip122 (through a 1k resistor) which again is connected to the led and a constant current regulator (LM317).
The Iref resistor is 2k (so about 20mA current from the tlc5940).
See the schematic for more details.
http://www.bek.no/~hc/downloads/powerled_schematic.png

As exected the values are reversed so 0 is on and 4095 is off.

I made an extremely simple sketch, first one with only turning on/off channel 0, the first of the high current leds.
The led turned on/off as expected. However, the other channels behaved strangely, going on and off more or less randomly (at least I haven´t found a logic to it yet), often many of them turning on/off at the same time.

When I expanded the sketch to turn on/off all the high current leds in a sequence, they behaved as expected, but again, now and then the other channels behaved strangely.

First I thought the tlc5940 was drawing too much current, but the chip was not hot at all.
Maybe I am missing something obvious in the code?

#include "Tlc5940.h"

void setup()
{
  Tlc.init();
// I added these two lines to see if it helped, but they didnt make a difference
   Tlc.clear();
   Tlc.update();
}
void loop()
{
  tlcflash(0);
  tlcflash(1);  
  tlcflash(2);  
  tlcflash(3);  
  tlcflash(4);  
}

void tlcflash(int tlc) {
  Tlc.set(tlc, 0);
  Tlc.update();
  delay(1000);
  Tlc.set(tlc, 4095);
  Tlc.update(); 
}

thanks for any input.

hc

Incredible work. Interestingly theres a guy on youtube whos basically copied your work (and many others) and is seemingly pretending he created it out of whole cloth. Maybe "developing in parallel" would be more accurate. He didnt appreciate my noting such.

Anyway could you toss the mega8 zip up to the google code site? I went NUTS trying to get the 168 version working on my old ng. I shouldve bought a diecimila heh but the old oscilloscope i just bought (Woot!) just killed that budget. PS i had a problem with the basicuse on ng but the others are great on the mega8

Thanks for all your hard work by the way