Go Down

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


nphillips

#1 -- That interrupt/sli() code worked perfectly. Thanks, AC!

#2 -- If anyone else was interested, this library works PERFECTLY with the Mega168's internal clock, and running on 3.3V.

...at least it does in my scenario :D

acleone

The library now supports servos - check out the Servo example (thank you Steve Pomeroy).

http://code.google.com/p/tlc5940arduino/

and updated documentation is at
http://students.washington.edu/acleone/codes/tlc5940arduino/html_r8/

joe912

#168
Feb 27, 2009, 04:38 am Last Edit: Feb 27, 2009, 05:00 am by joe912 Reason: 1
so im trying to control 112 rgb leds with this library.

what i do is strobe which pin of a common cathode led gets 5 volts with transistors and then adjust the pwm on the tlc accordingly so i end up with

turn off all transistors
Send data to tlc for red
turnn on red transistor
turn off all transistors
Send data to tlc for green
turnn on green transistor
turn off all transistors
Send data to tlc for blue
turnn on blue transistor
then repeat

the problem im running into is the update time to the tlc since i need to change from r to g to b about once every 2 ms that means i get some flickering due to the update time of the tlc.  
my question is is this because of the update time and so how long does it take to update 7 tlc's?
if that is the limiting factor is there any way to speed up the upload?

or could i possibly modify the library to not latch the data in the tlc input buffer untill i told it to?

acleone

#169
Feb 27, 2009, 05:31 am Last Edit: Feb 27, 2009, 05:32 am by acleone Reason: 1
joe: you should wait for the PWM cycle to end before you switch transistors, eg

Code: [Select]

#define RED  0
#define GREEN 1
#define BLUE 2
uint8_t color;

void loop()
{
 color++;
 if (color == 3) {
   color = 0;
 }

 // set everything
 if (color == RED) {
   Tlc.set(0, 1000);
 } else if (color == GREEN) {
   Tlc.set(1, 1000);
 } else {
   Tlc.set(2, 1000);
 }
 Tlc.update();
 while (tlc_needXLAT)
   ;
 turn_off_transistors();
 turn_on_transistor(color);
}


I haven't measured [font=Courier New]Tlc.update()[/font] in SPI mode but way back in August I measured bit-banging to be about ~260us for 1 tlc.

Go Up