Teensy 3.0 and TLC5940

Status
Not open for further replies.

local_dani_21

Well-known member
Hi

Has anyone tried to drive TLC5940's with a teensy 3.0? I'm quite unfamiliar with teensy 3.0 processor but since I have one and a project to get done I thought well maybe someone knows how to.

Thanks for sharing,
Dani
 
This is one of the libraries I initially skipped for porting to Teensy3. It has a LOT of avr-specific code.

Now that IntervalTimer and analogWriteFrequency() are stable APIs in the core library, maybe this one is worth another look? Do people still use this TLC5940, now that RGB LED strips are widely available?
 
hello all,

Just wanted to chime in on this topic. First let me say I have been a HUGE teensy fan every since our hackerspace (lvl1) was sent some of the early teensy 2.0 boards to experiment with. My absolute favorite, go-to board on most all projects.

I create alot of very large RGB pixel displays and yes I would agree the TLC5940 is a bit obsolete in this realm now, however... I think there are probably still plenty of people using the TLC5940 for other uses. For me the TLC5940 is the cheapest and best chip I know of for gaining a large number of PWM outputs. I was actually connecting my Teensy 3.0 to an array of 200+ TLC5940 outputs this morning to AC dimmer circuits controlling 30,000+ christmas lights. I found this post once I realized that the TLC5940 library wouldn't compile on my new fancy 3.0 boards. Luckily I have plenty of spare 2.0's laying around so it's not a huge issue but personally would love to see the library ported over to the 3.0. With or with out the library on 3.X, these boards are still the best thing since Chuck Norris!
 
If your just looking to make a wall of LED's then the strips are far more useful, but if you want to create POV designs then you need something with more speed. The TLC5940 is a very fast chip if not a little IO pin heavy. I am still working on my POV projects I took a long break and have finally gotten back into looking at how I want to build my next Spinning POV project.

Between coding the Teensy and figuring out how to create the images to display I have a long road ahead of me.

Some of the problems I have run into and have to figure out are.
1. 12 bit color....(wrapping my head around bit shifting, I have had example code for a while but it just seems it go over my head)
2. Im multiplexing 4 TLC5940's to run 64 RGB led's so I have to break up a BMP into the 3 colors or create a file with the Red Green Blue columns separated and convert the 8 bit color into 12bit (this part will most likely happen external to the Teensy).
3. Image storage, unless your just displaying 1-2 images you will run out of room fast... Every RGB Led requires 3 x 12bits, a 64x64 RGB array would be 18432 bytes.
4. Since I will be rapidly moving the led's I have to refresh the RGB columns fast or the colors will not appear all as one pixel.

Finally I need to get a working test code that will allow me to test all my RGB leds and make sure it is multiplexing.... (my current task, im looking into the Arduino TLC5940 code for hints)

 
Last edited:
has anyone had luck making the Tlc5940 library work with the teensy 3. ?

Looks fairly time intensive to rewrite the whole library to work with the Teensy3/3.1. Not saying it cant be done, but I know I dont know enough to jump right in and do it. I am looking at it right now to maybe use some of the functions in some of my projects.

Edit...

Actually looks to be fairly straight forward, some of the files don't need changing. Its mostly the port calls for the ATmega's that would have to be changed. And the timers.
 
Last edited:
I ported Tlc5940 this weekend. Here's the source code:

https://github.com/PaulStoffregen/Tlc5940

I've updated the web page with pin connection info for Teensy 3.x.

http://www.pjrc.com/teensy/td_libs_Tlc5940.html

If you're still watching this old thread and still interested in using a TLC5940 chip with Teensy 3.0 or 3.1, I hope you'll give it a try. I tested here with 1 TLC5940 chip and 16 LEDs. It seems to be working well, but I didn't have time to exhaustively test the many special features of this library.

The special (slow) servo mode doesn't work on Teensy 3.1 or 3.0 or even Teensy 2.0 (it's never worked). To control a very large number of servo motors, I'd recommend the PulsePosition library, or Adafruit's servo control board.
 
Paul, thanks for porting the Tlc5940 code, it works fine, but actually I'm trying to change the PWM frequency by changing the values for TLC_PWM_PERIOD and TLC_GSCLK_PERIOD in tlc_config.h...
Nothing changes, I tried some calculated combinations as well as completely unreasonable values (e.g. "0" and "0"), but there is completely no effect at all. (I restarted the IDE after each alteration in tlc_config.h.)
The frequency always remains at ~975 Hz.
Do you have any suggestion and help? Thanks!
 
The frequency always remains at ~975 Hz.

The PWM frequency of the TLC5940 is GSCLK / 4096.

This code is used to configure the CMT timer for a 4 MHz waveform:

Code:
    SIM_SCGC4 |= SIM_SCGC4_CMT;
    CMT_MSC = 0;
    CMT_PPS = 0;
    CMT_CGH1 = TLC_TIMER_TEENSY3_NORMAL_CGH1;
    CMT_CGL1 = TLC_TIMER_TEENSY3_NORMAL_CGL1;
    CMT_CMD1 = 1;
    CMT_CMD2 = 0;
    CMT_CMD3 = 0;
    CMT_CMD4 = 0;
    CMT_OC = 0x60;
    CMT_MSC = 0x01;
    CORE_PIN5_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_DSE|PORT_PCR_SRE;

You could try editing TLC_TIMER_TEENSY3_NORMAL_CGH1 and TLC_TIMER_TEENSY3_NORMAL_CGL1 to see if you can get a higher frequency. You see in pinouts/Teensy_KinetisK20.h there are many combinations depending on F_BUS. When Teensy is at 48 or 96 MHz, the 48 MHz bus clock is used. If you uncomment the 120 MHz overclock line in boards.txt, you can get access to the 60 MHz bus clock.

Alternately, you could use a crystal oscillator (the kind with TTL level square wave output) to drive GSCLK instead of Teensy3's CMT. That requires extra hardware, but it might be simpler than fiddling with the code.
 
Hello,

i am building a 8x8x8 RGB Led cube with 12 TLC5940
i have sucessfully got 4 of them working (daisychained SOUT(n-1) to SIN(n))
however when i add more then 4 TLCs the leds start doing weird things.
Not only the ones that are at the end of the daisy chain, but also the ones at the beginnen.
The power supply should be strong enough (i was only testing one led after another till now)
the wires from one TLC to the next one (SOUT to SIN) are about 30cm long, the other signals are connected directly from the teensy with 15cm wires, maybe this makes a problem with the timing??
however when it is a timing problem, why do the ones at the beginning of the daisy chain get confused??
anyone having similar problems??
 
This may be a silly question, but you've edited NUM_TLCS, right?

https://github.com/PaulStoffregen/Tlc5940/blob/master/tlc_config.h#L55

however when it is a timing problem, why do the ones at the beginning of the daisy chain get confused??
anyone having similar problems??

These sorts of problems, especially "strange flicker" in certain conditions, are really common with large LED projects using WS2812 LED strips, where the ground wires have (varying) voltage drops due to the large currents. Changes in the ground voltage make the effective signal voltage look different.
 
Last edited:
Hi Paul,

thanks for the quick answer.

the NUM_TLCs in tlc_config.h is defined to 6 with 6 TLCs connecte at the moment.

These sorts of problems, especially "strange flicker" in certain conditions, are really common with large LED projects using WS2812 LED strips[
I think you meant TLC5940 not WS2812 or are these drivers related somehow?

I have a 100n capacitor directly at the VCC / GND of each TLC and an bigger elco on the main board where the teensy is.
maybee ill try adding some more capacitors to the whol setup. However there should not bee any high current at the moment since i am only testing the LEDs one by one

EDIT:
adding some additional capacitors did not help :(

EDIT:
i found the solution to my problem.
There was kind of a bug in the wireing.
I had the VCC of the TLC5940 connected to 5V as described in Teensy TLC5940.
Instead i am using 3V3 for TLC VCC now, and it seems that it is better compatible with the 3V3 signals of the Teensy when many TLCs are used for some reason. (or maybe the reason it works now is that a seperate voltage regulator is used that provides a more stable supply, and it has nothing to do if its 3V3 or 5V, i will test that)
 
Last edited:
Hi Paul,

i think there is a bug in the [URL="https://www.pjrc.com/teensy/td_libs_Tlc5940.html"Teensy-TLC4950 manual[/URL]
the Vcc for the TLCs is set to 5V there.
In the datasheet of the TLC the high voltage is defined to 0.8Vcc which is 4V if the TLC is driven with 5V hoever the teensy high is 3V3 only.
When only running 1 to 4 TLCs in a daisychain it works with the VCC for the TLC set to 5V for some reasons. However with more TLCs there is some flickering.

I have made an experiment to verify it is not due to voltage stability:
Experiment #1: Vcc of Teensy is 3V3 Vcc. Vcc for the TLCs is 5V generated by a seperate voltage regulator. The Leds are connected to a third 5V source. All three sources have a common ground.
Result: when more than 4 TLCs are daisychained they do some weird things (flicker, wrong Leds enabled....)
Experimet #2: Vcc for teensy is 3V3. Vcc for the TLCs is also 3V3 generated by a seperate voltage regulator. The Leds are connected to 5V again and all sources have commen ground.
With up to 8 TLCs (i have not tested more till now) everything works perfect.

Since the Vcc is generate by a seperate regular in both cases it cannot be due to voltage stability.
For me everything is fine now. The drawback of driving the TLCs with 3V3 is, that the outputcurrent for the PWMs is limited to 60mA then, so i suggest using a levelshifter from 3V3 to 5V in the case you want to drive higher current.

I guess the reason is, that with many TLCs the high voltage drops further under 3V3 since there is some current going into the inputs, until the high level drops under some critical point.
 
Last edited:
Status
Not open for further replies.
Back
Top