LED Cube/Understanding The Electronics

Aus Wiki CCC Göttingen
Wechseln zu: Navigation, Suche

This page is meant to give you a understanding of the workings in your LED cube. We will try to avoid common electronics slang, thus this is especially suitable for you if you are not familiar with electronics. If you are, however, you are probably better of simply having a look at the schematics and your cube itself - it is not complex in any aspect.

The Cube Structure

We will first explain the cube structure and then work our way to the USB connector. First of all, some basic understanding on how you work with LEDs.

LEDs are very handy and mostly nice-looking devices which is the reason we chose to create this cube kit. Usually, if you connect a LED to a battery, there is a characteristic of the LED you have to take into consideration. For batteries with very low voltage ratings, your LED will not emit light. If you slowly increase the voltage, for example by using different batteries, or, if you are more used to electronics, use a variable voltage source, you will see that at some voltage, current will start to flow through the LED and it lights up. This depends on the color (or the technology) of the LED. Red LEDs for example start to light up at about 1.5 V. However, in contrast to a light bulb, which will not get much brighter or draw much more current at higher voltages, the LED will! Thus, if you want to connect a LED to a commonly available voltage source with a fixed voltage, it is necessary to add a resistor to the circuit which is able to limit this current. So, if you want to connect an LED to a battery, the circuit will look somewhat like this:


Please notice that I have used two colors for the wires: black and blue. You can use these colors to find the same wires in future schematics.

Now, we are not interested to always light up an LED, but we want to be able to switch them off and on to display different patterns on our cube. Thus we add a switch:


With this circuit we can control the LED with the switch. If the switch is closed, the LED lights up. If it is opened, the LED is off. You may have wondered that you do not see this switch on your own LED cube: The switch is included in the microcontroller (the largest device on your board) and controlled by a program that is running on it. Thus you do not have to switch your LED off and on manually, but it is cone automatically.

However, we are not nearly done. We do not have only one LED, we have 27 in a 3 * 3 * 3 cube! So, let's add further LEDs to our circuit, which will give us one plane of your cube:


This is quite a bit more complex. Please take some time looking at this diagram. You can clearly see that the "Switch-Resistor-LED" construct has simply been duplicated until we had nine of them. The battery is still only one - we can connect all of these constructs to the same battery. Notice especially that you can already recognize that this is one plane of your cube. The black wires are going downwards, the blue wire is used to connect the short pins of the LEDs together and is then going down separately, using only one wire. Using this pattern and our intelligent switches within our microcontroller we are already able to display two-dimensional patterns.

But, that's not enough! We need two additional planes. The first idea that comes to ones mind may be to again add two copies of that plane, leading to 27 LEDs, 27 Resistors and 27 Switches, and be done. However, this would be quite problematic: One would first of all require a device which has enough switches, is able to bear the current required by the LEDs to light up. Also, we would have a big mess of wires in our cube which will probably not be as nice at one would with their cube to be. So, we are now doing something which is called multiplexing. Don't be scared of this word, it is really easy and we will develop it step by step.

First, we simply add additional planes of LEDs, however we connect all LEDs together at the lead to the resistor. Thus, three LEDs share one resistor and one LED:


But, you see a big, red question mark in this diagram: How to we connect the opposite wires of the LEDs? Well, we could for example do this:


Now, (as you may have already guessed) this is not the best idea. If we now close one switch, the three LEDs that share one resistor and switch will all light up. (Probably only, actually. Something else is possible, but I will not go into it in this document as this would only confuse you.) This is not what we want, as always complete columns would be on. We need a way to disable the other three LEDs if we only wish to switch on one at a time. And the solution is, you probably guessed it, we add some switches:


Now we are able to switch on a single LED, for example by switching on one blue and one black switch:


This is nice! We are able to control single LEDs! However, if you want to switch on multiple LEDs we will again hit a bump. If these multiple LEDs are on the same plane, we have no problem. However, if we want to enable LEDs on different planes that are not in the same column, we will experience an effect called ghosting: Two additional LEDs will light up. For example, if we close two switches at opposing edge LEDs we get two additional edge LEDs lighting up:


There is no way to fix this electrically - this is the price you have to pay for multiplexing. However, the cubes are still able to display any pattern you want, even two LEDs of different columns in different planes: The switches we are using are *really* fast, much faster than your eye. Thus the microcontroller will only enable one plane at a time and then show you the image on that plane. Then it will go on to the next plane and display this 2D image and so on. This is then done so fast that you are unable to see it and the cube seems to be illuminated completely all the time.

Now, just for completeness: The blue switches are different from the black switches. You will see that the full current of one plane has to be handled by them. Depending on your resistors, this can be quite much for hobby electronics. Also, the microcontoller is not able to handle those currents. Thus, there is a second IC on the board, called "ULN2003". This is simply an array of switches which are able to handle much more current. Thus, the circuit actually looks somewhat like this:


The microcontoller and its periphery

There is not as much to understand about the microcontroller than about the cube. However, there are some things we can show you:

The Oscillator

The microcontroller is a synchrnous device - and as such it requires a clock. What synchronous means, is actually fairly irrelevant, but implied by the word: Everything happens synchronously. This is the reasyon this clock is required - as a signal when "things" should happen.

The clock for the microcontroller is provided by a crystal. To see how such a crystal works, have a look at [1]. The microcontroller basically excites a device like a tuning fork which then gives it a fairly accurate frequency. (There is much more behind that, but let's leave it at that.)