Writing software for the TLC5940 LED drivers.

March 2nd, 2012

Last week I had a week off, so I decided to put some time in the LED-cube project again.

Led driver test.

TLC5940 LED driver test.

I’ve been working on the LED matrix on and off (in between  working, gaming and my other project: piko3d) but being free from work for the week seemed like a good opportunity to get some work done on the Cube.

So this week, I thought I’d work on the software part of it all.

In his blog posts, Vespine talks about a free digital book called “Demystifying the TLC5940” by Matthew T. Pandina.

If you are planning on using the Texas instruments TLC5940 LED drivers for your project, than make sure you check out this book. Especially if you are working with AVR microcontrollers like the Arduino sets. What was most interesting to me was a reference to the TLC5940 programmer flowchart by Texas Instruments. The first code-example in the book describes a reference implementation of this flowchart, which is a great starting point for your own project.

Any reference implementation can be VERY useful. As you continue to work on your program, and your own implementation, the reference program can be a great way to see if you messed up your program, or if your TLC somehow got fried whenever it stops working.

So I wrote my own version of the reference implementation for the Pic32 and it works! It was very nice to finally be able to see how this driver business works, and gives me a lot of new ideas about architecture and the next parts of the my Cube’s design. Still brainstorming about a lot of things, but we’re getting there!

If you’re developing on Pic32 btw, make sure you use MPLAB X. I only updated today, and was very pleasantly surprised. A BIG step forward from MPLAB 8.x

Aside from the software, I also managed to build another layer for the LED matrix, which brings me at 5 of 8 layers total now.

Well that’s it for now!
If you have any questions, don’t hesitate to mail me, or leave a comment below!

Thanks for reading!






Comment by Deedee — May 31, 2012 @ 8:08 pm

I am interested in tour project.

Have any videos or other descriptions?


Comment by Wracky — July 11, 2012 @ 10:28 am

Sorry for the late response.
As soon as I have more material, I will post it up here.
I do have to mention that this is like, my third hobby? 😀 so progress is probably slow.
Still working on it though 😉



Comment by Boskyz — July 12, 2012 @ 5:20 pm

It would be awesome if you could leave the source code, I’m trying to control the tlc with a PIC too and I still quite don’t understand how the serial with those driver works.

Comment by Wracky — August 3, 2012 @ 10:59 am

I don’t have my schematics for the controller board finished yet.
But you can make your own.

You should check out the link I mentioned in my Post.
It’s a free ebook that describes how to drive your TLC using a micro controller. It uses Arduino by example, but the theory can be applied to any micro controller really.

Good luck!

Comment by Gelmer Orsel — July 30, 2012 @ 6:54 pm

Hello i have a cube now rgb 8x8x8 but now i must build the controller i can’t find schematic on this side? only hints…
Pleace how are the TLC5940 conect?

greetings Gelmer

Comment by Andrew (Andy) Eliason — September 4, 2012 @ 3:32 pm

Your snippets have convinced me that I might like to start an 8^3 as well, using the eightCubed kit as the foundation. Please help me understand, are you using any of their components or is yours strictly your own design? Do you plan a new update soon? What is the best way to be notified when you publish? Do you maintain a mailing list? Thanks in advance. Andy 9/4/12

Comment by Wracky — February 23, 2013 @ 5:12 pm

Hi Andrew,

Sorry for my late reply! I’ve some how missed the notification.
I’ve added an RSS icon to the site, which you can use to keep track of new posts I’ll be making.

Please note however, that I’m doing this project as a hobby, and along side other projects I’m currently doing.
I’m planning on doing some more work on the Cube in the upcoming week, but progress will be slow, as I only work on this from time to time.

To answer your questions:
The cube I’m building is my own design. I gather all the parts myself. I got a lot of inspiration and help from reading Vespine’s blog. Perhaps you can look there for more help.

Unfortunately, I’ve noticed that the lumisense site, from the people who build the EightCubed kit, has gone offline. So getting their custom control print and the other stuff might be tricky (if you didn’t get your hands on the kit yet) However you can order the Pic32 microcontroller starter kit directly from microchip, and can order cheap LED’s off of EBay, and other stuff from mouser.com. Vespine also discusses several sites which can make prints for you if you have designed your own. This way, you can gather the parts yourself. (Basically what I did).

Good luck with your own project,
And again, sorry for my late response.



Comment by aesculap — November 17, 2013 @ 7:27 am

Good day!
Currently working on a cube rgb12h12h12.
I use tlc5940 and microcontroller pic32
The project involves 27 tlc5940, which I have divided into 3 sequences (9 chips on each). The sequence of 27 chips, none that I know of libraries is not pulled. Therefore, I plan to manage the three sequences of the nine chips each.
I am not a professional programmer, I try the complexity.
Should I use 3 SPI? If you do something like that, share code, please.

Comment by Wracky — November 20, 2013 @ 3:00 pm

Hi Aesculap

I’m sorry I didn’t work on my SPI code yet.
I have too many hobbies and work on this from time to time. Even though I only work on this a bit it’s still on my mind and I still worked on the lattice last week 😀

Driving chains of 9 should be doable, and I guess driving it with SPI is the best option. The Pic32 SPI’s are 25Mhz, and the TLCs can manage 30Mhz so my guess is that should work out, if your circuitry is good enough.

As far as code is concerned, you can get a lot of information on the TLC5940 and how to program it from the book I mentioned: Demystifying the TLC5940
Start with a reference implementation so you can test it, and then try the SPI. This way you can easily see if the chip or the code is malfunctioning 🙂

Good luck!


RSS feed for comments on this post. TrackBack URL

Leave a comment


Powered by WordPress