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>look the video led not working and bord file in pdf can u people help me fix my problem</p>
<p>look my video led was not working on 2 row actually working but working different way I don what mistake I have done I attached board file in pdf please anybody can help I am really appreciate. I put full effort for this project but finally animation make me upset </p>
<p>hai I have problem in cube I done well but some animation not coming properly 1 and 2 row I mean 1and 2 ic I checked very well circuit is correct can u help me I upload pdf of my schematic and pics</p>
<p>Hello,</p><p>I read these sentences in this post:</p><p>With a cpu frequency of 14745600 Hz, 128 prescaler and output compare of 10, the interrupt routine is called every 1408th CPU cycle (128*11) or 10472.7 times per second.</p><p>Can anybody help me to explain how to calculate to 10472.7 times per second. I am new to AVR timer.</p><p>Thanks,</p>
Thanks for sharing the awesome project.? . The instructibles are very elaborative. Atfirst i was sceptical if i could make this project. But atlast after backbraking hours of soldering and debugging , it was a succes. And the credit goes to chr. Thanks chr . U rock☺.<br>I used arduino uno as the controller. But the code is not complete. I mean many effects are missing. I dont know anything about programming. I request u to please mail me the code with every effect. It will be a great help. Thank u.<br>dbnjnds@gmail.com
<p>Is there some other way other than gray coding in software to avoid 74HC138 glitches </p>
<p>If the latch order is incorrect from the 138, usually it's the binary inputs are either miswired (wrong order, or a line not connected) or 2 inputs are shorted together.</p><p>Another issue you may run into is switching the data too fast, not latching long enough etc. which has to be fixed in the code.</p>
<p>hey can you please help me.</p><p>IC 74hc138 is misbehaving. I suspect it to be race hazard.</p><p>Wrong latches are being selected by the address selecter.</p><p>the following sequence seems to fix the proplem.</p><p>void draw(char *buffer)</p><p>{</p><p> PORTB=0b00001000;</p><p> PORTA=buffer[0]; </p><p> PORTB=0b00001001;</p><p> PORTA=buffer[1];</p><p> PORTB=0b00001101;</p><p> PORTA=buffer[5];</p><p> PORTB=0b00001100;</p><p> PORTA=buffer[4];</p><p> PORTB=0b00001110;</p><p> PORTA=buffer[6];</p><p> PORTB=0b00001010;</p><p> PORTA=buffer[2];</p><p> PORTB=0b00001011;</p><p> PORTA=buffer[3];</p><p> PORTB=0b00001111;</p><p> PORTA=buffer[7];</p><p> PORTB=0b00001000;</p><p> PORTB=0b00000000;</p><p>}</p><p>What I did was to change one logical state in the input to decoder at a time.</p><p>some sites recommend temporary disabling of output to prevent race hazards.</p><p>how did you deal with this issue&gt;</p><p>pls help </p>
<p>WOW - 5 million views.</p><p>I think it's some kind of record! LOL!</p>
Hi, Where do i buy all that stuff for 69 dlls? Thanks
<p>thats projects its great! Im looking for all the stuff and making time for doing! please continue doing amazing thing. :)</p>
<p>hi, really great instructable, kind that inspires people.</p><p>This code, cube[5][3] |= (0x01 &lt;&lt; 4);</p><p>Hex01 bit wise move 4, or with a 2d array, I can't get my head around it.</p><p>Plz, a more detailed description will save me from more tablets, cheers</p>
<p>Made it!!</p><p>Thank you for the great instruction!!</p>
<p>Your print looks very neat. Mine is very messy.</p>
<p>Wow, how do you get your trace wires so straight and the perfect length?</p>
<p>I measured 1, and cut them all to the same length at once...</p><p>And alcohol-free-february also did the trick ;-)</p>
<p>Hahaha nice work!</p>
<p>Nice job. Many never get their hand wired boards working! Nice and tidy job too.</p>
<p>Do you have a list of components that that board required?</p>
<p>Thank you for your guidance chr..</p>
<p>i am selling most of the components needed from Futurlec. I decided to do the Tindie kit instead. You can find my list of parts (less 512 LEDS) and further info in the classified sale section here: </p><p><a href="http://www.instructables.com/community/Major-Parts-KIT-for-8X8-CUBE-LED-from-Furturlec/">http://www.instructables.com/community/Major-Parts...</a></p><p>I am offering this at a discount and Priority mail within the US. </p><p>thank you</p>
<p>What's the purpose of the address bus?</p><p>And can all of the cube or generally any number of IO's can be runned with only 3 pins by making layers of shift registers?</p>
<p>Is it possible to just switch out these same color LED's for some RGB LED's without changing anything else, apart from the code?</p>
<p>I understand that RGB LEDs have 4 pins, and this may be change the layout of how cube is soldered. How much harder am I making this project by deciding to use RGB LEDs. This is my first LED cube so I don't want to get in over my head.</p>
<p>hi</p><p>i need a help for connecting program (3d8s alpha ) to arduino uno </p>
<p>If we want to replace all transistors, for cathode riser, like Đ&ocirc;ng Phạm post, we can use ULN2803. If we are anode riser, TD62783 is the replacement for ULN2803.</p>
<p>Great Tutorial. Thanks</p>
<p>hi<br>thanks for this nce tut. </p><p>can any one tell me if i can use SN74LS574,HD74LS138P instead of 74HC574,74HC138 and im using arduino uno <br>thanks alot<br></p>
<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>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>You can use even less space using SMT 2N2222 type transistors. My board will take either.</p>
Can you please kindly send me the circuit and diagram.
<p>The circuit diagrams for this project are in this instructable.</p>

About This Instructable

5,124,343views

4,001favorites

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: