DIGITAL CIRCUITS**

Image

Thus far, we’ve covered two aspects of computing. First, computers work in a binary system of 0s and 1s. Second, computers are electronic devices built upon electrical circuits. Now it’s time to bring those two aspects of computing together. In this chapter we define what it means for an electrical circuit to be digital. We look at approaches for implementing digital circuits, including the role that transistors play. Finally, we examine logic gates and integrated circuits, the building blocks of more complex components that we’ll cover in the chapters ahead.

What Is a Digital Circuit?

You may have noticed that the circuits we built in the previous chapter weren’t digital—they were analog. In those circuits, voltage, current, and resistance could vary over a wide range of values. That isn’t surprising; our world is naturally analog! However, computers work in the digital realm, and to understand computers we need to understand circuits that are digital. If we want our circuits to be digital, we must first define what that means in the context of electronics, and then we can use analog components to build a digital circuit.

Digital circuits deal with signals that represent a limited number of states. This book deals with binary digital circuits, so 0 and 1 are the only two states to consider. We typically use voltage to represent a 0 or 1 in a digital circuit, where 0 is a low voltage and 1 is a high voltage. Usually low means 0V, and high tends to be 5V, 3.3V, or 1.8V, depending on the design of the circuit. In reality, digital circuits don’t need a precise voltage to register as high or low. Instead, usually a range of voltages registers as high or low. For example, in a nominal 5-volt digital circuit, an input voltage of anywhere between 2V and 5V registers as high, and anywhere between 0V and 0.8V is considered low. Any other voltage level results in undefined behavior in the circuit and should be avoided.

Usually ground is the lowest voltage in a digital circuit, and all other voltages in that circuit are positive compared to ground. If a digital circuit is battery powered, we consider the negative terminal of the battery to be ground. The same goes for other kinds of DC power supplies; the negative terminal or wire is considered ground.

When referring to the 0 and 1 states in digital circuits, lots of terms and abbreviations get thrown around that all mean the same thing. These terms are often used interchangeably. Here are some common terms for low and high:

Low voltage    Low, LO, off, ground, GND, false, zero, 0

High voltage    High, HI, on, V+, true, one, 1

Logic with Mechanical Switches

Now that we’ve established that high and low voltages represent 1 and 0 in our digital circuit, let’s consider how we can build a digital circuit. We want a circuit where the input and output voltages are always a predetermined high or low value, or at least within an allowable range. To help us accomplish this, let’s bring in a circuit element that’s very simple and familiar: a mechanical switch. A switch is useful because it’s digital in nature. It’s on or off. When the switch is on, it acts like a simple copper wire through which current flows freely. When the switch is off, it acts like an open circuit and no current can flow. We represent a switch with the symbol shown in Figure 4-1 .

image

Figure 4-1: The circuit diagram symbol for a switch—open/off (left), closed/on (right)

The switch symbol conveys the idea that a switch is an open circuit when in the off position, and the switch is a closed circuit when in the on position. You can think of the switch symbol, and a switch itself, as being like a fence gate that’s either open or closed. Current flows through a switch when it’s closed. In the real world, switches come in various shapes and sizes, as seen in Figure 4-2 .

image

Figure 4-2: Some electrical switches

Note that in Figure 4-2 , two of the switches, those closest to us, are pushbuttons , which you might not usually think of as switches. Pushbuttons are also known as momentary switches , since the switch is closed only while the button is pressed. Removing pressure on the button opens the switch.

Now that we’ve introduced a circuit element that can easily turn on and off, let’s use switches to build a digital circuit that acts like a logical AND operator. If you remember from Chapter 2 , a two-input logical AND outputs a 1 if both inputs are 1, and a 0 otherwise. As a reminder, the truth table for AND is repeated in Table 4-1 .

Table 4-1: AND Truth Table

A B Output
0 0 0
0 1 0
1 0 0
1 1 1

Let’s now translate this to a circuit, with the following guidelines:

  1. Inputs A and B are represented by mechanical switches. We represent 0 with an open switch, and we use a closed switch to represent 1.
  2. The output is determined by voltage at a particular point in our circuit, called V out .
  3. If V out is approximately 5V, the output is a logical 1, and if V out is approximately 0V, the output is a logical 0.

Consider the circuit shown in Figure 4-3 . This is a logical AND implemented with switches.

image

Figure 4-3: A logical AND implemented with switches

If either switch in Figure 4-3 is off (open/0), no current flows and the voltage at V out is 0V. If both switches are on (closed/1), this makes a path to ground, current flows, and the voltage at V out is 5V. In other words, if both A and B are 1, then the output is 1.

Let’s take the same approach with a logical OR. The truth table for OR, first covered in Chapter 2 , is shown in Table 4-2 .

Table 4-2: OR Truth Table

A B Output
0 0 0
0 1 1
1 0 1
1 1 1

Look at the circuit shown in Figure 4-4 , a logical OR implemented with switches.

image

Figure 4-4: A logical OR implemented with switches

In Figure 4-4 , when both switches are off (open/0), no current flows and the voltage at V out is 0V, a logical 0. When either switch is turned on (closed/1), then current flows, and the voltage at V out is 5V. In other words, if A or B is 1, then the output is 1.

The Amazing Transistor

In our quest to design digital circuits, the switch-based circuits just discussed are a good conceptual start. However, in computing devices, we can’t practically use mechanical switches. The inputs to a computer are numerous, and flipping switches to control those inputs isn’t a great design. Also, computing devices need to connect multiple logical circuits together—the output of one circuit needs to become the input of another. To accomplish this, our switches need to be electrically, rather than mechanically, controlled. We don’t want a mechanical switch; we want an electronic switch. Fortunately, there’s a circuit component that can act as an electronic switch: the transistor!

A transistor is a device used to switch or amplify current. For our purposes, let’s focus on the switching capabilities of the transistor. The transistor is the basis of modern electronics, including computing devices. There are two main types of transistors: bipolar junction transistors (BJTs) and field-effect transistors (FETs). The differences between the two types aren’t relevant for our discussion here; to keep things simple, let’s focus on only one type: BJTs.

BJTs have three terminals: base, collector, and emitter. There are two types of BJTs: NPN and PNP. The two differ in the way they respond to the application of current to the base terminal. For our purposes, we focus on NPN BJTs. See Figure 4-5 for a circuit diagram and photo of an NPN transistor.

image

Figure 4-5: The symbol for (left) and photo of (right) an NPN transistor

In an NPN transistor, applying a small current at the base allows a larger current to flow from the collector to the emitter. In other words, if we think of the transistor as a switch, then applying current at the base is like turning the transistor on, and removing that current turns the transistor off. Let’s look at how a transistor can be wired as an electronic switch, as shown in Figure 4-6 .

image

Figure 4-6: An NPN transistor as a switch

In Figure 4-6 an NPN transistor is connected to a couple of resistors with various labeled voltages. V cc is a positive supply voltage applied to the collector terminal. This supplies power to our circuit. In case you are wondering, the “cc” in V cc stands for “common collector,” and V cc is the typical designation for the positive supply voltage in NPN-based circuits. V out is the voltage we wish to control; we want this voltage to be high when our transistor-as-a-switch is on and low when our switch is off. V in acts as the voltage that electrically controls our switch. Rather than flipping a mechanical device, we can use voltage V in to control our switch.

Let’s consider what happens if we set V in to either a low or high voltage. If V in is low, connected to ground, then no current flows to the base of the transistor. With no current at the base, the transistor acts like an open circuit between the collector and emitter. That means that V out is also low. Figure 4-7 illustrates this.

image

Figure 4-7: An NPN transistor as a switch in the off state

On the left in Figure 4-7 is the transistor-based circuit we’re discussing, and on the right is a switch-based circuit that represents the same state. In other words, the circuit on the left is effectively the same as the circuit on the right; I’ve just replaced the transistor with a switch to make it clear that the transistor, in this state, is like an open switch.

If V in is low, then no current flows. On the other hand, if V in is high, then a current flows to the base of the transistor. This current causes the transistor to conduct current from the collector to the emitter. That means that V out is effectively connected to V cc and so the output is high, as shown in Figure 4-8 .

image

Figure 4-8: An NPN transistor as a switch in the on state

On the left in Figure 4-8 is the transistor-based circuit we’re discussing, and on the right is a mechanical switch-based circuit with the same effective state. The transistor, in this state, is like a closed switch.

Logic Gates

Now that we’ve established that a transistor can act as an electrically controlled switch, we can build circuit elements that implement logical functions where the inputs and outputs are high and low voltages. Such components are known as logic gates . Let’s begin by taking our earlier design for an AND circuit and replacing the mechanical switches with transistors. The advantage of this is that we can alter the input to the circuit just by changing a voltage; we don’t need to flip a mechanical switch. Though mechanical switches are a good way for humans to interact with circuits, electronic switches allow multiple circuits to interact with each other—the output of one circuit can easily become the input of another.

Previously we built an AND circuit using mechanical switches (see Figure 4-3 ). Let’s use transistors as switches to accomplish the same thing, as shown in Figure 4-9 .

image

Figure 4-9: Logical AND implemented with transistors

In Figure 4-9 , if V A and V B are high (a logical 1), then current flows through both transistors and V out is also high (a logical 1). If V A or V B is low (a logical 0), then current doesn’t flow and V out is also low (a logical 0). This circuit implements a logical AND.

A similar approach can be used to implement a logical OR with transistors. I’ll leave that as a design exercise and project for you to complete.

EXERCISE 4-1: DESIGN A LOGICAL OR WITH TRANSISTORS

Draw a circuit diagram for a logical OR circuit that uses transistors for inputs A and B. Adapt the circuit in Figure 4-4 that uses mechanical switches, but use NPN transistors instead. See Appendix A for a solution.

NOTE

Please see Project #3 on page 66 , where you can build the circuits for logical AND and logical OR with transistors .

We’ve just seen how a logic gate, a circuit that implements a logical function, can be constructed with transistors and resistors. From this point forward, I am going to hide the details of how logic gates are implemented; instead we’ll consider the entire gate as a single circuit element. This isn’t just a theoretical way of looking at logic gates; it’s aligned with the way these circuit elements are used in the real world. Logic gates are available for purchase already assembled and physically packaged as a circuit component, so there’s usually no need for you to build them yourself from transistors, except as a learning exercise. Standard circuit symbols are defined for the various logic gates. You can see some of the most common ones in Figure 4-10 .

While reviewing the various logic gates in Figure 4-10 , note the small circles added to the various symbols to represent NOT or inversion. A NOT gate is the simplest example of this; it takes a single input, and its output is the inversion of that input. So, 1 becomes 0, and 0 becomes 1. The output of a NAND gate is the same as NOT AND; its output is the inversion of the output of a regular AND gate. The same is true of NOR. You’ll see the small circle crop up in other places in logic symbols to indicate NOT or inversion.

Before we move on, let’s pause here and reflect on a certain aspect of what we just covered. First, we examined how a logic gate works internally. Then we took that design, wrapped it up in a package, and gave it a name and a symbol. We deliberately obscured the implementation of the circuit, while continuing to document its expected behavior. We put the design details of the logic gate into what is known as a black box , an element where inputs and outputs are known, but the internal details are hidden. Another term for this approach is encapsulation , a design choice that hides internal details of a component while documenting how to interact with that component.

image

Figure 4-10: Common logic gates

Encapsulation is a design principle that’s found throughout modern technology. It’s used when designers of a component want others to be able to easily use their creation and build upon it without needing to fully understand the details of its implementation. This approach also allows for improvements to be made inside “the box,” and as long as the inputs and outputs continue to behave the same, the box can continue to be used as it always has been. Another advantage of encapsulation is that a team can work collaboratively on a large project, with portions of the project encapsulated. This frees individuals from needing to understand every detail of every component. Encapsulating transistors in a logic gate is the first example of encapsulation in this book, but you’ll see it multiple times as we proceed.

Designing with Logic Gates

In Chapter 2 , we saw how multiple logical operators can be combined to create more complex logical statements. Let’s now extend this idea to logic gates. Once a logical statement or truth table is written, that logic can be physically implemented in hardware using logic gates. Let’s apply this principle to the truth table we previously created ( Table 2-6 ) for the following statement:

IF it is sunny AND warm, OR it is my birthday, THEN I am going to the beach.

We simplified that to

(A AND B) OR C

Let’s now represent this statement using a diagram with logic gates, as shown in Figure 4-11 .

image

Figure 4-11: Logic gate diagram for (A AND B) OR C

If both A and B are 1, then the output of the AND gate will be 1. The output of the AND connects to the input of the OR gate, along with C. If either the AND output or C is 1, then the overall output will be 1.

When we combine logic gates in such a way that the output is a function of the present inputs, the circuit is known as a combinational logic circuit. That is, a certain set of present inputs will always produce the same output. This is in contrast to sequential logic , in which the output is a function of both present and past inputs. We’ll cover sequential logic later in this book. For now, try your hand at designing a circuit that represents the logical expression described in Exercise 4-2 .

EXERCISE 4-2: DESIGN A CIRCUIT WITH LOGIC GATES

In Chapter 2 , Exercise 2-5 , you created the truth table for (A OR B) AND C. Now build on that work and translate that truth table and logical expression into a circuit diagram. Draw a logic gate diagram (similar to the one in Figure 4-11 ) for the circuit using logic gates. See Appendix A for the answer.

Integrated Circuits

As mentioned previously, companies manufacture and sell ready-to-use digital logic gates. Hardware designers can buy these gates and start building their logic without worrying about how the gate circuits work internally. These logic gates are an example of an integrated circuit. An integrated circuit (IC) contains multiple components on a single piece of silicon in a package that has external electrical contact points, or pins . ICs are also known as chips .

In this book we primarily look at ICs that are packaged in a dual in-line package (DIP) , a rectangular enclosure with two parallel rows of pins. These pins are spaced so they can easily be used on a breadboard. Manufacturers build ICs from tiny transistors, much smaller than discrete transistors like the one shown earlier in Figure 4-5 . A discrete component is an electronic device containing only a single element, such as a resistor or transistor. ICs result in small circuits that can operate faster and are less expensive than the same circuit built from discrete transistors.

The logic circuits we discussed earlier that used resistors and transistors are known as resistor–transistor logic (RTL) circuits. Manufacturers built early digital logic circuits this way, but later they used other approaches, including diode–transistor logic (DTL), and transistor–transistor logic (TTL). The 7400 series is the most popular line of TTL logic circuits. This line of integrated circuits includes logic gates and other digital components. Introduced in the 1960s, the 7400 line and its descendants are still a standard for digital circuits. I’m going to focus on the 7400 series to give you real-world examples of how integrated circuits are used.

Let’s examine a specific 7400 series integrated circuit. The 7432 chip, shown in Figure 4-12 , contains four OR gates.

image

Figure 4-12: SN7432N integrated circuit in a dual in-line package (both), shown in a breadboard (right)

The 7432 IC comes in a package with 14 pins. Each of the four OR gates requires 3 pins, so that’s 12 pins, plus 1 pin for positive voltage (V cc ) and 1 pin for ground, giving us 14 pins in total. Speaking of voltage, the 7400 series operates with an expected V cc of 5V. That is, high voltage, a logical 1, is ideally 5V, and low voltage is 0V. However, in practice an input voltage of anywhere between 2V and 5V registers as high, and anywhere between 0V and 0.8V is considered low.

You can see in Figure 4-12 that the 7432 package has 7 pins on each side and neatly fits into a breadboard. When placing such a chip in a breadboard, be sure to place the chip so that it straddles the gap in the center of the breadboard to ensure that pins directly across from each other (example: pins 1 and 14) aren’t accidentally connected. Note the half-circle notch in the packaging; this tells you which way to orient the chip when identifying the pins.

You can see the arrangement of the circuit within the package in Figure 4-13 . This is a pinout diagram—a diagram that labels the electrical contacts, or pins, of a component. The purpose of such a diagram is to show the component’s external connection points, but usually a pinout diagram does not document the internal design of the circuit.

image

Figure 4-13: A pinout diagram showing the pin arrangement of a 7432 IC

Let’s say you want to use one of the four OR gates in the 7432 chip, and you select the gate in the lower left of the pinout diagram in Figure 4-13 , connected to pins 1, 2, and 3. To use this gate, you would connect the pins as shown in Table 4-3 .

Table 4-3: Connecting a Single OR Gate in a 7432 IC

Pin Connection
1 This is the A input of the OR gate.Connect to either 5V or GND for 1 or 0, respectively.
2 This is the B input of the OR gate.Connect to either 5V or GND for 1 or 0, respectively.
3 This is the output of the OR gate.Expect it to be either 5V or GND for 1 or 0, respectively.
7 Connect to ground.
14 Connect to a 5-volt power source.

The 7400 series contains hundreds of components. We don’t cover them all here, but in Figure 4-14 you can see the pinouts of four common logic gates available in the series. You can do a quick online search to find pinouts for other 7400 ICs.

Equipped with the pinout diagrams for each of these integrated circuits, you now have the knowledge you need to physically construct the circuit you previously designed in Exercise 4-2 .

image

Figure 4-14: Pinout diagrams for common 7400 series integrated circuits

NOTE

Please see Project #4 page 68 , where you can build a circuit that implements the logical expression (A OR B) AND C .

Summary

In this chapter, we covered binary digital circuits, circuits where we use voltage levels to represent a logical 1 or 0. You learned how switches can be used to construct logical operators, such as AND, in a physical circuit. We covered the limitations of using mechanical switches for that purpose, and we introduced a new circuit element that can act as an electrically controlled switch—the transistor. You learned about logic gates, circuit elements that implement a logical function. We covered integrated circuits, including the 7400 series.

In the next chapter we’ll explore how logic gates can be used to build circuits that handle one of the fundamental abilities of a computer—math. You’ll see how simple logic gates, when used together, allow for more complex functions. We’ll also cover the representation of integers within a computer, using signed and unsigned numbers.

PROJECT #3: BUILD LOGICAL OPERATORS (AND, OR) WITH TRANSISTORS

In this project, you’ll construct the physical circuits for a logical AND and a logical OR using transistors. To build these circuits, you’ll need the following components:

  • Breadboard (either a 400-point or 830-point model)
  • Resistors (an assortment of resistors)
  • 9-volt battery
  • 9-volt battery clip connector
  • 5mm or 3mm red LED
  • Jumper wires (designed for use in a breadboard)
  • Two transistors (Model 2N2222 in TO-92 packaging [also known as PN2222])

See “Buying Electronic Components” on page 333 for help getting these parts.

Before you begin hooking things up, you should know that some transistors and integrated circuits are electrostatic-sensitive devices , meaning they can be damaged by static discharge. Have you ever walked on carpet and then experienced a shock of static electricity when you touched something? That jolt of electricity can be fatal to electronic components. Even a static discharge too small for you to notice can damage an electronic component.

Professionals in the electronics industry avoid this problem by wearing a grounded wrist strap, by working in antistatic workspaces, and by wearing special clothing. Such precautions aren’t followed by most hobbyists, but you should at least be aware of the risk of damaging your transistors or integrated circuits from a static discharge. Try to avoid static buildup and touch a grounded surface (like the screw that holds electric outlet covers in place) to discharge any static before you handle electrostatic-sensitive devices.

Now let’s get back to the project at hand. The 2N2222 in a TO-92 package has three pins. If you hold the transistor with the flat surface facing toward you and the pins pointing down, then the left pin is the emitter, the middle pin is the base, and the right pin is the collector (see Figure 4-5 ). You can also search online for “2N2222 TO-92” for more details about this particular transistor.

Follow the diagram in Figure 4-15 to build an AND circuit with a 9-volt battery, transistors, resistors, and an LED.

image

Figure 4-15: AND circuit diagram with suggested resistors, transistors, and an output LED

A and B should be connected to either 9V (for 1) or ground (for 0) to test inputs. The LED should turn on when the expected output is 1. See Table 4-1 for the expected output given for various combinations of inputs. Remember that +9V in the diagram represents a connection to the positive terminal of the battery, and the ground symbol in the diagram represents a connection to the negative terminal of the battery. Also, remember that an LED is designed to allow current flow in only one direction, so be sure to connect the shorter pin to ground. If your circuit isn’t working as expected, check out “ Troubleshooting Circuits ” on page 340 .

The constructed circuit should look something like Figure 4-16 . Of course, your specific layout of parts on the breadboard may vary from mine.

image

Figure 4-16: The AND circuit shown in Figure 4-15 , built on a breadboard

Once you have a working AND circuit, let’s move on to a similar OR circuit. Follow the diagram in Figure 4-17 to build an OR circuit with a 9-volt battery, transistors, resistors, and an LED.

image

Figure 4-17: OR circuit with suggested resistors, transistors, and an output LED

As with the previous circuit, A and B should be connected to either 9V (for 1) or ground (for 0) to test inputs. The LED should turn on when the expected output is 1. See Table 4-2 for the expected output given for various combinations of inputs.

PROJECT #4: CONSTRUCT A CIRCUIT WITH LOGIC GATES

In Exercise 4-2 , you drew a circuit diagram for (A OR B) AND C. If you skipped that exercise, I suggest you go back and do it before continuing here. The result should be something similar to the diagram shown in Figure 4-18 .

image

Figure 4-18: Logic gate diagram for (A OR B) AND C

Now let’s physically construct that circuit! Connect the output pin to an LED (remember to include a resistor too) so that you can see if the output is 0 or 1. Your three inputs (A, B, C) can be directly connected to 5V or ground. Try connecting different combinations of the inputs to ensure your logic works as expected.

For this project, you need the following components:

  • Breadboard
  • LED
  • A current-limiting resistor to use with your LED; approximately 220Ω
  • Jumper wires
  • 7408 integrated circuit (contains four AND gates)
  • 7432 integrated circuit (contains four OR gates)
  • 5-volt power supply
  • Three pushbuttons or slide switches that will fit a breadboard (for bonus project)
  • Three 470Ω resistors (for bonus question)

Since this circuit requires a 5-volt power supply, rather than a 9-volt battery, take a look at “Powering Digital Circuits” on page 336 for some options on how to set this up. Also, as before, see “Buying Electronic Components” on page 333 for help getting these parts.

You may have noticed that the list of components recommends a 220Ω resistor rather than the 330Ω resistor we used previously. This is because we’ve lowered the source voltage from 9V to 5V. The specific value you need for your circuit will depend on the forward voltage of the LED you are using, as we covered in Chapter 3 . That said, this resistor value doesn’t have to be precise. You can use a 220Ω, 200Ω, or 180Ω resistor—all of these values are readily available. The wiring diagram in Figure 4-19 shows the details of how to construct this circuit.

Keep in mind that the pins of the chip, once placed on the breadboard, are electrically connected to an entire row. Remember to place the integrated circuits so that they straddle the gap in the center of the breadboard to ensure that pins directly across from each other aren’t accidentally connected. The completed circuit, if built on a breadboard, will look similar to the photo shown in Figure 4-20 .

image

Figure 4-19: Wiring diagram for (A OR B) AND C

image

Figure 4-20: Breadboard implementation of (A OR B) AND C with inputs A, B, and C left disconnected

Note that in Figure 4-20 the 7432 IC is on the left and the 7408 is on the right. In this particular layout the power column along the top is connected to 5V and the negative power column at the bottom is connected to ground, but neither connection is shown in the photo. Also note that inputs A, B, and C are disconnected here; they will need to be attached to ground or 5V to test various inputs.

Once you’ve constructed this circuit, you can try connecting different combinations of the inputs to ensure your logic works as expected. Connect an input to 5V to represent a logical 1, or to ground to represent a logical 0. Check the circuit’s behavior against the truth table for (A OR B) AND C shown in Table 4-4 . If your circuit isn’t working as expected, check out “ Troubleshooting Circuits ” section on page 340 .

Table 4-4: (A OR B) AND C—Truth Table

A B C Output
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1

Manually moving the input wires between ground and 5V isn’t ideal. A better design would be to connect inputs A, B, and C to mechanical switches so you can easily change the inputs without rewiring the circuit. As a bonus project, let’s add some mechanical switches to control our inputs. Your first instinct may be to hook up a switch between an input and V cc , as shown in Figure 4-21 , where closing the switch connects the input to 5V, a logical 1.

image

Figure 4-21: A switch between V cc and the input. Hint: don’t do this.

Unfortunately, there’s a problem with the approach shown in Figure 4-21 . The closed switch works as expected, but the open switch does not. You might expect an open switch to result in 0V at input A, but that isn’t necessarily the case. When the switch is open, the voltage at input A “floats” and is an unpredictable value. Remember that input A in Figure 4-21 represents the input pin of a 7432 OR gate. This input is designed to be connected to a high or low voltage; leaving it disconnected puts the logic gate in a state that is undefined. We need to wire our switch so that a predictable low voltage is present when the switch is closed. As shown in Figure 4-22 , we can do this with a pull-down resistor —a regular resistor used for the purpose of “pulling” an input low when that input isn’t connected high.

image

Figure 4-22: Use a pull-down resistor to ensure digital inputs are correct.

Let’s consider what will happen when we add a pull-down resistor as shown in Figure 4-22 . To know how the input of a 7432 integrated circuit will respond under various conditions, we can look up the voltage and current characteristics as described in the manufacturer’s data sheet. I won’t go into the details here (feel free to look online for the data sheet for your specific 7432 chip), but in summary, when the switch is open, a small current flows from input A, through the resistor, to ground.

If we use a resistor with a low value, the current flowing from input A results in a voltage at the input that is low enough to register as a logical 0. When the switch is closed, the input is directly connected to V cc and the input will be a logical 1. For 74LS series components (discussed in Appendix B ), a pull-down resistor value of 470Ω or 1kΩ usually works for logic gate inputs. I recommend those specific values since they are commonly available and meet our requirements. Values higher than 1kΩ do not reliably work as pull-down resistors for 74LS components. When you use pull-down resistors, you can build the full circuit with switches as shown in Figure 4-23 .

image

Figure 4-23: Wiring diagram for (A OR B) AND C with switches added to control the inputs

The completed circuit, if built on a breadboard, will look similar to the photo shown in Figure 4-24 . In my circuit, I used pushbuttons for switches, as seen in the lower-left corner. If you happen to look very closely, you might see that the pull-down resistors in this photo are 1kΩ, which differs from the diagram’s suggested value of 470Ω, but either will work.

image

Figure 4-24: Breadboard implementation of (A OR B) AND C

Once you’ve built your circuit as shown in Figure 4-24 , be sure to check various combinations of inputs and see if it matches the truth table for (A OR B) AND C in Table 4-4 . If your circuit isn’t working as expected, check out “ Troubleshooting Circuits ” on page 340 .