Go Down

Topic: Driving A 10x10x10 RGB Cube (Read 4224 times) previous topic - next topic

mnpumar

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):

Code: [Select]
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?

fungus

#1
Nov 14, 2012, 07:59 pm Last Edit: Nov 14, 2012, 08:24 pm by fungus Reason: 1
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:

Code: [Select]

while (tlc.update()) {
}

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

mnpumar

#2
Nov 15, 2012, 01:13 am Last Edit: Nov 15, 2012, 01:28 am by mnpumar Reason: 1

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:

Code: [Select]

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)?

fungus


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...


 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).


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...

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Grumpy_Mike

Quote
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?

fungus

#5
Nov 15, 2012, 03:37 pm Last Edit: Nov 15, 2012, 04:23 pm by fungus Reason: 1

You would have a 100 to 1 duty cycle.


(You mean 10 to 1...?)


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.


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. :)

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Grumpy_Mike

Quote

(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.

Quote
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.

mnpumar

#7
Nov 15, 2012, 11:39 pm Last Edit: Nov 15, 2012, 11:47 pm by mnpumar Reason: 1


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?


Quote

(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.


Quote
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.

fungus

#8
Nov 16, 2012, 10:13 am Last Edit: Nov 16, 2012, 10:18 am by fungus Reason: 1

Quote
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.


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.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus


 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.


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.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

retrolefty

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

fungus


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...

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

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

fungus


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).


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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Grumpy_Mike

Quote
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.

Go Up