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>Hi ......</p><p>hope you are fine and doing wel....</p><p>I Just complete this project and its doing good</p><p>i used Arduino UNO </p><p>thanks for all this help</p><p>sir can you have ripple and sidewave effects codes for arduino....</p><p>If so,,,</p><p>please share it to me....</p><p>i am very excited to add this effects</p><p>waiting your's reply </p>
<p>HELP!!<br>How To run PC software code on windows machine?<br>My 3D functions not working. <br>I'm using a USB-TTL serial converter instead of RS232, and Arduino Mega.<br>I can post code of Arduino MEGA (altough it was already posted in one of the comments) and PC software if rrequired.<br>Everything compiles well. I'm using createfile() function under windows.h to create hCOM handle and writefile() function in the cube_push() function to write data to serial port..<br>Everything copiles well, but nothing shows up in the cube.<br>HELP!</p>
<p>I want to run code on desktop computer, but i dont know how to create a User Interface ( a simple software) to send a binary buffer to micro controller.Someone can teach me how to do this.</p><p>Thanks so much.</p>
Thanks for doing this Instructabe! I actually did this as my first electronic project, and it worked flawlessly on an Arduino UNO. I really apreciate you took the time to do a guide so extensive and complete.<br>Now, i wanna manage the cube via Serial Comunication on Bluetooth. So i need an Arduino MEGA(the Uno doesnt have any Pins lef). Problem is, the code isnt compatible with the Mega and i cant fully understand how the PORT commands work, so i am unable to make it work on am Arduino MEGA. Can you help doing a compatible code. (I dont need to use Analog pins anymore to control the cube)
I have the code for the mega. Will post this evening.
<p>Hi!<br>Can you please post the complete code (with all animations+serial programming)<br>for Arduino MEGA!?</p>
https://forum.arduino.cc/index.php?topic=371012.0
<p>Hello!,<br>I also have same problem. I also now want to make more awesome animations using serial communication. Have you found some way?<br>Or have you found some way to use UNO itself? Or i have to go for Arduino Mega?</p>
<p>Pls .pls help me i can't understand the wiring can someone pls give me easy board design i am going to control it with a arduino uno or an arduino no (most probably nano) pls i need help .pls tell me a easy board design. </p>
<p><a href="http://www.pyroelectro.com/projects/8x8x8_led_cube/img/8x8x8_schematic.png" rel="nofollow">http://www.pyroelectro.com/projects/8x8x8_led_cube...</a><br><br>See this..this uses Arduino UNO..<br>I would recommend you to read some tutorials first..like CHR, SuperTech-IT, and Pyro Electro..<br>Then get your hands dirty! :) </p>
Just about to start this project as mg first. Any tips would be lovely. Thanks!
<p>Just be very sure about not to short VCC and GND anywhere!<br>And don't forget the capacitors anywhere, altough they seem of less use but infact they improve switching.</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>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>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>
<p><iframe allowfullscreen="" frameborder="0" height="400" src="https://www.youtube.com/embed/4gNiDprbUPc" width="600"></iframe></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>How Do i flash the EEPROM of arduino!?<br>i.e. i want to store the fonts in the eeprom of arduino UNO ..how to do?<br>for eg. i could easily flash the .eep file when using normal AVR board or some non arduino board..but how to do the equivalent thing in Arduino UNO!?<br>PLZ Help!</p>
<p>Hey thanks for the instructable! I finally finished mine. Here is a link to the arduino mega2560 code that i used for my cube.</p><p><a href="https://forum.arduino.cc/index.php?topic=371012.0" rel="nofollow">https://forum.arduino.cc/index.php?topic=371012.0</a></p><p>Hope that helps someone!</p>
<p>Perfect explanations, I have learnt soldering and reading circuits with this project, which had been my final project for high school.<br>I used 5mm LEDs (I think I should have bought 3mm LEDs instead because the sight of the LED at the opposite corner is not clear) and an Arduino Nano v3.0 to run the software. <br>The best thing of this guide is that as soon as you understand how the functions of the provided code work you can easily make your own ones (if you know C)</p>
<p>great job!!!</p>
<p>Thanks for your great instructions. The structure worked great and all without a mistake. The biggest problem for me is still the programming.<br> But should also be creating.<br> sorry for my bad english I have it translated into google XD<br> But pictures say more than a thousand words.</p>
<p>what a neat project ;D ,great soldering job ! You are my idol now. You must be a soldering master or monster ;)</p>
<p>thank you very much. It was a very elaborate work.</p><p>when the housing is done I take a picture.</p>
<p>i think u have same code used in site or different one if u have different one can u send to this email aravin_fun@icloud.com</p>
<p>I am done everything its work good but I feel animation is not working some of that </p>
<p>your cube was look nice perfect</p>
can any one please tell me how to use PC software? (pl dont tell me about escape characters, i already understand them). I want to know how does the PC software send data through COM PORT via serial line. I am using USB-TTL converter, but i'm unable to run the PC software as i suppose it was written for UNIX. i'm having trouble with the PC software functions for advance animations. Also, the terminos.h file and related Header files are not present. where should i run the PC software? in Atmel studio 4, or atmel studio 6, where? i'm unable to understand. all you people, please guide this beginner :)<br>thnx.
<p>https://www.youtube.com/watch?v=qO5z9IuCnXY </p>
<p>what a nice job! I spent a whole week on soldering and debugging (what a struggling job! )I finally decide to make a PCB multiplexer board. it works well and make whole device look nice and clean. I still have 9 pcs PCB rest . if anyone needs please send message to me . 20usd/pc .</p>
<p>what size drill bit?</p>
<p>I've made the LED lattice and am starting on the electronics now but have a few questions:</p><p>What values should the pull up resistors be?</p><p>Is 2k2, 1k or 100ohm the best for the transistor base resistor?</p>
<p>Do you have something like a link ready to a cart with all of the materials except the LED's? That would be extremely helpful</p><p>Thanks</p>
Hi I'm getting closer to being done with my cube and I just wanted to say thanks for making this possible. I've had to make things work my way but you've made it possible for me to do it. I will post a pic when I'm done
<p>You can have programs teaching it? !</p><p>Send to peterabbey52013@gmail.com </p>
<p>please give me a code and schematic email phanquoctri89@gmail.com</p>
<p>Hello, I used the exact set up with an Arduino Uno. As soon as I connect the the 5v pin to the board its stops. No more lights on the arduino. Dose this mean I have a short circuit somewhere? How do I trouble shoot for it? Thanks I'm new to this and was really excited about building one. </p>
<br> Really<br> great post. I just unearthed your web journal and needed to say that I have<br> truly delighted in perusing your blog entries. Any way I'll be subscribing to<br> your food and I trust you post again soon. Huge a debt of gratitude is in<br> order for the helpful information.<br><br> <a href="http://www.grivy.com/featureddeals/city/bali" rel="nofollow">bali deals</a><br>
<p>please give me a code and schematic email asimsheikh780@gmail.com</p>
<p>Great survey, I'm sure you're getting a great response.<br><a href="http://markoservices.pl/pod-lupa-szklo-w-kaszkach-nestle/" rel="nofollow">szklo w nestle</a></p>
<p>Hello, I understand that the use of two transistor for each layer is due to the current limitation of the transistor. Can those 2 be changed for a more powerfull transistor ?<br>Also,its not possible to use some kind of shift register to control the transistors ?Use 3 ports instead of 8 ports ?</p>
<p>bravo</p>
<p>Great work..</p>
Hii....i built my cube but its not glowing properly....
<br> The<br> website is looking bit flashy and it catches the visitors eyes. Design is<br> pretty simple and a good user friendly interface.<br><p><a href="http://journalistesportif.tumblr.com" rel="nofollow">http://journalistesportif.tumblr.com</a></p>
<p>Hi, I've added your project to the &quot;<strong>A Collection of WAAAY To Many 8X8X8 RGB LED Cubes!</strong>&quot; Collection</p><p>This is the link If you are interested:</p><p><a href="http://www.instructables.com/id/A-Collection-of-WAAAY-To-Many-8X8X8-RGB-LED-Cubes/">http://www.instructables.com/id/A-Collection-of-WA...</a></p>
<p>Hi guys! ? </p><p>first, thanks to chr for that incredible instructable! it has me inspired, a lot. </p><p>i tried to download the files from the project. but i was not successfull.</p><p>any ideas?</p>

About This Instructable

4,913,548 views

3,798 favorites

License:

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