introduction to how electronic gates work

Upload: moses-abiodun

Post on 06-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Introduction to How Electronic Gates Work

    1/14

    Introduction to How Electronic Gates Work

    If you have read the HowStuffWorks article on Boolean logic, then you know that digital devices depend

    on Boolean gates. You also know from that article that one way to implement gates involves relays.

    However, no modern computer uses relays -- it uses "chips."

    What if you want to experiment with Boolean gates and chips? What if you would like to build your own

    digital devices? It turns out that it is not that difficult. In this article, you will see how you can

    experiment with all of the gates discussed in the Boolean logic article. We will talk about where you can

    get parts, how you can wire them together, and how you can see what they are doing. In the process,

    you will open the door to a whole new universe of technology.

    Setting the Stage

    A solderless breadboard

    In the article How Boolean Logic Works, we looked at seven fundamental gates. These gates arethe building blocks of all digital devices. We also saw how to combine these gates together intohigher-level functions, such as full adders. If you would like to experiment with these gates soyou can try things out yourself, the easiest way to do it is to purchase something called TTLchips and quickly wire circuits together on a device called a solderless breadboard. Let's talk alittle bit about the technology and the process so you can actually try it out!

    If you look back at the history of computer technology, you find that all computers are designedaround Boolean gates. The technologies used to implement those gates, however, have changeddramatically over the years. The very first electronic gates were created using relays. Thesegates were slow and bulky. Vacuum tubes replaced relays. Tubes were much faster but they

    were just as bulky, and they were also plagued by the problem that tubes burn out (like lightbulbs). Once transistors were perfected (transistors were invented in 1947), computers startedusing gates made from discrete transistors. Transistors had many advantages: high reliability,low power consumption and small size compared to tubes or relays. These transistors werediscrete devices, meaning that each transistor was a separate device. Each one came in a littlemetal can about the size of a pea with three wires attached to it. It might take three or fourtransistors and several resistors and diodes to create a gate.

  • 8/3/2019 Introduction to How Electronic Gates Work

    2/14

    In the early 1960s, integrated circuits (ICs) were invented. Transistors, resistors and diodescould be manufactured together on silicon "chips." This discovery gave rise to SSI (small scaleintegration) ICs. An SSI IC typically consists of a 3-mm-square chip of silicon on which perhaps20 transistors and various other components have been etched. A typical chip might contain fouror six individual gates. These chips shrank the size of computers by a factor of about 100 and

    made them much easier to build.

    As chip manufacturing techniques improved, more and more transistors could be etched onto asingle chip. This led to MSI (medium scale integration) chips containing simple components,such as full adders, made up of multiple gates. Then LSI (large scale integration) alloweddesigners to fit all of the components of a simple microprocessoronto a single chip. The 8080processor, released by Intel in 1974, was the first commercially successful single-chipmicroprocessor. It was an LSI chip that contained 4,800 transistors. VLSI (very large scaleintegration) has steadily increased the number of transistors ever since. The first Pentiumprocessor was released in 1993 with 3.2 million transistors, and current chips can contain up to20 million transistors.

    In order to experiment with gates, we are going to go back in time a bit and use SSI ICs. Thesechips are still widely available and are extremely reliable and inexpensive. You can buildanything you want with them, one gate at a time. The specific ICs we will use are of a familycalled TTL (Transistor Transistor Logic, named for the specific wiring of gates on the IC). Thechips we will use are from the most common TTL series, called the 7400 series. There areperhaps 100 different SSI and MSI chips in the series, ranging from simple AND gates up tocomplete ALUs (arithmetic logic units).

    The 7400-series chips are housed in DIPs (dual inline packages). As pictured on the right, a DIPis a small plastic package with 14, 16, 20 or 24 little metal leads protruding from it to provideconnections to the gates inside. The easiest way to construct something from these gates is toplace the chips on a solderless breadboard. The breadboard lets you wire things together simplyby plugging pieces of wire into connection holes on the board.

    All electronic gates need a source of electrical power. TTL gates use 5 volts for operation. Thechips are fairly particular about this voltage, so we will want to use a clean, regulated 5-voltpower supply whenever working with TTL chips. Certain other chip families, such as the 4000series of CMOS chips, are far less particular about the voltages they use. CMOS chips have theadditional advantage that they use much less power. However, they are very sensitive to staticelectricity, and that makes them less reliable unless you have a static-free environment to workin. Therefore, we will stick

  • 8/3/2019 Introduction to How Electronic Gates Work

    3/14

    Assembling Your Equipment

    In order to play with TTL gates, you must have several pieces of equipment. Here's a list of whatyou will need to purchase:

    y A breadboardy A volt-ohm meter (also known as a multimeter)y A logic probe (optional)y A regulated 5-volt power supplyy A collection ofTTL chips to experiment withy Several LEDs (light emitting diodes) to see outputs of the gatesy Several resistors for the LEDsy Some wire (20 to 28 gauge) to hook things together

    These parts together might cost between $40 and $60 or so, depending on where you get them.

    Let's walk through a few details on these parts to make you more familiar with them:

    y As described on the previous page, a breadboard is a device that makes it easy to wireup your circuits.

    y A volt-ohm meter lets you measure voltage and current easily. We will use it to makesure that our power supply is producing the right voltage.

    y The logic probe is optional. It makes it easy to test the state (1 or 0) of a wire, but youcan do the same thing with an LED.

    A resistor and an LED

    y Of the parts described above, all are easy except the 5-volt power supply. No one seemsto sell a simple, cheap 5-volt regulated power supply. You therefore have two choices.

    You can either buy a surplus power supply from Jameco (for something like a videogame) and use the 5-volt supply from it, or you can use a littlepower-cube transformerand then build the regulator yourself. We will talk through both options below.

    y An LED (light emitting diode) is a mini light bulb. You use LEDs to see the output of agate.

    y We will use the resistors to protect the LEDs. If you fail to use the resistors, the LEDswill burn out immediately.

    y

  • 8/3/2019 Introduction to How Electronic Gates Work

    4/14

    This equipment is not the sort of stuff you are going to find at the corner store. However, it is nothard to obtain these parts. You have a few choices when trying to purchase the components listedabove:

    1. Radio Shack2.

    A local electronics parts store - Most major cities have electronics parts stores, and manycities are blessed with good surplus electronics stores. If you can find a good surplusstore in your area that caters to people building their own stuff, then you have found agoldmine.

    3. A mail-order house like Jameco - Jameco has been in business for decades, has a goodinventory and good prices. (Be sure to download their PDF catalog or get a paper catalogfrom them -- it makes it much easier to traverse the Web site.)

    The following table shows you what you need to buy, with Jameco part numbers listed.

    Part Jameco #

    Breadboard 20722

    Volt-ohm meter 119212

    Logic probe (optional) 149930

    Regulated 5-volt power supply See below

    7400 (NAND gates) 48979

    7402 (NOR gates) 49015

    7404 (NOT gates) 49040

    7408 (AND gates) 49146

    7432 (OR gates) 50235

    7486 (XOR gates) 50665

    5 to 10 LEDs 94529*

    5 to 10 330-ohm resistors 30867

    Wire (20 to 28 gauge) 36767

    For the Power Supply (optional)

    (See next section for details)

    Part Jameco #

    Transformer (7 to 12 volts, 300ma) 149964

    7805 5-volt voltage regulator (TO-220 case) 51262

    2 470-microfarad electrolytic capacitors 93817

  • 8/3/2019 Introduction to How Electronic Gates Work

    5/14

    Notes

    y *Jameco also has "assorted LEDs" (or grab bags) that are much cheaper on a per-LEDbasis. Look around and see what's available. This is one place where a surplus electronicsshop will have much better prices.

    y If you are shopping at Jameco, you may want to get two or three of each chip just in case-- they only cost about 30 cents each. You might also want to purchase an extra 7805 ortwo.

    y You will also need a pair ofwire cutters and wire strippers. In a pinch, you can usescissors and your fingernails, but having the proper tool makes it easier. You can get wirecutters and wire strippers at Jameco, Wal-mart, Radio Shack, and tons of other places. Ialso find that a small pair ofneedle nose pliers is helpful at times.

    The Power Supply

    Using a Volt-Ohm MeterA volt-ohm meter (multimeter) measures voltage, current and resistance. It has two "leads"(wires), one black and one red. What we want to do with the meter right now is learn how tomeasure voltage. To do this, find a AA, C or Dbattery to play with (not a dead one). We will useit as a voltage source.

    Every meter is different, but in general, here are the steps to get ready to measure a battery'svoltage:

    1. Take your black test lead and insert it in the hole marked (depends on the meter)"Common," "Com," "Ground," "Gnd" or "-" (minus).2. Take your red test lead and insert it in the hole marked (depends on the meter) "Volts,"

    "V," "Pos" or "+" (plus). Some meters have multiple holes for the red lead -- make sureyou use the one for volts.

    3. Turn the dial to the "DC Volts" section. There will usually be multiple voltage rangesavailable in this section -- on my meter, the ranges are 2.5 volts, 50 volts, 250 volts and1,000 volts (fancy auto-ranging meters may set the range for you automatically). Yourmeter will have similar ranges. The battery will have a voltage of 1.25 volts, so find theclosest voltage greater than 1.25 volts. In my case, that is 2.5 volts.

    Now, hold the black lead to the negative terminal of the battery and the red lead to the positiveterminal. You should be able to read something close to 1.25 volts off the meter. It is importantthat you hook the black lead up to negative and the red lead up to positive and stay in the habit ofdoing that. Now you can use the meter to test your power supply, as well. Change the voltagerange if necessary and then connect the black lead to ground and the red lead to what youpresume to be the positive 5-volt wire. The meter should read 5 volts.

  • 8/3/2019 Introduction to How Electronic Gates Work

    6/14

    You will definitely need a regulated 5-volt power supply to work with TTL chips. Asmentioned previously, neither Radio Shack nor Jameco seem to offer a standard, inexpensive 5-volt regulated power supply. One option you have is to buy from Jameco something like partnumber 116089. This is a 5-volt power supply from an old Atari video game. If you look in theJameco catalog, you will find that they have about 20 different surplus power supplies like this,

    producing all sorts ofvoltages and amperages. You need 5 volts at at least 0.3

    amps (300milliamps) -- you need no more than 2 amps, so do not purchase more power supply than youneed. What you can do is buy the power supply, then cut off the connector and get access to the5-volt and ground wires. That will work fine, and is probably the easiest path. You can use yourvolt meter (see below) to make sure the power supply produces the voltage you need.

    Your alternative is to build a 5-volt supply from a little power-cube transformer. What youneed is a transformer that produces 7 to 12 DC volts at 100 milliamps or more. Note that:

    y The transformer MUST produce DC voltage.y It MUST produce 7 to 12 volts.y

    It MUST produce 100 milliamps (0.1 amps) or more.

    You may have an old one lying around that you can use -- read the imprint on the cover andmake sure it meets all three requirements. If not, you can purchase a transformer from RadioShack or Jameco.

    Radio Shack sells a 9-volt 300-milliamp transformer (part number 273-1455). Jameco has a 7.5-volt 300-milliamp model (part number 149964). Clip the connector off the transformer andseparate the two wires. Strip about a centimeter of insulation off both wires. Now plug thetransformer in (once it is plugged in, NEVER let the two wires from the transformer touch oneanother or you are likely to burn out the transformer and ruin it). Use your volt meter (see below)

    to measure the voltage. You want to make sure that the transformer is producing approximatelythe stated voltage (it may be high by as much as a factor of two -- that is okay). Your transformeris acting like abattery for you, so you also want to determine which wire is the negative andwhich is the positive. Hook the black and red leads of the volt meter up to the transformer's wiresrandomly and see if the voltage measured is positive or negative. If it is negative, reverse theleads. Now you know that the wire to which the black lead is attached is the negative (ground)wire, while the other is the positive wire.

    Building the Regulator

    An electrolytic capacitor

  • 8/3/2019 Introduction to How Electronic Gates Work

    7/14

    To build the regulator, you need three parts:

    y A 7805 5-volt voltage regulator in a TO-220 case (Radio Shack part number 276-1770)y Two electrolytic capacitors, anywhere between 100 and 1,000 microfarads (typical Radio

    Shack part number 272-958)

    The 7805 takes in a voltage between 7 and 30 volts and regulates it down to exactly 5 volts. Thefirst capacitortakes out any ripple coming from the transformer so that the 7805 is receiving asmooth input voltage, and the second capacitor acts as a load balancer to ensure consistent outputfrom the 7805.

    The 7805 has three leads. If you look at the 7805 from the front (the side with printing on it), thethree leads are, from left to right, input voltage (7 to 30 volts), ground, and output voltage (5volts).

    To connect the regulator to the transformer, you can use this configuration:

    The two capacitors are represented by parallel lines. The "+" sign indicates thatelectrolytic capacitors are polarized: There is a positive and a negative terminal on anelectrolytic capacitor (one of which will be marked). You need to make sure you getthe polarity right when you install the capacitor.

  • 8/3/2019 Introduction to How Electronic Gates Work

    8/14

    You can build this regulator on your breadboard. To do this, you need to understand how abreadboard is internally wired. The following figure shows you the wiring:

    On the outer edges of the breadboard are two lines of terminals running the length of the board.All of these terminals are internally connected. Typically, you run +5 volts down one of themand ground down the other. Down the center of the board is a channel. On either side of thechannel are sets offive interconnected terminals. You can use your volt-ohm meter to see the

    interconnections. Set the meter's dial to its ohm setting, and then stick wires at different points inthe breadboard (the test leads for the meter are likely too thick to fit in the breadboard's holes).

    In the ohm setting, the meter measures resistance. Resistance will be zero if there is aconnection between two points (touch the leads together to see this), and infinite if there is noconnection (hold the leads apart to see this). You will find that points on the board really areinterconnected as shown in the diagram. Another way to see the connections is to pull back thesticker on the back of the breadboard a bit and see the metal connectors.

    Now connect the parts for yourregulator:

    1. Connect the ground wire of the transformer to one of the long outer strips on thebreadboard.2. Plug the 7805 into three of the five-hole rows.3. Connect ground from the terminal strip to the middle lead of the 7805 with a wire --

    simply cut a short piece of wire, strip off both ends and plug them in.4. Connect the positive wire from the transformer to the left lead (input) of the 7805.5. Connect a capacitor from the left lead of the 7805 to ground, paying attention to the

    polarity.

  • 8/3/2019 Introduction to How Electronic Gates Work

    9/14

    6. Connect the 5-volt lead of 7805 to the other long outer terminal strip on the breadboard.7. Connect the second capacitor between the 5-volt and ground strips.

    You have created your regulator. It might look like this when you are done (two views):

    In both of the above figures, the lines from the transformer come in from the left. You can seethe ground line of the transformer connected directly into the ground strip running the length ofthe board at the bottom. The top strip supplies +5 volts and is connected directly to the +5 pin ofthe 7805. The left capacitor filters the transformer voltage, while the right capacitor filters the +5volts produced by the 7805. The LED connects between the +5 and ground strips, through theresistor, and lets you know when the power supply is "on."

    Plug in the transformer and measure the input and output voltage of the 7805. You should see

    exactly 5 volts coming out of the 7805, and whatever voltage your transformer delivers going in.If you do not, then immediately disconnect the transformer and do the following:

    y Pull out the capacitors. Plug the transformer back in for a moment and see if that changedanything.

    y Make sure the ground wire and positive wire from the transformer are not reversed (ifthey are, it is likely the 7805 is very hot, and possibly fried).

    y Make sure the transformer is producing any voltage at all by disconnecting it andchecking it with your volt meter. See theprevious page tolearn how to do this.

    Once you see 5 volts coming out of the regulator, you can test itfurther and see that it is on by connecting an LED to it. You needto connect an LED and a resistorin series -- something that iseasy to do on your breadboard. You must use the resistor or theLED will burn out immediately. A good value for the resistor is330 ohms, although anything between 200 and 500 ohms willwork fine. LEDs, being diodes, have a polarity, so if your LEDdoes not light, try reversing the leads and see if that helps.

  • 8/3/2019 Introduction to How Electronic Gates Work

    10/14

    It might seem like we've had to go to a tremendous amount of trouble just to get the powersupply wired up and working. But you've learned a couple of things in the process. Now we canexperiment with Boolean gates!

    7.Playing with Boolean Gates

    If you used the table on the previous page to order your parts, you should have six different chipscontaining six different types of gates:

    y 7400 - NAND (four gates per chip)y 7402 - NOR(four gates per chip)y 7404 - NOT (six gates per chip)y 7408 - AND (four gates per chip)y 743

    2 -O

    R(four gates per chip)y 7486 - XOR(four gates per chip)

    Inside the chips, things look like this:

  • 8/3/2019 Introduction to How Electronic Gates Work

    11/14

    Let's start with a 7408 AND chip. If you look at the chip, there will normally be a dot at pin 1, oran indentation at the pin 1 end of the chip, or some other marking to indicate pin 1. Push the chipinto the breadboard so it straddles the center channel. You can see from the diagrams that on allchips, pin 7 must connect to ground and pin 14 must connect to +5 volts. So connect those twopins appropriately. (If you connect them backward you will burn the chip out, so don't connect

    them backward. If you happen to burn a chip out accidentally, throw it away so you do notconfuse it with your good parts.) Now connect an LED and resistor between pin 3 of the chip andground. The LED should light. If not, reverse the LED so it lights. Your IC should look like this:

    In this figure, the chip is receiving +5 volts on pin 14 (red wire) andground on pin 7 (black wire). The resistor leaves pin 3 and connects

    to the LED, which is also connected to ground. Connect wires from

    +5 and ground to the gate's A and B inputs to exercise the gate.

    Here is what is happening. In TTL, +5 represents a binary "1" and ground represents a binary"0." If an input pin to a gate is not connected to anything, it "floats high," meaning the gatemakes an assumption that there is a 1 on the pin. So the AND gate should be seeing 1s on boththe A and B inputs, meaning that the output at pin 3 is delivering 5 volts. So the LED lights. Ifyou ground either pin 1 or 2 or both on the chip, the LED will extinguish. This is the standardbehavior for an AND gate, as described in How Boolean Logic Works.

    Try out the other gates by connecting them on your breadboard and see that they all behaveaccording to the logic tables in the Boolean logic article. Then try wiring up something morecomplicated. For example, wire up the XOR gate, or the Q bit of the full adder, and see that theybehave as expected.

  • 8/3/2019 Introduction to How Electronic Gates Work

    12/14

    Build It!

    In theory, you now have the fundamental knowledge you need to build any digital device. Youcan take the basic gates discussed in this article and construct anything. However, it is often

    more convenient to use larger-scale devices so that you don't have to combine 50 chips to buildsomething common like an ALU. It is also helpful to see examples of different ways to combinegates to create complicated systems.

    If you would like to work on a bigger project, you can try building the digital clock described inHow Digital Clocks Work. If you want to learn more about TTL devices, the following bookswill be helpful:

    You will be AMAZED at what you can create with just a few ICs and some creativity. Have funwith it!

    For more information on electronic gates and related topics, check out the links on the next page.

    Lots More Information

    Related HowStuffWorks Articles

    y How Boolean Logic Worksy How LEDs Worky How Capacitors Worky How Digital Clocks Worky How Microcontrollers Worky How Semiconductors Worky How Electricity Worksy How Electric Motors Worky Electric Motor Quizy How Microprocessors Worky How Batteries Worky Batteries Quizy What are amps, watts, volts and ohms?

    More Great Links

    y Basic Gates and Functionsy DMOZ: Electronics Tutorialsy Introductory Digital Electronicsy y Gadget Savvy: Capacitors Quiz

  • 8/3/2019 Introduction to How Electronic Gates Work

    13/14

    y What looks like a battery, has two terminals like a battery and stores electrons like abattery? Capacitors can store and release electrical energy, but don't replenish theirsupply. How do capacitors work, and what tools rely on them? See more

    y yy Gadget Savvy: Electric Motors Quizy Electric motors are inside all kinds of ordinary devices, using a power source to make

    motion. So what makes the motor go 'round? See more

    y yy How Capacitors Worky The capacitor plays a crucial role in electronics -- it stores electrons for when they're

    needed most, dumping a huge charge instead of a steady flow. How does it doit? See more

    y yy How Circuit Breakers Worky The circuit breaker is one of the most important safety mechanisms in your home.

    Without it, the risk of fire would skyrocket. Learn how a circuit breaker keeps yourhome's electricity in check. See more

    y yy How does a brushless electric motor work?y The brushless motor is more precise than a regular electric motor and it's also a great deal

    more efficient. Learn all about brushless motors and how the invention of transistors ledto their development. See more

    y yy How Electric Motors Worky You might be surprised to find out just how much work is done by electric motors.

    They're everywhere! You'll find them in your car, your kitchen, bathroom, office... Find

    out how electric motors get stuff moving. See more

    y yy How Electronic Gates Worky Would you like to be able to build your own digital devices? Logic gates are the basis of

    digital electronics. Find out what these gates do and how you can use them to startbuilding your own devices. See more

  • 8/3/2019 Introduction to How Electronic Gates Work

    14/14

    y yy How Inductors Worky An inductor is little more than a coil of wire. Sound simple? Well, it is -- but that coil of

    wire can do some pretty cool things. Learn all about inductors and what they're usedfor. See more

    y yy How Light Emitting Diodes Worky Light emitting diodes form numbers on digital clocks, send data from remote controls,

    light up traffic signals, illuminate watches -- the simple genius of the design makes itinfinitely applicable. See more

    y yy How Microcontrollers Worky Most modern electronic devices (TVs, appliances, power tools) contain an embedded

    microcontroller. It's basically a dedicated computer. Find out how these devices work andexperiment with one on your own. See more