Over the years electronics has gone two distinctly different directions; digital and analog. Digital electronics involves manipulation of signals in two well defined states, on and off. Analog electronics is not within the scope of this article.
By limiting signals to two states, the effects of distortion and interference introduced to signals as they travel around any circuit are greatly reduced. For example, when an audio signal passes through a copper trace on a PCB it encounters a small amount of resistance which dissipates small amount of the signal's energy as heat and limits the rate at which voltages can change. These effects change the audio signal slightly as it moves through the circuit and can often result in audible distortion. Digital signals suffer in the same way, but because there is only two well defined states that the signal can be interpreted as (rather than an infinite amount of undefined states) the effects of this distortion are far less likely to be of consequence.
Before we go on it should be noted that there is in fact a third "state" often encountered in digital circuits, often called tristate. Where "on" is usually a defined voltage level (for example positive 5 volts) and off is another defined voltage (such as 0 volts), tristate is more the absence of a voltage or a high impedance state. (when referring to an I/O pin)
So, digital electronics involves signals in two (or three) different states. We'll call these high, low and tristate or occasionally 0, 1 and Z. Now we need a means by which these signals can be manipulated, which is where logic functions come in. I am referring to the boolean operators AND, OR, XOR and NOT. The table below presents a summary.
This stuff should be more or less self explanatory. AND takes two inputs and only sets the output if one and the other input are set. OR takes two inputs and sets the output if one or the other (or both) are set. XOR, or exclusive OR, takes two inputs and sets the output if one or the other (exclusively, so not both) are set. NOT takes one input and ensures the the output is not the same.
These functions (with the exception of NOT) can be expanded to more than two inputs. For example a 3 input AND gate would require that all three inputs were set before the output was, where a 5 input XOR gate would only set the output when one (and only one) of the five inputs was set.
Because the NOT gate operates from a single input, it is often combined with other logic gates by placing the NOT gate in series with the output to invert the signal. The result is a NAND, NOR or XNOR gate which operates as described above except the sense of the output signal is inverted.
There's one other basic element found in logic IC's, the buffer. Buffers have a single input and output like a NOT gate, but they do not invert the signal. What would be the point in this? There are two primary uses for buffers; isolating signals from one another and driving large numbers of inputs from a single output. Because a signal only propagates from a buffer's input to it's output, (and not the other way) they can be used as one way values just like diodes, but without they forward voltage drop. The latter use is not so common these days as modern CMOS outputs can drive a few tens of CMOS inputs without any trouble.
There are two separate methods of representing logic gates in a schematic diagram, the European (DIN) symbols and the American (IEC) symbols. Both sets are in common use so it's a good idea to be familiar with either. Below is a summary of logic symbols, at least as EAGLE sees it...
Notice that a signal inversion is represented by a small circular symbol (often called a "bubble") at the base of the pin. This convention can be used for any pin, input or output, to identify the inverse nature of the signal. The NOT gate or inverter is usually drawn as a buffer with this inversion symbol on the output.
This is all very well, but how do we make these "gates" out of electronic components? Usually, we don't. This is because it's much easier and cheaper just to go and buy an integrated circuit which provides a number of the above gates. However, sometimes these ICs are not available or only a single gate is required, rather than 4 or 6. In these situations it's useful to know how to cobble together logic functions from a handful of discrete components.
First up, the AND gate:
If both inputs A and B are high then the diodes block the input signals and the resistor pulls the output high. If any input is low then the output is forced low, or rather 0.6V above the voltage on the low input. The number of inputs can be expanded by cascading more diodes.
Now the OR gate:
As long as both inputs are held low the output is pulled low by the resistor. If either input is driven high then the output is also force high (less the forward voltage drop of the diode). As with the AND gate the number of inputs can be expanded by adding more diodes. Both of the circuits above are very similar because the function of the AND and OR gates are identical with the polarity of the input and output signals reversed.
The NOT gate:
The NOT gate is a simple transistor inverter. When the input is low little or no current flows into the transistor's base and it doesn't conduct, leaving the output to be pulled high by the resistor. When the input is high, the transistor conducts and pulls the output down to ground.
Finally, the XOR gate:
The requirement to only propagate one input exclusively makes the XOR gate somewhat more more complicated. The two diodes with their anodes connected to the circuit inputs along with the resistor connected to ground form an OR gate much like the one above. As long as neither or only one of the inputs is high then this OR gate determines the state of the output. The two diodes with their cathodes connected to the inputs form an AND gate connected to the base of the transistor. When both inputs go high the transistor base is pulled high by the resistor and the output is forced low as the transistor conducts. The extra diode connected to the transistor's base is to remove the offset voltage from the AND gate. Without this the transistor could partially conduct with the base lead 0.6V higher than the lowest input. Note that this circuit cannot easily be expanded by adding more diodes because a triple input XOR gate is still expected to give a low output with two inputs high.
The NAND, NOR and XNOR gates can be made by combining the above circuits for the AND, OR and XOR gate with the transistor inverter NOT gate.
There are a few drawbacks to these particular discrete logic gates which are worth noting:
The basic logic gates discussed so far along with a whole raft of other digital functions are available in cheap and easy to use integrated circuits. In the hope of one day finishing writing this page, I'll focus primarily on the two most common series; the TTL 7400 series and the CMOS 4000 series.
The 7400 series first appeared some half a century ago and is still widely used today. The first ICs were based on bipolar transistors, probably much like the above discrete circuits but with transistor buffers on the output pins. These parts were quite slow by modern standards, were limited to driving a few inputs from an output and required excessive power to operate. In more recent times a variety of sub-families have arrived on the scene offering many improvements. A few of these are listed below. The part numbers always take on the firm of 74xxxxnn where xxxx denotes the logic family listed below with up to four upper case letters, and nn denotes the part itself with at least two numerals. For example, 74HC04 is a hex inverter (part number 7404) of the HC variant.
A military grade series was released along with the 7400s boasting wider operating temperature ranges and lower failure rates. These parts have the prefix 54 rather than 74 but are otherwise functionally equivalent. Initially, all 7400 and 5400 parts operated only from 5V although a few of the more recent variants have different supply ranges.
The question of exactly what "fast" means is a bit subjective. Given that parts of the same variant but from different manufacturers may vary in performance it's generally best to look at the datasheet for exact figures. For the average hobbyists, any variant will likely work fine provided it meets the power supply requirements.
The 4000 logic series appeared a little later and is also still widely used. These parts are purely CMOS resulting in significantly lower power usage (at the time of their release anyway) and the advantage of operating at any supply voltage in the range of 4-18V. Only two families were ever made; the 4000A and 4000B. The A version had unbuffered outputs which results in limited fanout (the number of inputs that a given output can drive) and to the best of my knowledge is no longer produced.
For some unfathomable reason, some manufacturers offer 7400 series parts in a 4000 series pinout. These parts are designated 74xxxxnnnn, where xxxx is the logic family from the list above and nnnn is a 4000 series part number. For example, 74HC4066.
A few examples of how gates are usually packaged into ICs:
7400 Quad NAND Gate
7404 Hex Inverter
7427 Triple 3-Input NOR Gate
7420 Dual 4-Input NAND
As a point of interest it is possible to create any logic gate from various combinations of the NAND and NOR gates. This may not seem immediately useful, but it just so happens that NAND gates are usually the easiest and cheapest to manufacture and this approach is often used when fabricating logic components. Just in case you have a lifetime supply of NAND chips (or just happen to be interested), here's how it's done.
It's also possible to do this with NOR gates, although not with the same circuit layouts.
The 7400 and 4000 logic series also includes a multitude of more complicated digital devices beyond the basic logic gates described so far. These include (but are by no means limited to) things like binary adders, shift registers, flip-flops, counters, latches, multiplexers and line decoders. Each of the series mentioned contain over a hundred parts, more than can be comprehensively covered here. Feel free to contact me if you want to know about a specific part although you may find quicker answers in the part datasheets. Google is your friend.
7483 4-bit Binary Adder
7476 Dual J-K Flip Flops
If you have any comments or questions please don't hesitate to contact me.
|Return To Top||Last Updated: 11/03/2007||Home Page|