Even this relatively simple circuit arrangement has subtleties that affect performance.
In the crisp, clean, theoretical binary world, signals exist in only two unambiguous states, generally called 1 and 0 (one and zero). However, when engineering students, hobbyists, and digital-only professionals get into the hands-on real world of circuits and systems, they find that binary circuits have three states: 1, 0, and undefined (or indeterminant).
That last state is undesirable and can lead to circuit and system malfunctions, erratic operation, and even hard faults, so it must be avoided in nearly all designs. Fortunately, that is fairly easy to accomplish. Note that technically, “binary” is a specific case and subset of “digital,” but the two terms are often used interchangeably.
This FAQ will explore the role of pull-up and pull-down resistors to ensure that the binary (digital) circuit points are indisputably at an unambiguous 1 or 0 level and that the intermittent state cannot occur. These resistors are often used when interfacing a switch or other components with microcontroller input/output (I/O) pins or other digital gates. Many microcontrollers include them, but others do not, allowing interface flexibility.
Q: What is the reality of a digital-circuit logic level?
A: A digital logic circuit actually has three logic states: high, low, and “floating” (or high impedance); the latter is indeterminate. When probed with a meter, it may appear as a high or low or alternate between them randomly, but that is misleading, and it is not a valid logic-level reading.
Q: Is this a problem for circuit inputs as well as outputs?
A: Yes, you can have a floating input or output. They may have different “appearances” and impacts despite having the same underlying cause.
Q: Are there basic principles to keep in mind when looking at logic levels in real circuits?
A: Yes, there are two: 1) electrical current needs a path to flow, and 2) voltage only has meaning when defined between two known points. Of course, voltage and current coexist and interact, and you need to understand the actions of one to understand the other.
Q: Do concerns about a floating signal in a circuit relate to both input and output points?
A: Yes. Input is either the base of a bipolar transistor or the gate of a CMOS transistor (Figure 1), where the output driving base or gate is from another IC, or it could be a discrete mechanical switch. The concerns are very similar in both input and output cases.
Pull-up versus pull-down resistors
Q: What is a pull-up resistor? What is a pull-down resistor?
A: A pull-up resistor is a resistor used to ensure that a circuit point is “pulled” to a high logic level in the absence of an input signal; a pull-down resistor ensures that the circuit point goes too low (almost always “ground” or common). These resistors are used to correctly bias the inputs of digital gates to stop them from floating randomly. They are also used on the outputs of digital gates.
Q: Can we see this “in action?”
A: Consider a simple on/off pushbutton switch connected to the input of a logic gate (remember, gates in the real world are built of bipolar or CMOS transistors; they are not some abstract concept). Electrically, the switch looks like a short or open circuit — simple enough.
If there is no pull-up resistor (Figure 2), the logic-gate input is floating and not at 1 or 0 when the switch is open; when the switch is closed, the input is hard-connected to ground, logic 0.
Consider the same input but with a pull-up resistor (Figure 3).
When the switch is open, the voltage at the gate input is pulled up to the level of the input voltage (designated as Vin, VCC, VDD, or the supply rail, depending on the circuit design and its designer) and is at logic 1. When the switch is closed, the input voltage at the gate goes directly to the ground.
In short, you must use a pull-up resistor when you have a low default impedance state and wish to pull the signal to ‘high.’
Q: This all makes sense for a “hard” contact-closure on/off switch, but how does it apply to an input being driven by the output of another digital-logic gate?
A: If you draw the schematic and model the circuit, it’s a very similar situation. When the driving output is low, there is a low impedance to ground, almost but not quite a short circuit; when the output is high, there is a high-impedance path and virtually no current flow, appearing almost as an open circuit.
Q: What about pull-down resistors on inputs?
A: It’s the same principle except as its complement (Figure 4). When the switch is open, the voltage of the gate input is pulled down to the ground level. When the switch is closed, the input voltage at the gate goes to Vin. The voltage levels would virtually float between the two voltages without the resistor. The pull-down resistor holds the logic signal near zero volts (0 V) as it pulls the input voltage down to the ground to prevent an undefined state at the input.
Q: Can you briefly compare and contrast pull-up and pull-down resistor arrangements?
A: Figure 5 is a brief overview of their relative attributes.
Q: What about pull-up and pull-down on the output side of a gate or even a basic transistor?
A: It’s a similar problem. If the output collector or drain is connected to “nothing,” it will float and be unable to attain a true logic of 0 or 1, as there is no current path. For this reason, most logic gates have a built-in pull-up or pull-down output resistor.
Q: Why do I sometimes see gates with “open collector” or “open drain” outputs?
A: This is needed when you want the transistor’s output to drive an external, “real-world” load. The open-collector output refers to an output connected to the collector of the transistor (here, an NPN device) (Figure 6). The NPN transistor allows the sinking of current to ground (more correctly called circuit common).
By using an open collector or drain, you can make the load function as the pull-up resistor. The load can be a discrete resistor, relay, motor, lamp, LED, or other component.
The next section discusses sourcing and sinking current, as well as resistor sizing.
Related EE World content
What is an open drain?
FAQ: How to wire a switch to a microcontroller with pullup resistors
150-V fast high-side-protected N-channel MOSFET driver provides 100% duty cycle
Choosing the right encoder – open-collector, push-pull or differential output?
When to use NPN and PNP transistors and FETs
Why I still like electromechanical relays – and you should, too (maybe)
External references
Sparkfun, “Pull-up Resistors”
Circuit Basics, “Pull-up and Pull-down Resistors”
Wikipedia, “Pull-up resistor”
EE Power, “Pull-up and Pull-down Resistors”
Utmel Electronic, “What are the Differences Between Pull up and Pull down Resistors?”
Electronics Tutorials, ”Pull-up Resistors”
Robu.in, “What are Pull-up and Pull-down resistors?”