Pull-up resistors, high impedance pins, and open collector buses

From DP

Jump to: navigation , search

[In progress] Wikipedia is a great resource, but it's not always to the point. Here's our explanation of high impedance pins, open collector buses, and pull-up resistors.


Key points


  • Normal pins (S1) switch between high (supply voltage) and low (ground)
  • Open collector pins (S2) switch between disconnected (Hi-Z) and low (ground)
  • Open collector/high impedance pins cannot output a high (1)
  • A pull-up resistor (1K to 10K ohms) holds the open collector/high impedance pin high

Pin state 101

The pins on a microcontroller and some other electronics can be switched between three states. Or tri-state, if you're fancy.


Pin is an output and connects to 0volts or ground (-, negative, Vss).

Supply voltage

Pin is an output and connects to the supply voltage

High impedance

Pin is an input, it doesn't get involved in the external circuit at all. This is called high impedance, or Hi-Z.

  • The input value of a Hi-Z pin is defined by whatever it's connected to.
  • An unconnected Hi-Z pin is called a floating pin.
  • The value of a floating pin (1 or 0) is unpredictable and undefined.

The Bus Pirate starts in Hi-Z mode with all pins as inputs. That means there's no output from the Bus Pirate that could damage a connected circuit.

Two types of switches

There are two common ways to switch a microcontroller pin, depending on the circuit.

Supply voltage<--->Ground


S1. Switches between supply (eg 3.3volts or 5volts) and ground (0volts). This switch connects to the supply voltage to output high (1), and connects to ground to output low (0).

High impedance<--->Ground


S2. Switches between supply and unconnected. In this switch the pin can connect to ground to output low (0). The other state is unconnected.

If nothing is connected the pins float. Floating pins have an undefined value that oscillates between 0 and 1 with the noise from florescent lighting in the room.

An external source has to create the high state (1) when the pin is high impedance. For this, we use a pull-up resistor (S3).

Pull-up resistors


Here's our high impedance<-->ground switch again. This time we connected it to a resistor, and the resistor is connected to the supply voltage. 1K-10K ohms are common values for pull-up resistor, the exact value is not critical.

When the switch is high impedance (an input), the a little bit of the power supply goes through the resistor and holds the pin high. This defines the high state (1), and we can say the pin is 'pulled high'. Instead of being a random 1 or 0 when we read it, it will always be 1.

When the switch is connected to ground it overcomes the small amount of current the resistor will let pass. The pin overpowers the resistor and the output is held at 0volts (ground).

Resistors are current limiting devices, and a pull-up resistor is like water in your shower:

  • A little comes out, but the water keeps flowing to the neighbors (current limiting)
  • The drain works fast enough that the shower doesn't overflow (0)
  • If the drain is plugged, the house gets soaked (1)

Open collector buses

Open collector buses are connections between electronic parts where all parts use open collector pins. The speed is highly limited by the pull-up resistor.

Common when one wire is used for bidirectional communication.

  • I2C
  • 1-wire

Useful for multi-voltage interfacing. It doesn't matter what voltage the individual parts run at, as long as the pull-up resistor is connected to a voltage that both can withstand.