torsdag den 29. september 2011

Meeting Hub part 2: Software

In the previous post I talked about the 4x4x4 LED cube. This post will be about the software to drive the LED cube from an Arduino. I will assume you know about connecting your Arduino board to a computer and transfer programming code from the Arduino IDE to the board through the USB-interface.

The connection to the LED cube is via a serial-to-parallel shiftregister. This is a way to handle lots of connections with only a few outputs from the microcontroller - in this case the Arduino. I use the 74HC595 shiftregister as described in this tutorial. Using two cascaded shiftregisters means you will have to use the shiftOut command two times in succession in order to service all 16 outputs.

As mentioned in the previous post we will use the concept of multiplexing to light up all the LEDs. This means we will turn on one layer at a time so fast you can't see the switching. The sequence in my code is as follows:

  1. Turn off LEDS
  2. shiftOut 2 times for all 16 LEDs in the layer - setting high the wanted LEDs
  3. Turn on the given layer by pulling the common cathode low.
  4. wait a bit
  5. start over.
With the configuration of the LEDs in the cube an LED will light when a HIGH is set on the data output (the 2 bytes shifted out) and a LOW set on the Layer Select bits (separate output).
I've put this sequence in a function of its own that will 'repaint' the 'image' on the cube a given amount of time - void setCube(int* image, int repeats) This also takes the 'image' as a parameter which is a pointer to an array of 4 integers that tells which LEDs to turn on in the cube. An integer for each layer.

With this it is now possible to visualize any pattern on the 4x4x4 cube. Let your imagination get to work :)

Demo source code is given as an Arduino sketch
Below is a video of the demo sketch in action.

fredag den 16. september 2011

Meeting Hub part 1: LED cube 4x4x4

A week ago I was at the amazing hackerspace conference Meeting Hub #1 at Platform 4, Aalborg, Denmark. This great venue for art & technology and other geeks :) Among other thing it's housing the local hackerspace www.hal9k.com.
This weekend I took part as a drop-in hacker in the Open Hackerspace they've made available. It was a great opportunity to experience what the concept of hacking and the spirit of a hackerspace was all about. And I did enjoy my time there and met a lot of new people. Maybe I'll see them again.
To honor some requests about the documentation on my project their I opened this blog and this time I will post the hardware for the 4x4x4 LED cube. This is inspired by the youtube post from Make Magezine about an LED cube. Theirs is only 3x3x3 but the concept is sort of the same. The schematics is posted below both as a png-file and an eagle-file. The ladder makes it easy to modifiable.
The circuit consists of a couple of cascaded serial to parrallel shift-register. This means they are connected to make the parallel output flow from one to the next to make it serial input with 16-bit parallel outputs. Each output will in turn drive an LED through a resistor. I've chosen a 270 Ohms resistor to limit the current on each output to 10 milliAmps(mA).
In the schematics I've only included one layer of LEDs. Obviously you will have to make 4 of such layers as described in the youtube-video from Make. SL1 in the schematic will connect to the common cathode of each layer and turn it on. As and LED only lights up when the current flows one way through it the cathode needs to be set LOW in order to make the given layer light up. This concept will be described in a later post about the software. For now all you need to know is which resistor value you need. This depends on your kind of LED and how much current you want to run through them. According to the datasheet this should be around 20 mA but just to be on the safe side choose a bit lower :)

In my setup I have a 270 Ohms resistor to limit the current to around 10mA. This is found by way of Ohms. Your LEDs might require a different a different value, but a good rule of thumb suggest that an LED takes a 2VDC voltage drop which leaves 3 V for the resistor when a 5VDC supply voltage is applied. But please consult your datasheet of your LEDs to make certain. Better safe than sorry :)

To follow the concept of multiplexing the output of the shift registers is connected to the anode of each LED (or resistor in this case but it's the same side of the LED) and the cathode is connected together for each layer to make it possible to select each layer. That's why SL1 is not fully connected.

This will hook up nicely with the Arduino or any microcontroller circuit with 7 pins to control it: 3 for controlling the shift registers (SL2) and one for each layer from SL1. More on these connections and how to use them in the next post where I will be talking about the software to control the LED-cube.

Please feel free to post any relevant questions if you have any.

... and get out there and make something.

Here's the schematic for Eagle.
ledcube.sch

søndag den 11. september 2011

Introduction

Welcome to my blog.
Here I will be describing geekeries of any kind related to software programming and electronics and things in between.