28 Ocak 2013 Pazartesi

Logic Gates with Basic Lego Bricks

Last weekend, when I decided to play with my legos again like in old days (when I was a little kid, I used to play with my legos literally all day long) dad challenged me to build logic gates. First, I created some huge and ugly designs. After hours of thinking (and searching for pieces, it takes a few infities until I found the piece I am looking for in my big lego box) I could simplify them to a reasonable level.

In this post I will be showing mechanical implemantations for AND, OR and NOT gates only using the basic pieces. The picture below contains all kind of pieces I am going to use (which are actually a few more than necessary). It will theoretically be possible to connect the gates to build logic circuits.
Pieces used in construction of logic gates 
The small wheel isn't mandatory, but it makes the gates work way better. The fence is used to make the big wheel stand vertical to the green plate. You can achieve this by using lots of bricks if you dont have anything like this piece, but it really simplifies the system. The rest is no more than simple bricks.


Let's start with the simplest element. The piece below is made of a pair of small wheels and an 8x2 brick. They will be mostly used as input and output, but because they're the most basic elements which are used in all my gate designs, I like to call them transistors, although they have nothing else in common.  






By building such small towers (2x2x2) on both sides, you achieve logic elements, which have two states. (pushed as 1 and pulled as 0) The wheels prevent the brick from moving further.






If you don't have wheels, you can use this design, which of course doesn't move as easily as the other one.






As you can see, the transistors have no default value. Besides, they always stay at a value once they are set, even when you remove the force. Therefore you should place them vertically, so they default to 0, and they are reset when you stop lifting them. It's logical to add another brick connecting the "towers" to prevent them from falling. You will also need to increase the height of the towers by one brick, otherwise it rubs against the brick.
A vertically positioned transistor.
Then you are ready for your very first gate. You get to build an OR gate by simply placing two transistors next to each other and making them to push another one for output.

An OR Gate
Here you can see it in action:



Sadly, the NOT and AND gates can not be implemented that easily. The NOT gate's output should be in the upper position when the input is down. So, we use a mechanism that lifts the output and that is disabled by the input.

That weight lifts the output as long as it isn't lifted by the input. This means the force applied by the input should be bigger than that weight. This is why you may need to use heavier and heavier weight when connecting multiple gates.

Those elements are combined in this way:


Let's watch

As you can see, NOT gate is complexer than the OR gate. (We even need an additional plate) AND gate is even worse, because you need to make sure that the inputs can move independently. In NOT gate it's no problem at all because there's only one input and it is impossible for the output to prevent it from having a value. In OR gate the only case the input can't move is input=1 ^ output=0, which never occurs. But when it comes to the AND gate, this is a valid combination. This makes it impossible to design a system in which the output is pushed by the input, because the input should be able to move, even if the output doesn't. The problem is solved with a system, in which the output defaults to 1 (like NOT gate) but both input elements prevent it from raising when any input is 0.




You should make this addition to the basic transistor. This "hook" will stop the output raising.



One input alone should be heavy enough to set the output to 0, so you add a few more bricks.






The output element changes slightly. It's made of plates instead of bricks because it needs to be super light. Additionaly, on the back it has a T, where the input can hook (line in next picture).





Lastly, there is a similar piece like the one in NOT gate, which lifts the output.


You combine them like in this picture:


Voila, it works:

That was it folks. Hope you had as much fun reading this as I had writing. I would like to publish your work ( at least links to your work) if you are willing to make circuits with such components or to improve them. All comments are welcome.

Note to LEGO: I would also like to build a really functional computer if you sponsor me! :)