All About Circuits Forum LED 7x7x7 Cube & Effects Generator
 Register Blogs FAQ Members List Today's Posts Search Today's Posts Mark Forums Read

 The Completed Projects Collection A collection of completed projects from All About Circuits forum members. Comment, ask questions, and add to their ideas.

#1
01-21-2013, 09:53 AM
 mhutchie1 Junior Member Join Date: Jan 2013 Location: Sydney Posts: 17
LED 7x7x7 Cube & Effects Generator

I recently finished constructing and programming a 7x7x7 Blue LED Cube, so I thought I'd share a brief overview of the Cube itself. Please ask any questions if you are interested in making a cube, hopefully I can help you out.

Parts List:
• 343x Blue LED’s
• 49x 470 Ohm Resistors
• 7x 2N2222AG Transistors
• Approximately 30m of 0.9mm galvanised steel wire
• 1x Arduino Mega 2560

Equipment Used:
• Soldering Iron
• Heatsink
• Pliers
• Multimeter
• Vice

Software Used:
• Arduino Development Platform
• Processing (Used to design the frames & effects)

The cube is able to process 142 frames per second, that is, 1 frame every 7 milliseconds. Within this time period, it loops through a still frame 7 times (Each cycle of POV lasts 144 microseconds). This is able to compensate for flickering during video recording, allowing all camera’s to record fluid video without distortion.

The cube itself is controlled with an Arduino Mega 2560. For each frame in memory, the Arduino reads and bit shifts 49 bytes of data for an encoded duration. This allows for the cube to be applied to a variety of purposes, from text display to effects to music visualization.

The frames were generated through complex Processing scripts, allowing for a multitude of operations such as shifting in any direction (seen in the rain effect), and an edge shift (seen in the scrolling text around the outside of the cube). These scripts were used to perform the basis of calculations for fireworks, as well as sine waves in 1, 2 & 3 dimensions (seen in the video).

In this cube the supporting structure was made 0.9 mm galvanized steel wire, straightened by stretching the wire. The 5mm Blue LED’s are positioned 30mm apart, with the anodes being attached to the verticals (white wires in the image above) & the cathodes are attached to the horizontal layers (green wires in the image above – bottom right – shown passing through NPN transistors). The Arduino Mega 2560 R3 is positioned on a suspended platform, with the anodes controlled on the Digital Pins as opposed to the cathodes on remapped Analog Inputs.

As the cube is divided into layers (shown in the schematics) I made a template with drill pressed holes that I could fit the 49 LED's in with a spacing of 30mm while soldering the layer. By using a template, the LED's were aligned consistently. On the wooden template, I attached several lugs that allowed me to position the structural layers consistently and accurately. Soldering the layers took me approximately 6 hours, as all of the LED's legs need to be bent to attach to the structure.

I then made a jig out of foam that allowed me to join the first two layers. Layers are joined by soldering vertical straight pieces of galvanised wire to the anodes of the LED's. Once I had done two layers, I shifted the jig up a layer, and mounted the next layer until I had joined all seven layers.

The vertical wires (49 of them) attach to the Arduino on Digital Pins 0-48 directly, shown in the above schematic. At this stage, you essentially have a 2D display with 49 pixels.

To add the third dimension, a small circuit is required (shown below), which uses seven transistors (one for each layer) to connect the cathodes to ground in sequence, so a 1 pixel resolution is the result. This could be done through an IC, however I opted for a small prototyping board, which has seven transistors (I used 2N2222AG - High Speed). The emitters of these transistors are wired to a common ground on the Arduino Mega 2560, each collector is connected to one of the layers, and then the base's are connected to the Arduino's Analog Pins A0-A6.

Please feel free to ask any question, I more than happy to help!

Hutchie
Attached Images
 LED_Cube.JPG (192.3 KB, 1070 views) LED_Cube_02.JPG (121.0 KB, 1034 views) Schematic_Layer.jpg (44.3 KB, 956 views) Schematic_LED.jpg (87.5 KB, 1047 views)

Last edited by mhutchie1; 01-23-2013 at 08:45 AM.
 The Following 3 Users Say Thank You to mhutchie1 For This Useful Post: absf (01-22-2013), brian25 (02-12-2014), toffee_pie (03-19-2013)
#2
01-22-2013, 12:16 AM
 thatoneguy Senior Member Join Date: Feb 2009 Location: Midwest USA Posts: 6,356 Blog Entries: 4

7 is an odd number for a cube (and a prime, and...)

Could you go into details about the bit shifting in the frame buffer for the animations?

That is the part that few have documented for cubes above 4x4 (nibble math).

It's nice to see a solidly built/professional looking project here.

I'm also interested in the processing code to create the animations. That would be a goldmine to save work so others can get the project up and running to create new animations as well.
__________________
$\small{\fra{1}{\fra{1}{R_1}+\fra{1}{R_2}+{\dots}+{ \fra{1}{R_N}}}$ Nifty? -Click Here to see how to make your formulas Look GOOD!
Also-Impedance Graph paper.
 The Following User Says Thank You to thatoneguy For This Useful Post: absf (01-22-2013)
#3
01-22-2013, 12:53 AM
 mhutchie1 Junior Member Join Date: Jan 2013 Location: Sydney Posts: 17

Dimensions:
The reason for the cube being 7x7x7 is that effects in general (spirals, text etc.) work much better when there is a true center LED, as it forms an origin for all effects. Similarly text looks far better when the vertical height is an odd number, as you have a "middle line" for letters like "E", B", etc.

Bit shifting:
To significantly reduce the amount of data required to display the cube (speeding up the running of the script), bit shifting can be used as an extremely effecient method. Basically what happens is I have defined that there are 49 rows of 7 leds (across all layers), so if you use a byte to store data for a single row, you have 7 bits (0100101) representing the value of each LED, and one left over bit, which can be used as a validation bit (1).
In the example above I can have the decimal 75, representing the status of that row, along with 48 other bytes of data.

The arduino runs on a constant loop, reading these bytes, and then converting it into binary. When it then has the binary, it compares 0100101 to 0000001, and realises that the seventh byte is "on", therefor turning the LED on. It then does the bit shift (in this case to the left) and compares 0100101 to 0000010, it detects it should be of, and then starts the cycle again. By using the for loop shown in the code extract below, it will continue to do this until it has read the 7 bits values and outputted them to the cube.

Code:
```for (byte mask = 1; mask>0; mask <<= 1) { //cycle through bit mask
if (myFrames[i][layerInternal] & mask){ // if bitwise AND resolves to true
digitalWrite(myPins[bitcycle],HIGH);
}
bitcycle++;
}```
Select All
Once it has finished this, it loops through reading the other 48 bytes of data, outputting a frame to a cube.

Finally, the 50th byte in the 2D array for each frame stores the number of milliseconds the frame will last.

Effect generation:
In terms of pattern and effect generation, the scripts that generate it are very much dependent of the exact effect that you would like to achieve, for example, for the sine wave, and fireworks, the scripts that I have written would have to accommodate a far wider range of variables to suite individuals preferences for the effects. That being said, i have already started working on this and will hopefully develop this over the next few weeks.
 The Following User Says Thank You to mhutchie1 For This Useful Post: absf (01-22-2013)
#4
01-22-2013, 01:33 AM
 thatoneguy Senior Member Join Date: Feb 2009 Location: Midwest USA Posts: 6,356 Blog Entries: 4

Excellent code, fast and clever! Compared to some of the code posted for other cubes, it's genius level.

If you could post the complete code and the processing script (I'm getting started with Processing since there are questions about it from time to time), that would be most awesome.

Thanks for sharing!
__________________
$\small{\fra{1}{\fra{1}{R_1}+\fra{1}{R_2}+{\dots}+{ \fra{1}{R_N}}}$ Nifty? -Click Here to see how to make your formulas Look GOOD!
Also-Impedance Graph paper.
#5
01-22-2013, 01:57 AM
 mhutchie1 Junior Member Join Date: Jan 2013 Location: Sydney Posts: 17

As I only finished this two days ago, I am just commenting and cleaning up the code, so I will post it in the not to distant future.
 The Following User Says Thank You to mhutchie1 For This Useful Post: Markarduino (03-19-2013)
#6
01-22-2013, 01:49 PM
 MMcLaren Senior Member Join Date: Feb 2010 Location: Michigan, USA Posts: 572

Hi mhutchie1,

It's a work of art before you even turn it on (lol)...

Would I be correct in assuming your program is basically a small sequencer and that the majority of program memory space is simply the sequence (frame) arrays?

Last edited by MMcLaren; 01-22-2013 at 03:14 PM.
#7
01-22-2013, 02:18 PM
 MMcLaren Senior Member Join Date: Feb 2010 Location: Michigan, USA Posts: 572

Quote:
 Originally Posted by thatoneguy Excellent code, fast and clever! Compared to some of the code posted for other cubes, it's genius level.
Really? Is that 343 bit write operations per frame? Does Arduino force you to write individual bits only? Is there no way to write multiple bits directly to a port?

Last edited by MMcLaren; 01-22-2013 at 02:33 PM.
#8
01-22-2013, 02:44 PM
 SPQR Senior Member Join Date: Nov 2011 Location: Los Angeles Posts: 379

What an absolutely beautiful piece of work.
Congratulations!
The YouTube is great - did you sync the music beat to the LED movement or just time it to the beat?
#9
01-22-2013, 07:47 PM
 thatoneguy Senior Member Join Date: Feb 2009 Location: Midwest USA Posts: 6,356 Blog Entries: 4

Quote:
 Originally Posted by MMcLaren Really? Is that 343 bit write operations per frame? Does Arduino force you to write individual bits only? Is there no way to write multiple bits directly to a port?
A lot of code posted is a large number of digitalWrite[Pin]; delay(xx); code (generated from a animation they like), no framebuffer. You can write to an entire port, but the layout of the boards makes that a bit hard to implement. The "Digital" side on Arduino Leonardo has 14 I/O, which are combined from various pins from ports B, D and E, which does make port writes a bit messy.
__________________
$\small{\fra{1}{\fra{1}{R_1}+\fra{1}{R_2}+{\dots}+{ \fra{1}{R_N}}}$ Nifty? -Click Here to see how to make your formulas Look GOOD!
Also-Impedance Graph paper.
#10
01-22-2013, 08:35 PM
 SPQR Senior Member Join Date: Nov 2011 Location: Los Angeles Posts: 379

Could you describe the connections between the wires and the LEDs, or show us a close-up?
How are the wires insulated from each other?

 Tags arduino, cube, effects, generator, led, led cube

 Similar Threads Thread Thread Starter Forum Replies Last Post Turkish The Projects Forum 8 02-27-2014 03:33 PM mp4nerd The Projects Forum 6 12-02-2012 12:29 AM jerseyguy1996 General Electronics Chat 7 01-16-2012 12:56 AM elimenohpee The Projects Forum 1 03-07-2009 09:56 PM YoloMike The Projects Forum 1 02-11-2009 01:17 AM

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Electronics Forums     General Electronics Chat     The Projects Forum     Homework Help     Electronics Resources Software, Microcomputing, and Communications Forums     Programmer's Corner     Embedded Systems and Microcontrollers     Computing and Networks     Radio and Communications Circuits and Projects     The Completed Projects Collection Abstract Forums     Math     Physics     General Science All About Circuits Commmunity Forums     Off-Topic     The Flea Market     Feedback and Suggestions

All times are GMT. The time now is 12:42 PM.