Building an 8x8x8 LED Cube – The Driving Circuit

LED Cube Driver Circuit - Complete Board - Front 04

In this article we are going to take a detailed look at how to build the driving circuit for the 8x8x8 LED cube. In other words we are going to design and analyze the circuit which translates the signals coming from the Arduino to appropriate currents passing through each of the LEDs, so that the desired animations can be created. We will go through the schematic, check the needed parts and we are going to see how to build the circuit exactly. If you haven’t read the introduction part yet, which talks about what we are trying to achieve in general, it’s probably a good idea to read it before we dive into the details of the driving circuit.

 

Power consumption

A very important thing to consider when designing a driving circuit for an LED cube is the maximum possible power consumption of the system, because the components and the power supply need to be chosen accordingly. The components that will drain most of the current are obviously the LEDs. Our cube is going to be one that is used with multiplexing (but we will do the multiplexing from the software, so we don’t need to worry about hardware multiplexing). This means that at any given time only one horizontal layer (plane) can be lit. In other words we need to plan for a maximum of N*N LEDs consuming power. In the 8x8x8 cube this means that we’ll have to take into account the power consumption of 64 LEDs, but if you are building a cube of a different size, you’ll need to adjust the calculations accordingly.

So how much current can an LED drain? Well, that depends on the value of the current limiting resistors that we use for each one of them. But the standard 3 mm (or 5 mm) LEDs of today are usually rated at 20 mA. We will design the circuit to be able to handle 20 mA of current per LED because there is a wide selection of LEDs out there and you might need to really give them 20 mA to shine brightly. However, I have found that most LEDs need much less current in order to shine brightly. For my own LED cube I have used standard 3 mm bright blue LEDs. For these the optimal brightness is obtained at 1.5 mA, which is obviously much less than their 20 mA rating. I’d like to emphasize here that figuring out the optimal brightness of you LEDs before you start building the cube’s driving circuit is very important. If your LEDs won’t be bright enough, the cube will look pale and that’s not something that we want. On the other hand, if the LEDs will be too bright, they will shine through the LED which is above them in the cube and it will seem that the above LED is also lit. This is even worse than a pale cube. So experiment with  your LEDs, in darkness and in daylight and determine how much current they need to shine with the exact brightness that is needed. Note that the value of the used current limiting resistors will also depend on the color of the LEDs because LEDs of different colors have different voltage drops. Here is a quick reference of the LED forward voltage values by color.

Getting back to the circuit design, we will plan for a maximum current of 20 mA per LED and a maximum of 64 LEDs being lit simultaneously. That means a total consumption of 1.28 A. That’s quite a lot and we’ll need a power supply rated at least at 1.5 A, preferably at 2 A. Should you decide to feed your LEDs with less current, a smaller power supply will suffice. In my circuit I have given them about 1.5 mA, so for 64 LEDs that’s a total of only 92 mA and yet the brightness is good enough. For 3 mm or 5 mm white or blue LEDs most likely the same current values can be used. For other colors you might need to give them a bit more current or even if the same amount of current will be enough, you’ll need resistors of different value.

Let’s also keep in mind that the LEDs are not the only components in the circuit which consume power. The other components (like MOSFETS and shift registers) also use up some current, but that is close to a negligible value. There is however something else. The multiplexed cube needs to switch between the layers very fast, in a matter of a few milliseconds or even less than one millisecond. Some of the components, like the MOSFETs which switch the layers, need time to shut off. I have found that some resistors are needed between the anode layers and the ground and the cathode columns and the positive voltage in order to help some currents go away after switching layers, otherwise they will go away through the LEDs and that will result in ghosting (when a layer is switched on, the previous layer is also dimly lit, which looks very bad). So, to get rid of this ghosting, I have added a 1K resistor between each anode layer and the ground and a 10K resistor between each cathode column and the positive voltage. In a 8x8x8 LED cube we have 8 anode layers and 64 cathode columns. Given the fact that the whole circuit functions at 5V, this means that the resistors between the anode layers and the ground will generate a total current consumption of 8*5 mA = 40 mA. The resistors between the cathode columns and the positive voltage will generate a total of 64*0.5 = 32 mA current consumption. That’s 72 mA overall. Unfortunately this is a passive power consumption, meaning that the cube will consume at least this this much, even if all the LEDs are off.

Finally, let’s not forget the power consumption of the Arduino which powers the cube. You will most likely want to power it from the same supply unit, so it too adds to the consumption. This will depend on the exact model that you use but even the most power hungry ones will not eat up more than 200 mA. Unfortunately it’s likely that we’ll need a model which uses quite some current (but not more than 200 mA) because the code that generates the animations will need a few kilobytes of memory, so a more powerful microcontroller (with enough memory) is needed for it.

 

Schematic

So, without further ado, allow me to present the schematic of the driving circuit. Please note that it was designed by Robert Patterson, also known as CrossRoads at the official Arduino forum. It’s he who we have to thank for this wonderful design. To check out more of his great circuits, visit his website at http://www.crossroadsfencing.com/BobuinoRev17/.

LED Cube Driver Circuit - Schematic

 

Serial communication between the Arduino and the shift registers

As explained earlier, in the introduction, we are going to use serial-in, parallel-out shift registers in our LED cube driving circuit, so that we can minimize the connections between the Arduino and the circuit. The data between the Arduino and the shift registers will be transferred via serial communication, through SPI. The Arduino will have the role of the master and the shift registers will be the slaves. The shift registers can be chained, meaning that the output of the first one can be fed into the second one, the output of the second one can be fed into the third one, and so on. This allows us to minimize the communication lines between the Arduino and the driving circuit because the Arduino only needs to send data to the first shift register in the chain and this first shift register will pass on the data, until it reaches the very last one. To understand how shift register work, check out this great video by Kevin Darrah:

In a circuit which drives an LED cube made of N*N*N LEDs, the number of shift registers needed is N+1 (this is true if N<=8). One is needed to switch on/off the anode planes and the rest of N shift registers are needed to switch the cathode columns. The TPIC6B595 shift registers that we use have 8 outputs, meaning that each shift register can drive up to 8 anode layers or 8 cathode columns. The first shift register in the chain is assigned to the anode layers because switching these is the most important and data from the Arduino reaches this shift register first. If you consult the datasheet of the TPIC6B595 shift register, you will see that the data is propagated from one shift register to the next very fast, in a matter of a few nanoseconds, so if the Arduino needs to send some data even to the last shift register in the chain, it can just push it through the whole chain quite fast, until it reaches the last one.

The most important thing to understand is that whenever the Arduino wants to change the state of any LED in the cube, it will actually update all the shift registers in the chain (with (N+1)*8 bits of data in total). It will first send the 8 bits of data which need to be in the last shift register and these first 8 bits will go into the first shift register first, but when it  will send the next 8 bits of data, the first shift register will make room for these next 8 bits by flushing out the first 8 bits, into the next shift register. The third transfer of 8 bits will push the data from the second shift register into the third one and from the first shift register into the second one. This way, after N+1 transfers of 8 bits, the first 8 bits will arrive into the last shift register in the chain, the second 8 bits will arrive into the one before the last and so on. The 8 bits which are sent out last will remain in the first shift register in the chain.  This means that the state of the cube changes all the time during the communication between the Arduino and the shift registers, but this happens so fast (in a few hundred milliseconds at most) that the human eye will not see any of it happening. Quite a nifty trick.

Unlike most LED cube driving circuits out there, which use the popular and ridiculously cheap 74HC595 shift register, ours has TPIC6B595 shift registers in it. This is because we plan for relatively high currents (if we really plan to give a maximum of 20 mA to the LEDs) and we need to sync the current, not source it, because of our anode layer and cathode column design. But the TPIC6B595 is also cheap enough and it switches fast enough (in a few nanoseconds).

As shown on the schematic, only 3 pins are needed for the serial communication between the Arduino and the first shift register: master out, slave in (MOSI), clock (SLCK) and slave select (SS). The MOSI pin of the Arduino is connected to the SER IN pin of the first shift register in the chain, than the SER OUT pin of the first shift register goes to the SER IN of the second one and so on. This is how the shift registers are chained (this is how data goes from one to the next). The SCK (SCLK) Arduino pin is connected to the SRCK pin of all shift registers. The SS Arduino pin is also connected to all the shift registers, to their RCK pin.


Switching the anode layers with MOSFETS

While only a maximum of 20 mA can travel through each cathode column (which means that the cathode column can be connected directly to an output pin of a TPI6B595 shift register), the situation of the anode layers is different. They can have up to N*N LEDs lit up at once, so in an 8*8*8 LED cube up to 1.28 A of current can go into an anode layer. This can obviously not be handled by the output of the shift register which controls the anode layers, so we need something that decouples these large currents from the anode layers’ shift register. The solution is to use NDP6020P MOSFETS. It’s important to note that not only can they handle the maximum possible current that goes through the anode layers, but also they switch on/off fast enough (in a matter of a few hundred nanoseconds in the worst case). This is crucial because of the multiplexing used in our cube (switching between layers very fast to trick the human eye and make it think that all the layers are on, while in reality only one is). The ability of the NDP6020P MOSFETS to switch very fast is explained by their low Rds(on) value (seen in their datasheet). This is what sets them apart from many similar components that exist.

Each output of the first shift register (which handles the anode layers) is connected to an NDP6020P MOSFET’s gate through a 220 Ohm resistor. The source pin of the MOSFETS is connected to the 5V power, from where it directs the current to the appropriate anode layer of the cube (through the drain pin) when the shift register switches it on. When the appropriate output pin of the TPIC6B595 is switched on, the output pin acts as low, switching the MOSFET on. When the shift register’s output pin is switched off, the MOSFET is pulled high through the pull-up resistor between its gate and the 5V positive voltage. For this pull-up resistor 5.6K or 3.3K values are fine.


Limiting the LED currents

The brightness of the LEDs in the cube is determined by how much current we allow to flow through them. This is determined by the current limiting resistors that are connected between the LED cathodes and the outputs of the N shift registers which drive the cathode columns. This means that for a cube consisting of N*N*N LEDs we are going to need N*N current limiting resistors of the same value. The value of these resistors depends on how much current we want to give the LEDs, as discussed earlier. The value of the current further depends on the type and color of the LEDs. However, we know that our circuit works with 5V, but the MOSFETS and the shift registers loose some of that voltage, so the value of the current limiting resistors should be calculated with approximately 4.89V (suing Ohm’s law or the LED resistor calculator).


Eliminating ghosting

Unfortunately the clean design of the driving circuit has to be complicated a bit by adding some resistors between the positive voltage and the cathode columns and between the ground and the anode layers respectively. Their role is to help dissipate some currents which would otherwise go through the LEDs when the LEDs are actually switched off. This would result in some ugly ghosting (some LEDs lighting up in a dim fashion when they are supposed to be completely off). The software also needs to be aware of this and wait for a few microseconds between switching one anode layer off and switching the next one on (think of multiplexing). During these few microseconds these unwanted currents are directed away through the resistors. Between the cathode columns and the positive voltage we will add 10K resistors. Between the anode layers and the ground we need to add 1K resistors.

I have struggled a lot until I have finally managed to figure out this solution for the ghosting issue that existed in my test cube. I wish to thank all the members of the official Arduino forum who have given me a hand with this and also to IQJar’s reader Robert Sukhudyan, who has pointed me in the direction of this article, which also deals with a similar solution to a ghosting problem (see the section entitled “Eliminating ghosting”).


Miscellaneous considerations

Let’s not forget to add small, 0.1 uF ceramic capacitors between the +5V inputs of the shift registers and the ground. Some other higher value (perhaps 10 uF) electrolytic capacitors in parallel are also welcome.

One other thing to keep in mind is to connect the GND of the driving circuit to the GND of the Arduino.


Driving circuit PCB

To make building the driving circuit easier, I have designed a printed circuit board to hold all the components. The board, which is 140*120 mm in size, has all the right connections and can safely be used to create the driver circuit for an LED cube of N*N*N, where N<=8. Of course, it’s possible to build the driving circuit on prototyping boards or with some other methods, but this printed circuit is a much cleaner and safer solution, with no ugly wires hanging around.

This is how the design looks from the front:

LED Cube Driver Circuit - Design - Front

and from the back:

LED Cube Driver Circuit - Design - Back

I have created my own driving circuit based on this design and it works perfectly, so we can consider the design to be tested. My real driving circuit board based on the above design turned out like this when viewed from the front:

LED Cube Driver Circuit - Bare Board (Printed Circuit) - Front

and it looks like this from the back:

LED Cube Driver Circuit - Bare Board (Printed Circuit) - Back

Finally, here are a few images of the finished driving circuit, with all components soldered in:

LED Cube Driver Circuit - Complete Board - Front 01

LED Cube Driver Circuit - Complete Board - Back 01

LED Cube Driver Circuit - Complete Board - Front 03

LED Cube Driver Circuit - Complete Board - Front 05

LED Cube Driver Circuit - Complete Board - Front 02

All the files necessary to manufacture the PCB for the LED cube driving circuit (PDFs, Gerber files, miling files, drill data) are available for download here.

So have fun building the driving circuit! The next article about building the 8x8x8 LED cube is going to explain how to build the cube itself, in detail.





Comments

Building an 8x8x8 LED Cube – The Driving Circuit — 25 Comments

    • Very difficult! The whole build process becomes overly complicated because for each LED you’d have 4 wires instead of 2. The circuit is just more shift registers chained together (3x more), so that is not a great deal, although I’m sure that when you chain more together, some problems might arise, like latency (longer chain => slower data transmission). The software becomes also much more complicated. I’d say that making the cube RGB will probably require 10x more work. But, of course, the result is incomparably more awesome. I recommend that you watch Kevin Darrah’s videos on YouTube about making his RGB LED cube. They are very educative. Note that in one of his videos he says that he will never ever start building such a cube again because it’s just too much work :)

      Here’s a link to his channel: http://www.youtube.com/channel/UC42d7zFnWU0dYVk_M0JED6w

  1. Ireally like this layout, it is the cleanest of the ones I’ve seen so far. Where can I find the components list for the board?

  2. I really like this layout, it is the cleanest of the ones I’ve seen so far. Where can I find the components list for the board?

    • I’m afraid I haven’t put together a component list… you’ll have to gather them by looking at the schematic or at the board diagramms.

        • Unfortunately not. I was planning on presenting the software part after the 8x8x8 cube is finished. Unfortunately I cannot find the time to finish it these days. I’m guessing that in the best case it will take a few more months, but maybe even a year or so before I can get to the software part…

          • Bummer! Am I right to say that with this setup, you could turn on multiple LED’s simultaneously in the same layer?

      • Yes, you’re right. But that should not be a problem, should it? In fact, how else would you be able to light up the LEDs in any combination. Because of multiplexing, the principle is that you only light up 1 layer at the same time, but in that layer you can light up any number of LEDs. That’s how it works. That is not a problem. A problem could be lighting up the whole cube (all layers at once). the hardware allows it and if you don’t have a strong enough power source, you might end up with unexpected results or damage. The software is responsible for not letting this happen (multiple layers lit up at once). But if you manage to introduce a serious bug in the code, there’s no guarantee that it won’t happen.

  3. Haha No sorry, just I was sure if the pdf’s of the board were literal size and there may have been a typo! Just being cautious before I make it :) Thanks for the quick reply and the PCB layout!

  4. Hi! I’m really interested to repeat this project, and I like the design of the driver board. I’m only curious if the sample Arduino software code will be published. Thank you!

    • Hi Sergey!
      I’m glad you like it :) The sample software is published, I’m just not advertising it much yet, because I’ve only been able to test it with a 4x4x4 cube so far. Theoretically it’s written in a way which only requires you to change a variable N from value 4 to 8, but, like I said, it hasn’t been tested with 8 yet… If you understand that for 8 it can have bugs (and that there are no animations in it yet, which take advantage of the large cube’s possibilities) and you’re willing to give it a try anyway, you can download it from here: http://iqjar.com/download/jar/LED_Cube/4x4x4/LEDQB_v0.4.ZIP

    • Hi,
      I’ve built this exact model and I believe i can answer your question.
      The total number of arduino Pins required is 3. 1 for the clock, 1 for the latch and 1 for the data. other than that you also require + and – for the voltage, so actually 5 if you don’t get an external source.
      As you probably already know, the 64 columns are driven with 8 shift registers. Now on top of that, the 8 layers are also driver with a shift register in series with the other shift registers. The 8 outputs have to be connected with a proper pull-down resistor to drive the gate of the Mosfets/transistors.
      In the software, you will have to write the code so that the 8 layers are written in the code in the front/back/middle of the data (72 bits of data), depending on how you connect it.
      I suggest you take a very long look at the schematic that is somewhere on this site and also brush up your knowledge on shift registers on youtube.

      And may I remind you that Caps are the equivalent to shouting over the internet? Please don’t, thanks.

      Hope i solved your question.

  5. Thx alot Pieter for the good job and thx again for info. u ‘ve provided. it is part of my final year project to do cubic led, so i ll appreciate it if you can help me here. I cant really figure out the schematic well, is there a way u can post a clearer one. Best Regards man

  6. I want to know if i make my cathodes as the columns and anodes as the layer, what is the things that i need to change ?

    • One of the main assumptions of this design is that the cathodes are the columns and the anodes are the layers, which is what you want, if I understand correctly. You cannot change that.

  7. Good morning all,
    I am new to this page,and would just like to say that i find it very interesting with regard to the cube driver board,is the board to scale,ie can i take a print from it,as i am in the middle of trying to complete an 8x8x8 led cube circuit from another site but find the layout of the schematic confusing up to a point,as i haven’t done electronics since i was aged 14, i am now 48,and wanted to make something that i could stand back and appreciate from my efforts,and my son wanted me to build it too,so don’t want to let him down,i don’t get much time to myself over the week because of my work,so try to do as much as i can over the weekends,anyway i just wanted you to know how interesting your site page is.

    kind regards. Dave.

    • Thank you, Dave! LED cubes are indeed extremely interesting and unique. Unfortunately building them requires a tremendous amount of time, so be ready for that. As for the driving circuit design, the credit goes to Robert Patterson (a.k.a. CrossRoads in the official Arduino forum), who helped me immensely while trying to come up with a usable design. I can never thank him enough in all our names, who follow his design!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>