Show Posts
Pages: 1 2 [3] 4 5 6
31  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 26, 2009, 04:01:43 pm
OK, I added a removeFade(channel) function and updated the Fades example.

Tlc5940__2009_01_26.zip
32  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 26, 2009, 12:42:28 pm
Yes, the new version should do everything in the background (hopefully!).  With this version, if you Tlc.set(...) a channel while a fade is running on that channel, it would assume the new value for one PWM cycle (1.024ms) and then get overridden when the fade is updated again.  Ack, I forgot tlc_deleteFade(channel)!
33  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 26, 2009, 05:27:23 am
Ok, I haven't had a chance to test it on hardware, but here's some software that compiles:
Tlc5940__2009_01_26.zip

Check out the Fades example.
34  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 25, 2009, 11:28:45 pm
Shadow:
You should be able to use a darlington array (or a common anode led): put a pull-up resistor between +5V and the output pin on the tlc, then connect the output pin to whatever.  The timing will be backwards though:  always on will be 0 and always off will be 4095, eg Tlc.set(channel, 0) = always on, Tlc.set(channel, 4095) = always off.

nphillips & Mike:
Do you think you need fades longer than 67 seconds?  I'm making tlc_fades.h with:
output channel, start value, end value, duration, and start time
where duration is increments of 1.024ms and has a max of 65535 (~67 seconds) and start time is in millis()

and tlc_long_fades.h:
output channel, start value, end value, duration, and start time,
where both duration and start time is in millis()

*Edit*: I think I'll name the one with both duration and start time in millis() tlc_fades.h (less confusing), and have a tlc_short_fades.h for the people who need to save ram.

thoughts?
35  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 21, 2009, 01:44:47 am
The problem with "extending" functions like digitalWrite and AnalogWrite is that their functionality is very chip-dependent.

Let's look at a good example of where "extending" (I think you mean virtual) functions is beneficial: print(int n).  For example, Serial.print(int n) and lcd.print(int n) use the same underlying code to convert the integer to the human readable '12345', but to actually print '1' then '2' ..., Serial and lcd have a different "write(char c)" function to display one character at a time.  Now it becomes very easy to extend print to new devices: just make the write(char c) function.

analogWrite and digitalWrite are already too low level and chip dependent: there's no code that's commonly shared.
36  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 20, 2009, 05:17:48 pm
Sure.
37  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 20, 2009, 04:59:42 pm
I haven't implemented fading after I redid the library a while back.

Here's all the functions in the library currently:
[olist]
38  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: January 09, 2009, 12:46:05 am
It would be possible, but it is definitely not more efficient.  This is because data is shifted out via the hardware SPI module, which runs at 8MHz (or 1 bit every two clock cycles)!  At first thought, it seems like it would be faster to set up three different data lines and clock them at the same time, but just to set up each line it takes an AND and CP (2 clock cycles) for each bit, then a clock pulse will be 2 cycles, etc.  The dedicated hardware will be much faster than the software implementation.

The library's default display cycle is 976.5625Hz.  For the entire display this would be a frame rate of 61.035Hz.

Your limiting factor will definitely be the serial data transfer rate.  One refresh takes 12*3*16*16 = 9216 bits.  If you use the fastest serial speed, 115200, and account for the start/stop bit, you could deliver 92160 bits/sec, or 10 frames per second.  There will be some processing overhead, even if the serial data went straight out to the tlc's, so realistically it would be ~8Hz.

See this thread for a similar project with an 8x8 grid.

About instantiating three separate instances; it won't work because the library just has one data buffer.
39  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: December 30, 2008, 12:31:09 pm
Everything above "Older information" on the playground page is up to date.  Make sure you have the latest library version.  The latest version will always be available here.

Be sure to check your hardware setup: it's easy to forget to connect DCPRG (TLC pin 19) to +5V and VPRG (TLC pin 27) to GND.

As for running off USB power, it depends on how many LEDs you have connected; I wouldn't connect more than ~20 LEDs.
40  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: December 26, 2008, 06:47:59 pm
This library uses timer 1 (XLAT on pin 9, BLANK on pin 10, which could easily be switched to 10/9) and timer2 (GSCLK on pin 3, which could be switched to pin 11).

The old library uses timer2 for GSCLK, timer1 for BLANK, and timer0 for XLAT.  It would be possible to switch XLAT to any pin but it violates the the timing in the TLC datasheet (everything should still work ok though).  If you want to try it, open Tlc5940.cpp and add
Code:
     XLAT_PORT |= _BV(XLAT_PIN);
      XLAT_PORT &= ~_BV(XLAT_PIN);
at the beginning of the ISR on line 71.

As for switching GSCLK to pin 11, (which is OC2A), change:
  • TLC_GSCLK_PERIOD (line 181) in tlc_config.h to 1
  • Add _BV(COM2A0) to TCCR2A = ... on line 150 of Tlc5940.cpp and delete _BV(COM2B1)
I have no idea if this will work - does anyone know if can you set a compare match toggle on OC2A if the timer2 TOP is defined to be OCRA?
41  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: December 26, 2008, 03:36:55 pm
Quote
I try to get more than 1 led burning at a time. If I understand it right the "usingprogmem.pde" example should do this, right?

The UsingProgmem example sets all the LEDs at once.  If you want to turn on more than 1 LED, just use Tlc.set(channel, value);
Code:
/* Turn on channels 0-5 */
Tlc.set(0, 4095);
Tlc.set(1, 4095);
Tlc.set(2, 4095);
// ...
Tlc.update();

/* or use a loop: */
for(int i = 0; i <= 5; i++) {
  Tlc.set(i, 4095);
}
Tlc.update();

Quote
Is it possible to use this library with the same pinout as for the old code in the playground page?

Unfortunately not, because GSCLK, BLANK, and XLAT are driven by timers (the PWM outputs), so they can't be changed.

On the other hand, SIN and SCLK can be changed to anything in bit-bang mode.
42  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: December 08, 2008, 02:50:22 pm
Here's an Atmega8 version:  Tlc5940__Atmega8_latest.zip

(I should have probably used preprocessor directives, but then I would have had to change all my horrible pin-out diagrams).  Tell me if it works!  The BasicUse example has hardware setup.
43  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: November 27, 2008, 04:58:01 pm
Happy Thanksgiving!  Have an update: Tlc5940_latest.zip

2008-11-26
  • Tlc.init() sets all channels to zero and updates.
  • Added TLC_PWM_PERIOD and TLC_GSCLK_PERIOD to tlc_config.h
  • Added TLC_CHANNEL_TYPE to tlc_config.h - Now the library supports 4096 TLCs!  (if TLC_CHANNEL_TYPE is uint16_t)
  • Changed the examples to use TLC_CHANNEL_TYPE
  • set DATA_TRANSFER_MODE default to TLC_SPI
  • [/b]
Since the DATA_TRANSFER_MODE is now TLC_SPI, be sure to change your hardware setup (or just set it back to TLC_BITBANG in tlc_config.h, then delete Tlc5940.o):
  • Arduino Digital Pin 11 (used to be pin smiley-cool -> TLC pin 26
  • Arduino Digital Pin 13 (used to be pin 7) -> TLC pin 25
44  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: November 21, 2008, 12:21:37 pm
Yes, the limit is now 16.  If you still need more, I can make a custom version of the library.
45  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: November 14, 2008, 06:28:34 pm
Very cool!  Are you just using serial to send data to the Arduino now?

As for dmx, you can use the Atmega168's USART (serial) module in receive mode.  It supports the start/8 data bits/2 stop bits protocol of dmx, you just have to set the baud rate.  (see the atmel datasheet).  I don't know of an ic off the top of my head that converts from 2.5/-2.5V into a digital 0/5V signal, but I'm sure you can find one.
Pages: 1 2 [3] 4 5 6