Go Down

Topic: Library for TLC5940 16-channel PWM chip (Read 35 times) previous topic - next topic


Thanks AC great library.

Is it possible to control the brightness of each channel?
If yes can someone please provide a sample of where they have done it?


Would it be easier to have another chip controlling a say mosfet to control each intensity.

Right now my setup is 3 TLC -> (3)Mosfets -> (1)RGB_LED

I thought about adding in a 4th TLC to control the common for intensity.

Let me know,


Oh yes one more question.

Is it possible to bitshift or do something to turn 0 into 4096 and 4096 into 0 for n channel fets?


Code: [Select]
int i = 2000;
int inverse = abs(i-4096); //subtracting 4096 makes it inverse, but negative, abs converts negative to positive, making the conversion complete

Hope that helps =)


Hi I noticed this interface in your initial email and wondered if it was by design ?
Tlc.setPWMperiod(PWM period (0 - n) milliseconds);

I read in the data sheet that the chip can have a max clock of 30MHz/ which works out at about 1/7th msec per 4096 clock pulses.

I guess that means the arduino has order of 2k instructions per cycle...

is that feasible?


Thanks on the code for inverse.
I was actually thinking about adding a !buffer chip to invert the outputs to drive the mosfets off when the signal is off / lost.
As for the pwm output i was wondering that myself I havnt seen it in there I think it had to be fixed when it changed to spi mode instead of bitbang.



=== code
int i = 2000 ;
int inverse = abs(i-4096) ;
=== or
int i = 2000;
int inverse = 4096 - i ;
below is a little smaller and simpler.


when would
int inverse = (4096-i)
be negative if you are inputting 0 and 4096? Unless you are going to put in values larger than 4096, I agree with dafid and you don't need abs().


I realise that now I was in the middle of a game when I posted :P.


Has anyone tested the Library from AC with the TLC5940 in the TSSOP packages? I have a big problem with more than one TLC. Maybe you can watch my thread here:


Mar 31, 2010, 04:55 am Last Edit: Mar 31, 2010, 03:42 pm by mistergreen Reason: 1
I'm using the TLC5941 and it's working great except for the fading function for the arduino to control 5 RBG LEDs (15 channels).

so I have  a function with this
Code: [Select]
 tlc_addFade(channel, Tlc.get(channel), green, millis(), millis()+(duration*60) );
 tlc_addFade(channel+1, Tlc.get(channel+1), red, millis(), millis()+(duration*60) );
 tlc_addFade(channel+2, Tlc.get(channel+2), blue, millis(), millis()+(duration*60) );

I would send in 'duration' to being like 300, making the transition to take place over hours. But the transitions occurs within seconds. Do you know what the issue could be?



Sorry, but I have not yet used fading. All I know is that it gives an example in the TLC library to do so.

Terrence Barr

*** Documentation Bug Alert ***


Thanks for the library - works great for me!

There is a small documentation bug on the page for VPRG_ENABLED:

It says

"You will also have to connect Arduino digital pin 6 to TLC pin 27"

Actually, the library uses Arduino pin 8, not 6. I stumbled over this
and dug through the pin definitions to find the problem.

-- Terrence


I think I figured out the length of the fading issue... There isn't enough memory to handle all of the fading.

in tlc_fades.h


I changed it to


and the steps of the fades went up and occurs a few seconds longer but alas I can't pump up the buffer_length any higher without crashing the board. Oh well, it was a nice idea :)


could it be used for other uses like driving a transistor that is conected to a motor?

or an lcd display??


I used the library to control an hbridge to run dc motors. The code I used is here. http://github.com/compuwizard123/HTHSRobotics0809/blob/master/hths_robotics/trunk/bottom/bottom.pde It contains other stuff for serial communication but primarily controls motors. Documentation for the electronics part of the project is here. http://sites.google.com/site/hthsrobotics/components/electronics It was used to compete in the MATE ROV competition last year.

Go Up