loading

Step 8: IO port expansion, more multiplexing

We gathered from the last step that an 8x8x8 LED cube requires 64+8 IO lines to operate. No AVR micro controller with a DIP package (the kind of through hole chip you can easily solder or use in a breadboard, Dual Inline Package) have that many IO lines available.

To get get the required 64 output lines needed for the LED anodes, we will create a simple multiplexer circuit. This circuit will multiplex 11 IO lines into 64 output lines.

The multiplexer is built by using a component called a latch or a flip-flop. We will call them latches from here on.

This multiplexer uses an 8 bit latch IC called 74HC574. This chip has the following pins:

  • 8 inputs (D0-7)
  • 8 outputs (Q0-7)
  • 1 "latch" pin (CP)
  • 1 output enable pin (OE)

The job of the latch is to serve as a kind of simple memory. The latch can hold 8 bits of information, and these 8 bits are represented on the output pins. Consider a latch with an LED connected to output Q0. To turn this LED on, apply V+ (1) to input D0, then pull the CP pin low (GND), then high (V+).

When the CP pin changes from low to high, the state of the input D0 is "latched" onto the output Q0, and this output stays in that state regardless of future changes in the status of input D0, until new data is loaded by pulling the CP pin low and high again.
To make a latch array that can remember the on/off state of 64 LEDs we need 8 of these latches. The inputs D0-7 of all the latches are connected together in an 8 bit bus.

To load the on/off states of all the 64 LEDs we simply do this: Load the data of the first latch onto the bus. pull the CP pin of the first latch low then high. Load the data of the second latch onto the bus. pull the CP pin of the second latch low then high. Load the data of the third latch onto the bus. pull the CP pin of the third latch low then high. Rinse and repeat.

The only problem with this setup is that we need 8 IO lines to control the CP line for each latch. The solution is to use a 74HC138. This IC has 3 input lines and 8 outputs. The input lines are used to control which of the 8 output lines that will be pulled low at any time. The rest will be high. Each out the outputs on the 74HC138 is connected to the CP pin on one of the latches.

The following pseudo-code will load the contents of a buffer array onto the latch array:

// PORT A = data bus
// PORT B = address bus (74HC138)
// char buffer[8] holds 64 bits of data for the latch array

PORTB = 0x00; // This pulls CP on latch 1 low.
for (i=0; i < 8; i++)
{

PORTA = buffer[i];
PORTB = i+1;

}

The outputs of the 74HC138 are active LOW. That means that the output that is active is pulled LOW. The latch pin (CP) on the latch is a rising edge trigger, meaning that the data is latched when it changes from LOW to HIGH. To trigger the right latch, the 74HC138 needs to stay one step ahead of the counter i. If it had been an active HIGH chip, we could write PORTB = i; You are probably thinking, what happens when the counter reaches 7, that would mean that the output on PORTB is 8 (1000 binary)on the last iteration of the for() loop. Only the first 8 bits of PORT B are connected to the 74HC138. So when port B outputs 8 or 1000 in binary, the 74HC138 reads 000 in binary, thus completing its cycle. (it started at 0). The 74HC138 now outputs the following sequence: 1 2 3 4 5 6 7 0, thus giving a change from LOW to HIGH for the current latch according to counter i.

<p>hello all of you, I have an idea to replace 16 BJT by ULN2803, it would save up for your area, and it works very tot.Toi did 2 cube leds and it all works fine however, I did not design the RS232 connection on my circuit. and here are some pictures about it:</p>
<p><iframe allowfullscreen="" frameborder="0" height="400" src="https://www.youtube.com/embed/4gNiDprbUPc" width="600"></iframe></p>
<p>can u help me to make the cube<br>can u send me some photos<br>and the list of things used to make the cube</p>
<p>Hi I see you got the cube working.</p><p>I have everything soldered together meaning all parts are on the PCB board, and all LEDs are connected in a 8x8 MATRIX and inserted into the PCB. I am not sure how to proceed with the final steps. Which side goes into the PCB board and which gets soldered to the RED wires in the diagram. </p><p>One version of the Welding guide contradicts the other. One shows the MATRIX going along the X-Axis (PICTURE #4, which is what I have), and the other shows the each MATRIX going along the Y axis (PICTURE #5).</p><p>Here are some images of what I have so far.</p><p>Now I have two options</p><p>1. Bend the NEGATIVE on the right side of each 8x8 MATRIX, and solder them together, then connect each ROW with the board.</p><p>2. or, follow the fourth image and switch all MATRICES to follow the Y-AXIS on the PCB</p>
<p>And in case it matters I have THIS cube kit from GikFun3D 8x8x8 CUBE with the blue PCB #11129F71578</p>
<p>đẹp lắm thanh ni&ecirc;n. m&agrave; cậu c&oacute; t&agrave;i liệu về led xoay n&agrave;o c&oacute; thể l&agrave;m được kh&ocirc;ng vậy. m&igrave;nh đang l&agrave;m m&agrave; n&oacute; kh&ocirc;ng chạy mới khổ. đang l&agrave;m đồ &aacute;n :D</p>
<p>send me pls PCB documentery sunayyildiz1989@gmail.com</p>
Circuit diagrams<br>Or kits details me <br>Also thes programmes code
<p>cho mình sin file hex của bạn với</p>
<p>You can use even less space using SMT 2N2222 type transistors. My board will take either.</p>
<p>Great idea!</p>
<p>Thanks. Most components on the board allow for SMT or through-hole.</p>
<p>hi sir, can you send me the circuit and diagram.</p><p>my mail qdat1202@gmail.com</p>
<p>Can you please kindly send me the circuit and diagram.</p><p>MAy mail add<br>isurutharanga019@gmail.com</p>
Can you please kindly send me the circuit and diagram.
<p>The circuit diagrams for this project are in this instructable.</p>
My email address is sisirroy777@gmail.com
<p>Neat.</p>
<p>Hello DongP1, <br>Can you share a more clear schematic how did you used the ULN2803 and explain what changes have you done to the code ?</p><p>Thanks</p>
<p>OK you, I'm very fun when help you. You can use Proteus to open file schematic and PCB, and i did fixed code. all in here:<br>https://drive.google.com/file/d/0BzXbfPpoHKV5eWQxU1VQODZhTTA/view?usp=sharing<br>when you use atmega32 you must set fuse for it. <br></p><p>and when you solder PCB solder you should note carefully and did not miss any legs, as this is the second circuit face, you can also book for someone trained to do it to ensure circuit reliability. And my final non-electric circuits become restricts motherboard area, it absolutely does not affect the led. And can not forget that it is a 5V supply. Wish success. I look forward to seeing your circuit here.</p><p></p><p>Inside the downloaded folder: principle diagram, schematic print, inside a simulated 3d opened by Proteus, the revised code with external hex file, inside the code can edit custom and standard you, use WINAVR (recommended recommended). and images to set the fuse for ATmega32.</p>
<p>Hi!!<br>Do you know hoe to flash the EEPROM of Arduino just like we do in normal non-arduino boards..<br>i.e. we flash .eep file directly into the micro controller.. do you know any similar or equivalant thing in Arduino...?</p>
<p>I sorry you, because I do not use Arduino, so I did not go through the difficulties you face, but you can read more online material on its use. I can only help you in terms of hardware. Good luck. I believe you will succeed! : D</p>
<p>Thnx for replying!<br>I got a solution for it already!</p>
Your led cube <br>Whitch kits using<br>
<p>Hello, </p><p>Now I got it. The idea to use the ULN2803 is to avoid using transistors correct ?<br>What do you mean that I need to set the fuse for the ATMEGA32 ?<br>I will be using arduino board, either Nano or mega. </p><p>Thanks for your reply </p><p>Jose </p>
<p>is this, if you use it you must chip atmega fuse set inside the IC, the fuse is to control a number of functions such as: using the calibrated internal or external crystal, and and some rather different features, please reference IC data sheet. so that it operates according to your desired this function. I use the load circuit to the load burn-e program for my IC, please find out more about it, or you can use the load circuit which you are available. <br>ULN2803 help replace the transistor 16 in the layer. you read this ic data sheet to learn more. I had to diagram inside folders principle schematic. you see that in order to better understand how it works. wish success! : D</p>
You don't need changes in code
<p>Sorry for answers will tell you now, when using ULN2803 then your program absolutely nothing changes, we simply optimized hardware only. Good luck! soon see your results here. : D</p>
<p>Cho e xin sơ đồ mạch in đc ko ạ</p>
<p>Hi DongP1, I am so like the Cube and I want to make it and give to my girl friend as a big surprise. Can you send all schematics ,programs and other files to me . Thans so much.</p><p>My e-mail address: dongliang.ma@matrixopto.com </p>
https://drive.google.com/file/d/0BzXbfPpoHKV5eWQxU1VQODZhTTA/view?usp=sharing
<p>Hey guy, if i use STK500 device to set up for atmega32 then plug it to the board , so, can i remove RS232 and AVR Isp?</p>
<p>sir, i have successfully made my cube, now the problem is with the code... im using arduino uno and the code given in this article i.e for arduino user is working fine for me... but other codes which are used for AVR is not compatible with aduino ? does coding for both arduino uno and AVR are different ?</p><p>i got a error as &quot;compilation terminated </p><p> exist status 1</p><p> error compiling &quot;</p><p>if there is solution for this plz post . </p><p>and the code in the link which u gave is compatible with arduino uno ? </p><p> Thanks :)</p>
<p>You likely need an older, or possibly a newer copy of the IDE.</p>
<p>sir presently im using latest version of IDE i.e 1.6.7</p><p>can i know the the exact version of IDE ??</p><p>and sir how can i make others codes compatible with IDE?</p><p>Thanks :)</p>
mail me.. 233himanshu@gmail.com
This is here. https://drive.google.com/file/d/0BzXbfPpoHKV5eWQxU1VQODZhTTA/view?usp=sharing and don't need chager in program .
<p>Hi Phamd4 , thank you so much. I have another question, I can not open the CUBE schematic and pcb files with Protues Desing Suite 8.0 , my computer is Win 7 system. whether the version of the Protues is not matching? Can you help me .</p>
<p>hello everyone, I have an idea to replace 16 BJT layers by ULN2803, it will save your area, and it works very well I did 2 LED cube and all activities well however, I did not design the RS232 connection on my circuit.</p>
<p>I have built an 8x8x8 cube using an Arduino Uno to run.</p><p>This works brilliantly with the code that you have kindly <br></p><p>Is<br> it possible to have the original, complete code for your cube demo <br>shown on this page. The code I have is missing a few of the animations <br>(see below) and as my programming in C is not great, I would really <br>appreciate some help!</p><p>single 'drops' of LEDs shifting vertically, up &amp; down (1min, 4sec); </p><p>sphere moving around internally (26 sec); </p><p>several LEDs shifting vertically, up &amp; down (1min, 17sec); </p><p>filling of cube from one diagonal to the other (1min, 59sec); </p><p>rotating character (3min, 5sec); </p><p>arrow path around the outside (3min, 14sec); </p><p>rotating internal arrow (3min, 59sec);</p>
<p>Did the pde download oddly when you downloaded it? Mine downloaded as a tmp file rather than a pde, and I can't open it.</p>
<p><strong>Various Different methods of making LED Cube 8x8x8</strong></p><p><a href="http://www.tricksandhacks.com/" rel="nofollow">http://www.tricksandhacks.com/</a></p>
<p>Hey, Can i use a 16 Mhz crystal instead, because i cannot find a 14.7456 Mhz crystal anywhere</p>
<p>Wow, Great instructable!</p><p>Here is the circuit diagram and PCB of a 8x8x8 RGB LED Cube using STC12C5A60S2.</p><p><a href="https://easyeda.com/wangpeng/8x8x8_RGB_LED_Cube_BasedonMCU-zZXtZhzsK" rel="nofollow">https://easyeda.com/wangpeng/8x8x8_RGB_LED_Cube_BasedonMCU-zZXtZhzsK</a></p>
<p>So I am (still) building this and I have a question... I was having trouble with the LEDs, some row-column combinations were lighting multiple LEDs and a couple didn't light at all. Turns out I (somehow) missed soldering the anodes between layers for an entire column! Once I took care of that, that fixed the three LEDs lighting up at a time, but I still had a couple of other LEDs ghosting when one or the other was turned on. I found one open LED and one shorted LED - luckily on the outside column! I guess that happened when I was soldering the layers together... I swear I tested each layer as I built it. </p><p>After all of that, I powered it up and the only thing that happens is that the &quot;status&quot; LEDs flicker back and forth. The entire cube is off. If I hit either the &quot;deubg&quot; switch or the &quot;status&quot; switch, the &quot;status&quot; LEDs stop flickering and only one remains lit. The cube then begins going through it's test program. The problem is that four rows-columns are constant lit and a couple of LEDs only come on during certain cycles, but not others. Since the entire cube is off before the processor beings running, that would tend to tell me that nothing is shorted. Also, when I press either the &quot;status&quot; or &quot;debug&quot; switches after the program is running, nothing happens. </p><p>When I first programmed the AVR, I used avrdude running under Ubuntu Linux and an AVRasp programmer. Every time I try to program the IC, it tells me that it expects a certain signature, but that the one returned by the IC is different and that I need to check my IC since it doesn't appear (to the programmer) to be an ATmega32. The IC I am using is ATMEGA32 16PU 1403. This is the same chip shown on the photos here, with the exception of the last line, which I didn't think should matter. I am able to program the IC anyway using the -F (force program) switch in avrdude, but I am wondering if this might be my problem rather than a hardware issue. </p><p>Any thoughts, ideas, or help? I've been working on this freaking thing on and off for over a year now, so I am ready to see some final results! Thanks...</p>
<p>hi , can you send me the circuit and diagram.</p><p>my mail suynghj@gmail.com</p>
<p>I still haven't got round to making this, can't wait to start!</p>

About This Instructable

5,415,439views

4,211favorites

License:

Bio: I like microcontrollers and LEDs :D
More by chr:Reverse Engineering: RGB LED Bulb with IR remote Reverse engineering: USB controlled home automation hack LED Cube 8x8x8 
Add instructable to: