4x4x4 LED cube driven by TLC5940

Hi all,

So, I am gonna build a 4x4x4 LED cube, like many others have done before me.
Most I have seen are using multiple 595 chips or alike, I plan on using the TLC5940.
Why? Well, if what I have seen from it is correct, I would only need 1 chip and 1 resistor, plus 4 transistors.

How I want to hook it up, is below. I hope someone can confirm that I am right, or correct me where I went wrong, so I can get the good parts.

I did some searching already and I think I am on the right track, but want to be sure before I start soldering and then find out this will fry everything.

By making a 4x4x4 cube, you get 16+4 channels.
1: Because of using the 5940 chip I would need to make the 16 channels the cathodes and the 4 channels the anodes.
2: The anodes will go to Arduino digital pins via transistors (2N2222 should be good, right?)
3: To light an LED I would need to enable the 5940's channel that is hooked up to the column the LED is in, and set the Arduino pin the anode layer is hooked up too HIGH.

Programming it will be another challenge, but if I have the electronics basics right I can start building the cube and the circuit and then worry about programming the beast.

Thanks in advance :slight_smile:

The anodes will go to Arduino digital pins via transistors (2N2222 should be good, right?)

No you will need to connect it to a PNP transistor not an NPN. ( or a P-channel FET)

For an example of multiplexing a TLC5940 see:-
http://www.thebox.myzen.co.uk/Hardware/Mini_Monome.html

Thanks for the re:

Yes, I checked your site, love the project. If I had a use for it, I'd build one of those as well :slight_smile:

I got this configuration of a project I found by someone else, guess I misread it then
Guess I'll order some PNP's then.
Any suggestions for one I could use? Didn't do much with transistors yet...
Would the BC327 work? Or do I need higher ratings.

Thanks!

Yes the BC327 can give you up to 500mA so should be fine.

Great, thanks for the support!

Right, so I have the cube nearly done now, tonight I'm going to hook it all up via breadboard to get the first code working.
(I might need to change one LED, since it is MUCH brighter than the other ones... luckily it is in the top level, so it is pretty easy to reach but still.. :frowning: )

A few questions come up that I want to have solved before I start working with it, because I don't want to burn up my Arduino.

  • Just for checking, do I need to put a resistor between my transistor and Arduino pin? I think I do, but I just want to make sure. If so, what value do I need? (or better, could you explain how I calculate what value I need :wink: )

  • Since the transistors give me 500mA to work with, it should be possible to light an entire horizontal level (4x4 matrix) completely without multiplexing(since 44=16, 1620mA = 320mA). Right?

  • Can I light up the whole cube without multiplexing? (setting all 5940 pins to max and setting the cathode pins HIGH) Or will this burn out the TLC chip? (If my calculations are correct, it should be possible since each LED get's 20mA, *4 is 80mA which should be safe for the 5940 to sink).

  • Are there any other things that might be easy to miss, but can damage the Arduino or TLC chip? (Burning out a TLC wouldn't be such a problem, burning out the Arduino would be VERY painfull since I can't replace it immediately.)

I rather double check some things before I try it out, since I still consider myself a beginner (I had a 10 year break from electronics, which I really REALLY noticed while soldering the LED's together... it is not like riding a bike, you do forget how it works.)

I'll show some results when I have it up and running.

Thanks in advance for the help :slight_smile:

do I need to put a resistor between my transistor and Arduino pin

If you are talking about the base pin of the transistor then yes. The value of current into the base times the transistor's gain equals the collector current. Look at the data sheet and pick the minimum gain. Then give it about 10% more than this current just to make sure and then calculate your resistor.

If my calculations are correct, it should be possible since each LED get's 20mA, *4 is 80mA

No if all the anodes are on and the TLC5940 is set to sink 20mA then the LEDs will have 20mA to share between them. You then have LEDs in parallel and as like as not one will take more current than the rest and so be brighter with the others dimmer. This is because the turn on voltages will be slightly different.

OK thanks. Then I'm gonna see if I can get it to multiplex some way :slight_smile:

No you will need to connect it to a PNP transistor not an NPN.

Sorry to spoil all of this, but I used an NPN transistor for my LED cube, and it worked nicely. I simply connected the base of the transistors to the controlling pins through a 10K (one per pin), and connected all the emitters together. All the emitters went straight to 0V, and the collectors went to the LED layer that I was wanting to connect to 0V.
If you are interested, I used a BC108 transistor.

Onions.

Yes but you weren't using a TLC5940 were you?

If the cathodes go to the Arduino, you need PNP, like Mike said.
The TLC's sink current, unlike the most used shift registers that provide current.

Grumpy_Mike:
Yes but you weren't using a TLC5940 were you?

Ahh... No, I wasn't, so that'll be why. Oops!

Hooked it all up tonight, finally (took a while for some parts to come in), print is done, but I've for a short somewhere.
When I measure the voltage over two of the collums I get 1.65, which shouldn't be.
So I guess I'll desolder it all tomorrow and start over again...

-edit:

Little more info, was a bit tired last night, so I kept it short.

I hooked everything up last night and tried to get it working.
I wrote a simple sketch, to see if I could light up a random LED but it didn't work.
Instead of 1 LED, a couple lit up but extremely dim.
So I checked my circuit and noticed that I soldered the resistors the wrong way.
The pull up resistor(10K) was hooked up to ground and the ref. resistor (2.2K) was on V+.
Fixed that, and nothing happened anymore.
Started measuring some more and found that between ground and V+ I have nearly infinite resistance. When I jacked my multimeter up to 2M ohm, I got a reading of 1,6M Ohm. A bit much?
On the voltage I got pretty OK readings, a bit on the low side. 1,65V.
But when I measured two cathodes, I got 1,65V as well, which doesn't sound right to me.
Tried to measure the current but I got no reading at all (this was the case before I redid the resistors as well).

So, I guess tonight I'll remove all components from my board and redo everything (probably on a new board, luckily they are cheap!), since I expect I made a shortcircuit somehwere.
I just can't figure out where, since readings between all the components check out fine.
Debugging can suck sometimes.

Note to self: CHECK a schematic AT LEAST twice before you go and solder everything together....
I don't need to explain anything else =(

It's ALIVE!

But one question remains, and I wonder if this can be solved.
Following the image (http://students.washington.edu/acleone/codes/tlc5940arduino/img/breadboard-arduino-tlc5940_close.png) in the playground for the TLC5940, I see a 2K Ohm is being used.
I used a 2.2K resistor first, because I had a couple laying around, but that was way too dim.
I then went with 2x 1K, I didn't have 2K, but this was too dim as well.

So I started playing around, and now I have 1x 1K Ohm and 1x 560 Ohm, which does improve the brightness a bit but still it's quite dim.
When I light 1 LED on a horizontal layer it's pretty OK, but when 2 or more are on there is hardly any light left.
My girlfriend was sitting at about 4 meters and she could hardly see any LED light up.

I am thinking of trying with a 1K resistor, but I don't really understand how the reference resistor works with the TLC.
I would think, it's a reference resistor, so it 'copies' the resistance that the resistor gives.
This doesn't seem to be the case, following the image that I linked earlier, which is on the playground.
I don't want to risk using such a low resistor (for my LED's on 5v voltage that would be a 330 Ohm resistor), replacing an LED in a cube is HORROR! :wink:

So, my question is: How does the reference resistor work?

Edit: I dug a littlebit deeper into the datasheet, and found on page 14, the following calculation:

I-max = V(IREF) x31.5
R(IREF)

Then it says: V(IREF) = 1,24v and R(IREF) is user-selected external resistor.

A little below it says: "The maximum output current current per channel is 31,5 times the current flowing out of the IREF pin.

Now, the voltage I supply to IREF is around 5v (coming from the Arduino), say I use a 1K Ohm resistor this gives:
(5 / 1000) * 31,5 = 0,1575.
That means it provides about 16mA, right?

So, if I want to supply 20mA to my LED's I would need (crunch numbers) about 800 Ohm's of resistance, since:
(5 / 800) *31,5 = 0,196875, right?

If I understand this correctly (and I think that I am), right now my LED's get 10mA, not surprising I'm getting such dim LED's, they're getting half the current that they 'need'.
Serves me right for only readin the playground and not searching for a datasheet myself :slight_smile:

Now, the voltage I supply to IREF is around 5v

No you don't supply any voltage to the Iref pin, the data sheet says:-

The maximum output current per channel is programmed by a single resistor, R(IREF), which is placed between IREF pin and GND pin.

say I use a 1K Ohm resistor this gives:
(5 / 1000) * 31,5 = 0,1575.
That means it provides about 16mA, right?

No:-
(5 / 1000) * 31,5 = 157mA

But this is wrong anyway the calculation is:-
(1.24 / 1000 ) * 31.5 = 39mA

You should not need any resistors in the LEDs (have you posted the schematic?)
If the LEDs are dim it is because you are multiplexing them. What is your multiplex ratio. Remember this acts like further PWM dimming so if they are on a 1:2 multiplex ( on one time in two ) then they are only going to be half as bright. I found a multiplex of 1:4 was about what I could stand.

Grumpy_Mike:

Now, the voltage I supply to IREF is around 5v

No you don't supply any voltage to the Iref pin, the data sheet says:-

The maximum output current per channel is programmed by a single resistor, R(IREF), which is placed between IREF pin and GND pin.

say I use a 1K Ohm resistor this gives:
(5 / 1000) * 31,5 = 0,1575.
That means it provides about 16mA, right?

No:-
(1.24 / 1000 ) * 31.5 = 39mA

You should not need any resistors in the LEDs (have you posted the schematic?)
If the LEDs are dim it is because you are multiplexing them. What is your multiplex ratio. Remember this acts like further PWM dimming so if they are on a 1:2 multiplex ( on one time in two ) then they are only going to be half as bright. I found a multiplex of 1:4 was about what I could stand.

I didn't put any more resistors in there except the one on Iref pin.
I trust the 1.24v is the correct value, howcome then that my LED's are dim, even if I only have 1 on?
I currently have 1560 Ohm resistance on Iref, so that would give me 25mA.
The specs for these LED's are 25mA at 2,25v, so I should get a pretty bright LED, which I do get when I hook them up to a breadboard with the Arduino flashing them.

When I start multiplexing them (at least, it's what I call multiplexing, I just set them on one by one as long as doesn't show a flicker, have to find out a better way if there is one...), even if it's just two of them, they get extremely dim.

I didn't post a schematic since I don't have any software for creating one.
I can draw one on paper, but didn't do it.
I did make a simple drawing on the computer to have a reference how to hook it all up, but it's pretty simple and might not be very clear for others to read.

I am a bit confused about what you are doing, multiplexing is the act of having an LED on for only part of the time, in effect flashing it so that more than one LED (or sets of LEDs) can use the one control equipment.

even if it's just two of them, they get extremely dim.

That might suggest you have power supply difficulties, this could be either the supply not being able to deliver the current or insufficient power supply decoupling.
It could also be that your software is only turning one LED on at a time and when you have two on you in fact have 1:2 multiplexing going on.
It could also be that your software is not right and is only feeding low values of PWM to each driver. There are 12 bits that control the brightness of each LED driver channel, if you are feeding it the wrong values then it will be dim.

I can draw one on paper,

Yes that would be good.

I'll draw up a schematic sometime today then, if you could check it for me but I doubt that's the issue...

The power supply is coming from the Arduino and it's giving me a bit under 5v (4,8 ~ 4,9 according to my multimeter).

To light 1 LED I use:

Tlc.set(chan, 4095);
Tlc.update();

where chan is the channel I am using.

Like I said, I haven't found out how to multiplex on the TLC5940 (couldn't find any good info on the mux library so I did not even try it yet).

What I am doing is, I light up an LED for a short amount of time so it doesn't flicker and then switch to the next one. It probably isn't the way it should be and could be the reason the LED's get even more dim than they are supposed to be, but they are pretty dim to begin with...

When I write it out in full it would be something like this:

Tlc.set(0, 4095);
Tlc.update();
delay(7);
Tlc.set(0, 0);
Tlc.set(1, 4095);
Tlc.update();
delay(7);
and so on...

There probably is a better way, but this is about the same thing I got to work with a 595 shift register when playing with it, so I thought it could be used about the same here.

is my makeshift schematic, I hope it's big enough to make anything from it.

Like I said, I think this is OK, since things are working, just too dim.