LED cube
I finally did it… I’ve wanted to build one for a long time but have always found other more important things to do. However, during last Christmas when I unpacked and organized some components I had recently bought from China the idea popped into my mind again. The timing was perfect. I had some spare time and had just bought a huge amount of cheap LEDs so I started the LED cube project that day.
This is a build log describing the project as far as I can remember. I only have a bunch of pictures to freshen my memory with so some details/steps might have been lost somewhere in my head…
Choosing components
I started to check my inventory to see what I could use to build the cube.
LEDs
The first and most important thing, the LEDs. My choices (i.e. the LEDs I had available in sufficient quantities) where:
- 5mm diffuse red
- 5mm diffuse RGB
- 3mm diffuse red
- 3mm high intensity red
- 3mm high intensity blue
I chose the 3mm blue LEDs because I had a thousand of them, they were cheap, and I like blue.
It would have been really nice to build a RGB cube but those are a bit expensive for this kind of project and the actual construction would have been too complicated for the limited time I had.
Driving the LEDs
My first idea on how to control the LEDs was to directly drive them from the processor (using transistor buffers) but since I recently had bought some STP16CP05 constant current drivers I wanted to try them instead.
The STP16CP05 is a serial to parallel, 16 channel driver which would work great for my cube.
I soldered a driver to a breakout board, hooked up a bunch of LEDs, and connected a processor to test the LED driver. I was satisfied with those LED drivers so I decided to use them for my cube.
Processor
I basically had two choices for the processor, Atmel AVR or XMOS XCore.
There was actually no choice to be made. I just love the XCore architecture and use XCore processors for almost everything since I discovered them. I still use AVR when I need ADC or DAC since the XCore processors don’t do analog stuff without external parts.
I had a bunch of XC-1 and XK-1 development boards and I chose the XK-1 since it’s smaller and easy to piggyback onto another board. The XK-1 also has an onboard SPI flash while the XC-1 does not.
Cube design
I started drawing some LED cubes on paper and came to the conclusion that an odd number of LEDs in each axis seemed nice since there are LEDs in the center of the cube and all axes. I decided to build a 5x5x5 cube since 3x3x3 is too small and 7x7x7 would be too much work.
The cube would consist of five layers with 25 LEDs in each layer. Each of the 25 LEDs in each layer would be controlled individually and each layer time multiplexed.
25 individually controlled LEDs meant that I needed two LED drivers (16+16) and could use five of the remaining channels to do the layer multiplexing. Each of the five layer outputs would be driving PNP transistors to provide power to each layer.
I started trying to assemble some LEDs in a cube shape but soon realized I needed something to hold the LEDs so I could solder them straight. I made a template in wood by drilling a bunch of holes in a grid. The first grid was too small so I extended it a bit.
The first layer was quickly soldered using the template and soon mounted on a stripboard and tested.
Schematic
Before I continued I drew a quick schematic to be able to keep track when assembling the rest of the parts.
The voltage regulator used to power the cube is a breadboard power supply from Sparkfun.
Board assembly
After I assembled all the layers I mounted the LED drivers and XK-1 connector on the board to test with first one layer mounted to the board and later two layers. That’s when I realized a fatal flaw in my selection of LEDs. The combination of high intensity clear plastic LEDs and stacking those LEDs on top of each other resulted in an unforeseen consequence. The amount of light from a led below was so great that the LED above looked like it was also on.
I did not want to start from the beginning with different LEDs so I came up with a quick solution. I simply painted the bottom of each LED with a black permanent marker. ![]()
The result was not perfect but acceptable…
I assembled the board without much thought but am quite happy with the result except for the wires on the top which I really should have put on the bottom of the board. That would have looked much cleaner…
I’ve also added an IR detector to the board to be able to control the animations using a standard remote control but that functionality is not complete yet. I doubt it ever will…
Software
The software for the LED cube is written in XC (a variant of C with extensions that simplify control over concurrency, I/O and timing.
I found inspiration for the command set to control the animations at picprojects.org.uk. The drawing processor described there is pretty sweet and makes creating animations really easy. I’ve used some of the command set although my solution is using C functions instead of (PIC assembly) macros.
This is an example of a simple animation pattern. For each frame the pattern will scroll the entire cube one layer upward and turn on one random LED on the bottom layer. The result is like bubbles in a glass rising to the top.
void bubbles(chanend c)
{
setDelay(70); // Display each frame 70ms
clearall(); // Clear all LEDs
mset(); // Set modifier value
while(1)
{
shyu(); // Shift entire cube up one layer
vox(getrand(5), 0, getrand(5)); // Light up a random voxel
show(c); // Display the frame
}
}
The source code for the LED cube can be found at XCore Exchange.
This is brilliant! Thank you so much for the wonderfully detailed overview, including your THOUGHT processes! As a fellow engineer (me: unix) I very very much appreciated your thoroughness.
While I’m not myself interested in cubes, I *am* in the process of trying to design a “wall of light” using an 8×8 grid of RGB LEDs that will be diffused. Just having problems!
Anyway. Thanks again!
RMT