3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

LED Cube 8x8x8

Step 9IO port expansion, alternative solution

IO port expansion, alternative solution
There is another solution for providing more output lines. We went with the latch based multiplexer because we had 8 latches available when building the LED cube.

You can also use a serial-in-parallel out shift register to get 64 output lines. 74HC164 is an 8 bit shift register. This chip has two inputs (may also have an output enable pin, but we will ignore this in this example).
  • data
  • clock
Every time the clock input changes from low to high, the data in Q6 is moved into Q7, Q5 into Q6, Q4 into Q5 and so on. Everything is shifted one position to the right (assuming that Q0 is to the left). The state of the data input line is shifted into Q0.

The way you would normally load data into a chip like this, is to take a byte and bit-shift it into the chip one bit at a time. This uses a lot of CPU cycles. However, we have to use 8 of these chips to get our desired 64 output lines. We simply connect the data input of each shift register to each of the 8 bits on a port on the micro controller. All the clock inputs are connected together and connected to a pin on another IO port.

This setup will use 9 IO lines on the micro controller.

In the previous solution, each byte in our buffer array was placed in it's own latch IC. In this setup each byte will be distributed over all 8 shift registers, with one bit in each.

The following pseudo-code will transfer the contents of a 64 bit buffer array to the shift registers.

// PORT A: bit 0 connected to shift register 0's data input, bit 1 to shift register 1 and so on.
// PORT B: bit 0 connected to all the clock inputs
// char buffer[8] holds 64 bits of data

for (i=0; i < 8; i++)
{

PORTB = 0x00; // Pull the clock line low, so we can pull it high later to trigger the shift register
PORTA = buffer[i]; // Load a byte of data onto port A
PORTB = 0x01; // Pull the clock line high to shift data into the shift registers.

}

This is perhaps a better solution, but we had to use what we had available when building the cube. For the purposes of this instructable, we will be using a latch based multiplexer for IO port expansion. Feel free to use this solution instead if you understand how they both work.

With this setup, the contents of the buffer will be "rotated" 90 degrees compared to the latch based multiplexer. Wire up your cube accordingly, or simply just turn it 90 degrees to compensate ;) 
« Previous StepDownload PDFView All StepsNext Step »
5 comments
Sep 14, 2011. 11:30 PMwalmis says:
you can use SPI peripheral to clock in data faster
Nov 24, 2011. 1:56 PMScerion says:
Yes I agree - I use SPI with a large LED Matrix and 20 shift registers driving 2304 LEDs ( actually 1152, but they are bi-color red/green so I shift in the red bytes for all rows first, then the green bytes ). SPI is much much faster than manual bit-banging. I worked out that it could run around 16000 LEDs at an acceptable frame rate with a 16mhz ATMega328 - but who would want to solder all those together? :-)

This is a great article though, and I'll be using this to make a cube soon!
Apr 26, 2011. 10:41 AMdavid_jc08 says:
no seria mejor usar un 74LS164N todos en seria y solo usar un puerto del pic???
ya que la salida 8 se conecta a los puertos a y b del siguiente 74LS164N ya que si introducimos mas de ocho bit estos los toma como dato de entrapa en siguiente integrado .De esta manera, encadenando varios de estos integrados podemos construir un registro de desplazamiento del largo que deseemos

Jul 6, 2011. 8:59 PMlabrahams vargas says:
Sí es posible encadenarlos de esa manera, la diferencia es que cargar todos los datos tomaría 8 veces más ciclos de trabajo y por tanto más tiempo. Pero si puedes trabajar lo suficientemente rápido puedes usar mucho menos puertos de salida del micro
Jan 10, 2011. 9:18 PMkool-lites says:
Where is the Code Example for this setup you mentioned in the test?

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
651
Followers
7
Author:chr
I like microcontrollers and LEDs :D