Chapter 11
IN THIS CHAPTER
Corralling components onto a chip
Speaking the language of bits
Thinking logically about gates
Reading into IC packages
Pondering IC pinouts
Boosting signals with op amps
Timing, counting, and controlling everything in sight
Space exploration, programmable pacemakers, consumer electronics, and much more would be nothing but the idle dreams of creative minds were it not for the integrated circuit (IC). This incredible innovation — really, a series of incredible innovations — makes possible your smartphone, tablet, iPod, and GPS navigation system, as well as newer disruptive technologies, such as 3D printing and autonomous (self-driving) vehicles. Who knows? One day ICs may enable you to 3D-print your own driverless car!
An integrated circuit incorporates anywhere from a few dozen to many billions (yes — billions!) of circuit components into a single device that fits easily into the palm of your hand. Each IC contains an intricate mesh of tiny transistor-based taskmasters, with access to the outside world provided by a finite number of inputs and outputs.
This chapter explores how integrated circuits came to be, identifies the three major IC flavors, and dissects the inner workings of one variety — digital ICs. You get a look at how computers and other digital devices manipulate two distinct voltage levels to process information using special rules known as logic. Next up is an explanation of how to read an IC to understand what the heck it does (because you can’t tell by its cover) and how to connect it for use in circuits. Finally, you get a closer look at three best-selling ICs, what they do, and how you can use them to create your own innovative circuits.
The integrated circuit (IC) was invented in 1958 (see the sidebar, “The birth of the IC”) to solve the problems inherent in manually assembling mass quantities of tiny transistors. Also called chips, integrated circuits are miniaturized circuits produced on a single piece of semiconductor. A typical integrated circuit contains hundreds of transistors, resistors, diodes, and capacitors; the most advanced ICs contain several billion components. Because of this circuit efficiency, you can build complex circuits with just a few parts. ICs are the building blocks of larger circuits. You string them together to form just about any electronic device you can think up.
Over the years, chip makers have come out with lots of different ICs, each of which performs a specific function depending on how the components inside are wired. Many of the integrated circuits you encounter are so popular they have become standardized, and you can find a wealth of information about them online and in books. A lot of different chip makers offer these standardized ICs, and manufacturers and hobbyists the world over buy and use them in various projects. Other special-purpose ICs are designed to accomplish a unique task. More often than not, only a single company sells a particular special-purpose chip.
Whether standardized or special-purpose, you can separate ICs into three main categories: linear (analog), digital, and mixed signal. These terms relate to the kinds of electrical signals (more about those Chapter 10) that work in the circuit:
When you first learned to add numbers, you memorized facts such as “2 + 2 = 4” and “3 + 6 = 9.” Then, when you learned to add multi-digit numbers, you used those simple facts as well as a new one — “carrying” numbers to us older folks, “regrouping” numbers to the younger generation. By applying a few simple addition facts and one simple rule, you can add two large numbers together fairly easily.
In this section, you get a look at how digital logic circuits work.
When you add two digits together, you have ten choices for each digit (0 through 9) because that’s how our numbering system (known as a base 10, or decimal, system) works. When a computer adds two digits together, it uses only two possible digits: 0 and 1 (this is known as a base 2 or binary system). Because there are only two, these digits are known as binary digits, or bits. Bits can be strung together to represent letters or numbers — for instance, the bit string 1101 represents the number 13. The sidebar “Adding bits of numbers” offers a glimpse of how this process works.
In addition to representing numbers and letters, bits can be used also to carry information. As information carriers, data bits are versatile. They can represent many two-state (binary) things: a screen’s pixel is either on or off; a CTRL key is either up or down; a laser pit is either present or absent on a DVD surface; an ATM transaction is either authorized or not; and much more. By assigning logical values of 1 and 0 to a particular on/off choice, you can use bits to carry information about physical events — and allow that information to control other things by processing the bits in a digital circuit.
Logic gates, or simply gates, are tiny digital circuits that accept one or more data bits as inputs and produce a single output bit whose value (1 or 0) is based on a specific rule. In the same way that different arithmetic operators produce different outputs for the same two inputs (for instance, three plus two produces five, while three minus two produces one), different types of logic gates produce different outputs for the same inputs:
Figure 11-1 shows the circuit symbols for these common logic gates.
You usually find multiple logic gates sold in integrated circuits, such as an IC containing four two-input NAND gates (called a quad 2-input NAND gate), as shown in Figure 11-2. The package sports pins that connect to each gate’s inputs and output, as well as other pins that connect a power supply to the circuitry. Look on the website of the IC’s manufacturer for a datasheet that tells you which pins are inputs, outputs, V+ (voltage), and ground. (A datasheet is like a user’s manual; it provides technical specifications and performance information about the chip.)
You may see labels in addition to V+ for the positive power supply pin on an IC. Different chip manufacturers use different conventions, but it’s common to see VDD used in CMOS chips and VCC used in TTL chips (see Figure 11-2). Refer to the sidebar “Meet the logic families” for details on CMOS and TTL.
Tracking all the 0 and 1 inputs to logic gates and the outputs they produce can get a bit confusing — especially for gates with more than two inputs — so designers use a tool called a truth table to keep things organized. This table lists all the possible combinations of inputs and corresponding outputs for a given logical function.
Figure 11-3 shows the truth tables for the NOT (inverter), AND, NAND, OR, NOR, XOR, and XNOR logic gates, along with labeled symbols for each gate. Each row in the truth table represents a logic statement. For instance, the second row in the NAND truth table is really telling you the following:
You can use truth tables also for other digital circuits, such as a half-adder circuit, which is designed to add two bits and produce an output consisting of a sum bit and a carry bit. For instance, for the binary equation 1 + 1 = 10, the sum bit is 0 and the carry bit is 1. The truth table for the half adder is shown in Figure 11-4.
If you look at the carry-bit column in the truth table for the half adder, you may notice that it looks just like the output for the two-input AND gate shown in Figure 11-3: That is, the carry bit is the same as A AND B, where A and B are the two input bits. Similarly, the sum bit is the same as A XOR B. What’s the significance of this? You can build a half adder using an AND gate and an XOR gate. You feed the input bits into both gates, and use the AND gate to generate the carry bit and the XOR gate to generate the sum bit. (See Figure 11-5.)
By connecting several adders together in just the right way, you can create a larger digital circuit that takes two multi-bit inputs, such as 10110110 and 00110011, and produces their sum, 11101001. (In decimal notation, that sum is 182+51=233.)
You can create loads of other complex functions by combining multiple AND, OR, and NOT gates. It’s all a matter of which gates you use and how you interconnect them. Think about forming words from letters. With just 26 different choices, you can create millions of words. Likewise, you can create circuits that perform math functions (such as adders, multipliers, and many others) by connecting a whole bunch of gates in the right combination.
Over the years, digital circuit designers have perfected the design of adders and other commonly used digital circuits, figuring out clever ways to speed up the computation time, reduce power dissipation, and ensure that the results are accurate, even under harsh circuit conditions such as extreme temperatures. Tried-and-true digital circuit designs are commonly turned into standardized IC product offerings — so you and other circuit builders don’t have to re-create the wheel over and over again.
Integrated circuits are nothing like discrete components — such as individual resistors, capacitors, and transistors — which have two or more leads connected directly to the component inside the package. The miniature prebuilt components inside an IC are already interconnected in one big happy circuit, ready to perform a specific task. You just have to add a few ingredients — say, power and one or more input signals — and the IC will do its thing. Sounds simple, right? Well, it is. You just have to know how to read IC packages — because they all look like black multilegged critters — so you know how to make the right connections.
Every IC has a unique code, such as 7400 or 4017, to identify the type of device — really, the circuit — that’s inside. You can use this code, also known as a part number, to look up specifications and parameters about an IC in an online resource. The code is printed on the top of the chip.
Great things really do come in small packages. Many ICs that can fit in the palm of your hand contain incredibly complex circuitry; for example, an entire AM/FM radio circuit (minus the battery and antenna) fits in an IC package the size of a nickel. The actual circuit is so small that manufacturers have to mount it onto a reasonable-size plastic or ceramic package so humans can use it. During the process of chip assembly, leads are attached to the appropriate circuit access points and fed out of the package enclosure so you and others like you can get current flowing to, through, and from the circuit inside.
Many ICs used in hobby electronics projects are assembled into dual in-line packages (DIPs), such as the ones in Figure 11-6. DIPs (sometimes called DILs) are rectangular-shaped plastic or ceramic packages with two parallel rows of leads, called pins, down either side. DIPs contain between 4 and 64 pins, but the most common sizes are 8-, 14-, and 16-pin.
DIPs are designed to be through-hole mounted onto a printed circuit board (PCB), with the pins extending through holes in the board and soldered on the other side. You can solder DIP pins directly onto a circuit board or use sockets designed to hold the chip without bending the pins. You solder the socket connections into your circuit, and then insert the chip into the socket. DIPs also fit nicely into the contact holes of solderless breadboards (which I cover in Chapter 15), making it easy to prototype a circuit.
The pins on an IC package provide connections to the tiny integrated circuits inside, but alas, the pins are not labeled on the package so you have to rely on the datasheet for the particular IC to make the proper connections. Among other things, the datasheet provides you with the IC’s pinout, which describes the function of each pin.
To determine which pin is which, you look down on the top of the IC (not up at the little critter’s underbelly) for the clocking mark, which is usually a small notch in the packaging but might instead be a little dimple or a white or colored stripe. (Some ICs have multiple marks.) By convention, the pins on an IC are numbered counterclockwise, starting with the upper-left pin closest to the clocking mark. So, for example, with the clocking notch orienting the chip at the 12 o’clock position, the pins of a 14-pin IC are numbered 1 through 7 down the left side and 8 through 14 up the right side, as shown in Figure 11-7.
Many circuit diagrams (schematics) indicate the connections to integrated circuits by showing an outline of the IC with numbers beside each pin. The numbers correspond to the counterclockwise sequence of the device’s pins, as viewed from the top. (Remember, you start with 1 in the upper left and count up as you go counterclockwise around the chip.) You can use these kinds of diagrams to easily wire an IC because you don’t need to look up the device in a book or a datasheet. Just make sure that you follow the schematic and that you count the pins properly.
If a schematic lacks pin numbers, you need to find a copy of the pinout diagram. For standard ICs, you can find these diagrams online; for nonstandard ICs, you have to visit the manufacturer’s website to get the datasheet.
IC datasheets are like owner’s manuals, providing detailed information about the insides, outsides, and recommended use of an integrated circuit. They are created by the IC manufacturer and are usually several pages long. Typical information contained in a datasheet includes
Many datasheets include sample circuit diagrams, illustrating how to use the IC in a complete circuit. You can get lots of guidance and good ideas from IC datasheets. Sometimes it really pays to read the owner’s manual!
In this section, you find out firsthand how to make the right connections to a NAND logic gate IC, and you watch the output change as you fiddle around with various combinations of inputs. Then you find out how to create another type of logic gate, an OR gate, by combining NAND gates in just the right way.
Here are the parts you need to build the two circuits in this section:
The circuit in Figure 11-8 uses an LED to indicate the high (1) or low (0) state of the output of a two-input NAND gate.
Set up the circuit using Figure 11-9 as a guide and noting the following important information:
The 74HC00 IC is a high-speed CMOS chip that is sensitive to static, so be sure to review the precautions outlined in Chapter 13 to avoid damaging the chip, and insert the IC last — but before you apply power — when you build the circuit, as suggested in Chapter 15.
When you close one of the switches, you make that input high because you connect the positive power-supply voltage to the input. When you open one of the switches, you make that input low because it’s connected through a resistor to ground (0 V).
Test the functionality of the NAND gate by trying all four combinations of open and closed switches, filling in the chart given here (which is essentially a truth table).
Input 1 |
Input 2 |
Output (High = LED on; Low = LED off) |
Low (SW1 open) |
Low (SW2 open) |
|
Low (SW1 open) |
High (SW2 closed) |
|
High (SW1 closed) |
Low (SW2 open) |
|
High (SW1 closed) |
High (SW2 closed) |
Did you see the LED light up when either or both switches were open? Did the LED turn off when both switches were closed? Be sure to tell the truth!
You can combine several NAND gates to create any other logical function. In the circuit in Figure 11-10, three NAND gates are combined to create an OR gate. The inputs to the OR gate are controlled by switches SW3 and SW4. The output of the OR gate is indicated by the on/off state of the LED.
Each of the two NAND gates on the left functions as a NOT gate (or inverter). Each NAND gate ties the inputs together so that a low input produces a high output, and a high input produces a low output. The NAND gate on the right produces a high output when either or both of its inputs are low, which happens when either or both switches (SW3 and SW4) are closed. The bottom line is that if either or both switches are closed, the output of the circuit is high. That’s an OR gate!
Set up the circuit, being careful to avoid static. You can use the remaining three NAND gates on the 74HC00 IC that you used to build the circuit in Figure 11-9. Figure 11-11 shows the circuits in Figure 11-8 and 11-10 set up together using a single 74HC00. Try not to get your wires crossed!
Test the functionality by opening and closing the switches. The LED should turn on when either or both switches are closed.
You can find a seemingly endless supply of integrated circuits on the market today, but two in particular are known far and wide for their outstanding versatility and ease of use: the operational amplifier (really a class of ICs) and the 555 timer. It pays to get to know these two circuits fairly well if you intend to get even remotely serious about developing your electronics habit.
In this section, I describe these two popular ICs and one additional IC, the 4017 CMOS decade counter. You encounter the 555 timer IC and the 4017 decade counter IC in projects in Chapter 17, so the upcoming sections provide a quick rundown on how they work.
The most popular type of linear (analog) IC is undoubtedly the operational amplifier, nicknamed the op amp, which is designed to add muscle to (that is, amplify) a weak signal. An op amp contains several transistors, resistors, and capacitors, and offers more robust performance than a single transistor. For example, an op amp can provide uniform amplification over a much wider range of frequencies (bandwidth) than can a single-transistor amplifier.
Most op amps come in 8-pin DIPs (as shown in Figure 11-12), and include two input pins (pin 2, known as the inverting input, and pin 3, known as the non-inverting input) and one output pin (pin 6). An op amp is one type of differential amplifier: The circuitry inside the op amp produces an output signal that is a multiple of the difference between the signals applied to the two inputs. Used a certain way, this setup can help eliminate noise (unwanted voltages) in the input signal by subtracting it out of what’s amplified.
You can configure an op amp to multiply an input signal by a known gain factor that is determined by external resistors. One such configuration, known as an inverting amplifier, is shown in Figure 11-13.
The values of the resistors connected to the op amp determine the gain of the inverting amplifier circuit:
The negative sign indicates that the input signal is flipped, or inverted, to produce the output signal. Say, for instance, that the value of R2 is 10 kΩ and that of R1 is 1 kΩ. The gain is –10. With a gain of –10, a 1 V input signal (peak value) produces an inverted 10 V (peak) output signal.
To use the inverting amplifier, you just apply a signal (for instance, the output of a microphone) between the input pins. The signal, amplified several times, then appears at the output, where it can drive a component, such as a speaker.
Gobs of different op amps are available at prices ranging from just a few cents for standard op-amp ICs, such as the LM741 general-purpose op amp, to $10 or more for high-performance op amps.
One of the most popular and easy-to-use integrated circuits is the versatile 555 timer, introduced in 1971 and still in wide use today, with more than one billion units produced every year. This little workhorse can be used for a variety of functions in both analog and digital circuits, most commonly for timing (ranging from microseconds to hours), and is the cornerstone of many projects you can build (as you see in Chapter 17).
Figure 11-14 illustrates the pin assignments for the 555 timer. Among the pin functions are
By connecting a few resistors, capacitors, and switches to the various pins of the 555 timer, you can get this little gem to perform loads of different functions — and it’s remarkably easy to do. You can find detailed, easy-to-read information about its various applications on datasheets. I discuss three popular ways to configure a timing circuit using a 555 here.
The 555 can behave as an astable multivibrator, which is just a fancy term to describe a sort of electronic metronome. By connecting components to the chip (as shown in Figure 11-15), you configure the 555 to produce a continuous series of voltage pulses that automatically alternate between low (0 volts) and high (the positive supply voltage, VCC), as shown in Figure 11-16. (The term astable refers to the fact that this circuit does not settle down into a stable state, but keeps changing on its own between two different states.) This self-triggering circuit is also known as an oscillator.
You can use the 555 astable multivibrator for lots of fun things:
The frequency f (in hertz), which is the number of complete up-and-down cycles per second, of the square wave produced is determined by your choice of three external components, according to this equation:
If you flip the numerator and dominator in that equation, you get the time period (T), which is the length of time (in seconds) of one complete up-and-down pulse:
You can set up your circuit so that the width of the high part of the pulse is different from the width of the low part of the pulse. To find the width of the high part of the pulse (expressed as Thigh), use the following equation:
You find the width of the low part of the pulse (expressed as Tlow) like this:
If R2 is much, much bigger than R1, the high and low pulse widths will be fairly equal. If R2=R1, the high portion of the pulse will be twice as wide as the low portion. You get the idea.
To choose values for R1, R2, and C1, I suggest you follow these steps:
For instance, one way to produce a pulse that is high for about 3 seconds and low for about 1.5 seconds is to use a 10 μF capacitor for C1 and 220 kΩ resistors for both R1 and R2. (Plug those values into the equations for Thigh and Tlow and see for yourself!)
By configuring the 555 timer as shown in Figure 11-17, you can use it as a monostable multivibrator that generates a single pulse when triggered. This configuration is sometimes called a one-shot. Without a trigger, this circuit produces a low (zero) voltage; this is its stable state. When triggered by closing the switch between pin 2 and ground, this circuit generates an output pulse at the level of the supply voltage, VCC. The width of the pulse, T, is determined by the values of R1 and C1, as follows:
If an astable circuit has no stable state and a monostable circuit has one stable state, what’s a bistable circuit? If you guessed that a bistable circuit is a circuit with two stable states, you are correct.
The 555 bistable multivibrator shown in Figure 11-18 produces alternating high (VCC) and low (0 V) voltages, switching from one state to the other only when triggered. Such a circuit is commonly known as a flip-flop. There’s no need to calculate resistor values; activating the trigger switch controls the timing of the pulses generated.
You can witness firsthand how a 555 timer works as a flip-flop by building the circuit shown in Figure 11-19. Here are the parts you need:
Set up the circuit, using Figure 11-20 as your guide. Note that one end of the SPDT switch is connected to pin 2 (trigger) of the 555 timer, the other end is connected to pin 4 (reset) of the 555 timer, and the center terminal is connected to ground. Depending on the position of the slider on the SPDT switch, the switch either triggers or resets the 555 timer.
After you set up the circuit, slide the switch to the trigger position. Does the LED light? Does it stay lit as long as you leave the switch in the trigger position? Now slide the switch to the reset position. Does the LED go off and stay off as long as the switch is in the reset position?
The 4017 CMOS decade counter shown in Figure 11-21 is a 16-pin IC that counts from 0 to 9 when triggered. Pins 1–7 and 9–11 go from low to high one at a time when a trigger signal is applied to pin 14. (They don’t go from low to high in strict counterclockwise order; you have to check the pinout to determine the order.) You can use the count outputs to light LEDs (as in the light chaser and traffic light projects in Chapter 17) or trigger a one-shot that controls another circuit.
Counting can take place only when the disable pin (pin 13) is low; you can disable counting by applying a high signal to pin 13. You can also force the counter to reset to zero (meaning that the zero-count output, which is pin 3, goes high) by applying a high signal to pin 14.
One of the most versatile integrated circuits you can find is the microcontroller. A microcontroller is a small, complete computer on a chip. To program it, you place it on a development board that allows the IC to interface with your personal computer. After it’s programmed, you mount the microcontroller into a socket on your electronic device (which could be a solderless breadboard). You add a few other components to provide an interface between the microcontroller and LEDs, motors, or switches — and voilà! Your little programmed IC makes things happen (for instance, it can control the motion of a robot). The nice thing about a microcontroller is that you can simply alter a few lines of code (or reprogram it completely) to change what it does; you don’t need to swap out wires, resistors, and other components to get this flexible IC to take on a new personality.
Hundreds of microcontrollers are available, but a handful are geared specifically for first-timers. Some, such as the one shown on the PCB in Figure 11-22, can be purchased as part of a complete development package: You get a pre-assembled printed circuit board populated with the microcontroller IC, discrete components, and standard connectors so that you can connect the microcontroller to a circuit during operation or to your computer for programming. Many of these kits also include an integrated development environment (IDE), which contains software tools for programming the microcontroller. (See Chapter 18 for more on microcontroller kits.)
Among the other common functions provided by ICs are mathematical operations (addition, subtraction, multiplication, and division), multiplexing (selecting a single output from among several inputs), and the conversion of signals between analog and digital:
Of course, the microprocessor that runs your personal computer (and maybe even your personal life) is also quite popular as ICs go.
There are so many more integrated circuits than I can possibly cover in this book. Really smart circuit designers are always coming up with new ideas and improvements on some old ideas, so there are a lot of choices in the world of integrated circuits.
18.224.38.3