Make Logic Gates out of (Almost) Anything


Logic gates are the bricks and mortar of digital electronics, implementing a logical operation on one or more binary inputs to produce a single output. These operations are what make all computations possible in every device you own, whether it is your cell phone, computer, gaming console etc.  There are myriad ways of implementing logic gates; mechanically, electronically, virtually (think Minecraft), etc. Let’s take a look at what it takes to create some fun, out-of-the-ordinary gate implementations.

How they work

As an example, let’s consider the AND gate (the others are OR, NOT, NAND, NOR, XOR and andgateXNOR). Electronic gates operate on two nominal voltages, normally 0 V and 5 V, representing the logic 0 and the logic 1, respectively.

The AND gate has two inputs A and B. The output of the gate, A.B, depends on the two inputs according to the truth table at the right. The AND gate has a “1” output only when both A and B are 1. As you can guess, the OR gate has a 1 output when A or B are 1, and 0 only when both A and B are 0.

Every gate has its own truth table. Although these seven gates are normally considered the “basic” gates, there are some gates, such as the NAND gate, that are universal, meaning that they can be interconnected to construct all other gates.

Combining Gates

5Logic gates can be combined to perform any computation. There are millions of them in a computer chip. But let’s see a very simple application of the AND gate.

At the left is a schematic for an automatic thermostat. The heater must turn on if the water is cold, but only if there is enough water in the tank. Contacts X and Y are near the top of the tank and if they are covered with water a signal is sent to one of the gate’s inputs. The thermistor senses the water temperature, and if it is cold enough, a signal is sent to the other gate input. Therefore the heater goes on when there is sufficient water and the temperature is cold enough.

Other Gate Implementations

Contemporary logic circuits use MOSFETs as the elements to build gates, but there are many ways to implement them. Using relays is one of them, and you can literally see how they work. [Andrew Kingsolver] has done an excellent job of explaining relay-based logic. The image below show his implementation of the AND and OR gates. A quick analysis of the circuits reveals how the truth tables are obtained from the inputs, represented by the two switches (energizing the coil in the relay will push the contacts to the far poles).

In order to understand how arithmetic can be done with logic gates, the half adder is a good example. [Andrew Kingsolver] has done that as well. It takes two inputs (0 or 1) and outputs a sum and a carry, in binary of course. This can be implemented with an AND gate and an XOR gate. As you may know, early computers were relay-based, and you can even build one just for fun, if you have the time.

Vacuum tubes replaced relays as the main elements for computation. A simplified circuit that implements the NOR logic gate, which only outputs 1 when both inputs are o, is show at the right. The tube grids are the inputs. There is no output when both grids are low, since the current flows to ground. When voltage is applied to both grids, the tubes become basically an infinite resistance, and a current flows to the output.

As with relays, all kinds of logic circuits were made using vacuum tubes. There were 17,468 of them in the ENIAC computer. Tube circuits were bulkier and power-hungry compared to relays, but the speed of computation was much larger.

Eventually, silicon arrived, and vacuum tube logic was replaced with diode and transistor logic. This represented a dramatic increase in speed and a great reduction in size and power consumption. You guessed it, diodes can also be used to build logic gates, but not all of them, only the AND and OR gates can be built using diodes only. However, by adding a transistor as an active element, all other gates can be implemented.

legosThe three input, diode-only AND gate is shown in the picture above. When all inputs are positive, a current will flow through the resistor and pull the output positive. If any of the three inputs is at 0 volts, current flowing through the corresponding diode will pull the output voltage down to 0 volts. The other diodes would be reverse biased and conduct no current.

How about mechanical logic gates? Sure, you can use LEGO to build gates and a half adder, or a small adding machine using wood and marbles. Of course, pneumatic logic gates can also be designed (useful in places with high levels of moisture or dust).

orms
OR gate built in Minesweeper

Some bizarre ways of building logic gates also exist. Conway’s Game of Life, perhaps the most well known cellular automaton, has been shown to be a Universal Turing Machine, meaning that anything that can be computed algorithmically can be done within the game. The game is fascinating by itself, and detailed ways of building gates in it have been described.

Another similar example comes from the Minesweeper game, popular in early versions of Windows.  This game seems innocent, but is in fact an NP-complete problem (the hardest problems to solve).

So if you have some spare time, consider building some logic gates, after all, there are many ways to do it!



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *