# Driving A 10x10x10 RGB Cube

I need some advice on how to drive a 10x10x10 RGB LED cube. It basically comes down to 300 pins multiplexed 10 times for the 10 layers. My first thought was to use TLC5940's, but I tried a simple test of just turning all the pins on one on and off as fast as I could. However, there was noticeable flickering in the LED's, so I'm having my doubts. If I can't even achieve persistence of vision on 16 pins, how could I possibly do it with 300 multiplexed 10 times? Here's the code I used for reference (Note I was using a Teensy++2.0):

``````void loop()
{
int i = 0;
while(1){
//Tlc.clear();
if(i == 1){
Tlc.set(1, 4095);
Tlc.set(2, 4095);
Tlc.set(3, 4095);
Tlc.set(4, 4095);
Tlc.set(5, 4095);
Tlc.set(6, 4095);
Tlc.set(7, 4095);
Tlc.set(8, 4095);
Tlc.set(9, 4095);
Tlc.set(10, 4095);
Tlc.set(11, 4095);
Tlc.set(12, 4095);
Tlc.set(13, 4095);
Tlc.set(14, 4095);
Tlc.set(15, 4095);
i = 0;
}else{
Tlc.set(1, 0);
Tlc.set(2, 0);
Tlc.set(3, 0);
Tlc.set(4, 0);
Tlc.set(5, 0);
Tlc.set(6, 0);
Tlc.set(7, 0);
Tlc.set(8, 0);
Tlc.set(9, 0);
Tlc.set(10, 0);
Tlc.set(11, 0);
Tlc.set(12, 0);
Tlc.set(13, 0);
Tlc.set(14, 0);
Tlc.set(15, 0);
i=1;
}
Tlc.update();
//delay(300);
}
}
``````

Is there a way to speed things up here, or should I scrap the TLC5940's entirely for something else? I've heard about other people using shift registers, would that be fast enough?

tlc.update() always returns immediately. It doesn't wait for the LEDs to update.

You need to look at the flag returned by tlc.update() and wait for it to return a 0m like this:

``````while (tlc.update()) {
}
``````

fungus: tlc.update() always returns immediately. It doesn't wait for the LEDs to update.

You need to look at the flag returned by tlc.update() and wait for it to return a 0m like this:

``````while (tlc.update()) {
}
``````

Thanks, I'll give this a try! I am still having serious doubts now about these chips being fast enough to drive the cube. Is there any hardware limitation here? Do I need to use an arduino due to acheive the kind of perfomance required to multiplex 300 pins across all 10 layers quickly enough for persistence of vision? If so, will these chips work with 3.3V inputs and 5V outputs?

Another idea/question: are there any chips out there that would support sending out the data to 3 sets of these chips at once (one for red, one for green, one for blue)?

mnpumar: Thanks, I'll give this a try! I am still having serious doubts now about these chips being fast enough to drive the cube.

The chips are fast enough, the standard library might not be...

mnpumar: Is there any hardware limitation here? Do I need to use an arduino due to acheive the kind of perfomance required to multiplex 300 pins across all 10 layers quickly enough for persistence of vision?

No. You can shorten the TLC5940 PWM cycle to any length you want, it doesn't have to be 12-bit (4096 clock pulses).

mnpumar: Another idea/question: are there any chips out there that would support sending out the data to 3 sets of these chips at once (one for red, one for green, one for blue)?

You could do that with the TLC5940, too, but you won't be able to use the SPI interface.

It's all down to programming...

I am still having serious doubts now about these chips being fast enough to drive the cube.

Well it is not the chip but the entire arduino. Also depending on how you do it the on / off ratio of the LEDs is not going to be very good, meaning the brightness will be compromised dramatically. You would have a 100 to 1 duty cycle. I have used a 4 to 1 duty cycle and found that quite limiting. You need to boos the current to the LEDs to compensate but the TLC5940 won't drive that much current even if yor LEDs can take it.

This was my 8 by 8 RGB LED matrix all be it in a strange layout. http://www.thebox.myzen.co.uk/Hardware/Hexome.html

Do you know how fast you need to go? Have you done the maths?

Grumpy_Mike: You would have a 100 to 1 duty cycle.

(You mean 10 to 1...?)

Grumpy_Mike: Do you know how fast you need to go? Have you done the maths?

Let's do it:

300 LEDs per layer means he'll need 19 driver chips. At 24 bytes of data per chip that makes 456 bytes per layer, 3648 bits total.

The SPI bus can send a byte in 17 clock cycles (see thread a couple of weeks ago). The Arduino runs at 16mHz so he can send that much data over 2000 times per second even with a bit of overhead for processing/sequencing.

He can cut the TLC5940's PWM cycle short at the end of each transmission, latch the PWM data and start on the next layer. With ten layers he can update the cube 200 times/sec. - a perfectly acceptable rate.

Grumpy_Mike: You need to boos the current to the LEDs to compensate but the TLC5940 won't drive that much current even if yor LEDs can take it.

It can drive 120mA per pin, that ought to be enough to overdrive a LED a little bit. :)

(You mean 10 to 1...?)

Well no, I was assuming, and said, that he was going to multiplex so that one column of one plane would be on at any one time. Now if you are going to drive it with 300 LEDs in one plane all on at the same time then yes it is only 10 to 1. However that means he will have to have 300 / 16 = 19 TLC5940 to drive it. While not impossible, there needs to be some signal buffering going on, proper construction and good layout. It is not something you are going to make on bread board.

It can drive 120mA per pin

Yes that is the current, now work out the power dissipation that will cause in the chip and you will find you can't run the chip at that current.

fungus: 300 LEDs per layer means he'll need 19 driver chips. At 24 bytes of data per chip that makes 456 bytes per layer, 3648 bits total.

The SPI bus can send a byte in 17 clock cycles (see thread a couple of weeks ago). The Arduino runs at 16mHz so he can send that much data over 2000 times per second even with a bit of overhead for processing/sequencing.

He can cut the TLC5940's PWM cycle short at the end of each transmission, latch the PWM data and start on the next layer. With ten layers he can update the cube 200 times/sec. - a perfectly acceptable rate.

These calculations look correct, based on the fact that you can send a byte in 17 clock cycles. I'm a bit skeptical though, because adding a delay of more than 10 in the code above causes the lights to flicker/blink. I'd like to see where you found that, could you post a link?

Grumpy_Mike:

(You mean 10 to 1...?)

Well no, I was assuming, and said, that he was going to multiplex so that one column of one plane would be on at any one time. Now if you are going to drive it with 300 LEDs in one plane all on at the same time then yes it is only 10 to 1. However that means he will have to have 300 / 16 = 19 TLC5940 to drive it. While not impossible, there needs to be some signal buffering going on, proper construction and good layout. It is not something you are going to make on bread board.

Maybe not a breadboard...but a perfboard, maybe? Last time I tried to make a large pcb at home using toner transfer it was a real challenge...I'm hoping not to have to resort to that again.

Grumpy_Mike:

It can drive 120mA per pin

Yes that is the current, now work out the power dissipation that will cause in the chip and you will find you can't run the chip at that current.

I only need to drive the LED's at 20mA or less, so this shouldn't be a problem.

Grumpy_Mike:

It can drive 120mA per pin

Yes that is the current, now work out the power dissipation that will cause in the chip and you will find you can't run the chip at that current.

You could if the supply voltages are very close to the LED voltages...:)

But realistically, no, you can't do 120mA per LED with a 5V supply.

OTOH if we assume an average 1.8V excess voltage per LED (ie. a 5V supply with R=2.2V, G+B=3.6V) you can do 60mA which is in the right ballpark for a project like this. Total dissipation per chip would be ~1792mW. The chip can do that easily.

Grumpy_Mike: While not impossible, there needs to be some signal buffering going on, proper construction and good layout. It is not something you are going to make on bread board.

Yep, it's an awful lot of chips+wires. No arguments there.

mnpumar: I'm a bit skeptical though, because adding a delay of more than 10 in the code above causes the lights to flicker/blink. I'd like to see where you found that, could you post a link?

To simulate the final LED brightness/flicker at 100Hz you need to turn the LED on for 10ms then off for 90ms. Putting "delay(10)" in that code doesn't do that.

nb. Any code which doesn't synchronize to the TLC5940's PWM cycle won't represent the final result.

mnpumar: I only need to drive the LED's at 20mA or less, so this shouldn't be a problem.

Normally you drive them harder to compensate for the fact that they're only on for 1/10th of the time.

LEDs have a power rating (watts) and a maximum 'pulse' current (mA), see the datasheet for your LED for details. You can go higher then 20mA so long as you don't exceed either of those ratings.

Well in designing my 5x5x5 led cube, I used a 2 millisecond timer interrupt to set-up my scanning of the cube, so five levels at 2 millisec each gives me a 10millisec update cycle time and I detected no flicking at all. As far a ma drive level for the leds Vs scan rate, I simple used shift registers that contain built in constant current (sinking) output pins which made the whole brightness thing a no worry situation. Each 16 bit register (I used 2 series connected) uses a single 'programming' resistor to set the desired constant output current value for all the output pins (I set for 20ma) and the performance is great, led brightness is the same no matter if a single led or all 125 are being lite up.

Lefty

retrolefty: I simple used shift registers that contain built in constant current (sinking) output pins which made the whole brightness thing a no worry situation.

RGB cubes are more complicated, they need PWM control for setting the colors...

fungus:

retrolefty: I simple used shift registers that contain built in constant current (sinking) output pins which made the whole brightness thing a no worry situation.

RGB cubes are more complicated, they need PWM control for setting the colors...

Depends on how many colors you want to be able to display. Simple on/off to each RGB led terminals should be able to have 7 colors plus all off. It's kind difficult to obtain near infinite colors outputs as well as near constant brightness in the same scanning algorithm I would think and add a lot of complexity to the sketch for the desired pattern/display coding. I think simple on/off controls to the 3000 led elements is the way to go, certainly for ones first attempt.

Lefty

retrolefty: Depends on how many colors you want to be able to display. Simple on/off to each RGB led terminals should be able to have 7 colors plus all off. It's kind difficult to obtain near infinite colors outputs as well as near constant brightness in the same scanning algorithm I would think and add a lot of complexity to the sketch for the desired pattern/display coding.

I'm not sure there's a massive difference in complexity between 7 colors and PWM. The wiring is almost identical, the software will be very similar (but with a lot more data).

retrolefty: I think simple on/off controls to the 3000 led elements is the way to go, certainly for ones first attempt.

Yep. Reading between the lines it seems like he should probably make something smaller to get some practice with electronics, TLC5940s, Arduino programming, etc.

it seems like he should probably make something smaller to get some practice with electronics, TLC5940s, Arduino programming, etc.

Let's face it. The OP is never going to make a 10 X 10 X 10 cube, it is one of those over ambitious things a newcomer wants to do. It is a lot more complex than just getting the right circuit and wiring it up. I wouldn't attempt this myself and I have got a bit of experience. I would say that there is over six months of work here.

Just thought i'd throw this in, im using a HEF4067BP to drive 8 x 7 seg displays, it's a 1 of 16 channel switch

http://www.nxp.com/documents/data_sheet/HEF4067B.pdf

Grumpy_Mike: I would say that there is over six months of work here.

I don't know if it's that much ... maybe a month of snipping/soldering and another of programming.

What major problems do you see in the electronics? I don't really see any apart from switching 15A of power on/off quickly (Separate 5V PSU with lots of capacitors on the output? Thick wires for all GND connections?)

fungus:

Grumpy_Mike: I would say that there is over six months of work here.

I don't know if it's that much ... maybe a month of snipping/soldering and another of programming.

What major problems do you see in the electronics? I don't really see any apart from switching 15A of power on/off quickly (Separate 5V PSU with lots of capacitors on the output? Thick wires for all GND connections?)

Having built a 5x5x5 cube, while finding designing, building, debugging the hardware challenging it was at least something I enjoyed and progress was mostly trouble free. The software was another kettle of fish however. The basic scanning of the cube was pretty simple but I found that the 'creative part' of coming up with interesting pattern shows was so very very tedious and very time consuming and I soon lost interest after defining about six basic patterns including a simple random pattern using a RNG. What I really longed for was a PC based GUI pattern editor that I could use to 'visually' build patterns, scan by scan, and then be able to upload the pattern into the arduino driven cube. But of course my PC software skills would never allow me to write such a application. So now when I watch cube being demonstrated on U-tube or wherever, I've really come to appreciate the artistic effort that some have mastered. So in effect the software is the biggest overall factor is the quality of the finished project.

Lefty

What major problems do you see in the electronics?

As you said:-

from switching 15A of power on/off quickly

(Separate 5V PSU with lots of capacitors on the output? Thick wires for all GND connections?)

If it were only that simple.

Grumpy_Mike:

(Separate 5V PSU with lots of capacitors on the output? Thick wires for all GND connections?)

If it were only that simple.

Four power wires to each layer (at the corners…)? Decoupling on each one?