Sunday, October 6, 2013

Pull-up Resistor

What is a Pull-up Resistor?

Imagine the following simple circuit:

Simple "floating" switch circuit
When the switch is closed there is a complete circuit from GPIO pin to ground.  A reading of the GPIO pin will read "low".

What happens when the switch is opened, though?  This leaves the GPIO pin in a "floating" state which is unable to determine a "high" or "low" state.  If you now read the GPIO pin, it will randomly report high and low states.

To force the GPIO pin to a "high" state, when the switch is open, we can add a very high Ohm resistor to the circuit and to the voltage source.
Simple switch circuit with Pull Up resistor

As the resistor is so high, when the switch is closed the resistor does not directly affect the rest of the circuit.  But when the switch is opened, the high resistance is better than no path and will "Pull Up" the circuit path to the voltage source, so the GPIO pin will now detect a "high" state.

Depending on if you want the opened switch circuit to be pulled up to the voltage source, or pulled down to the ground, different circuits can be built:
Input Circuits with "Pull Up" (top) and "Pull Down" (bottom) configurations

"Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected or high-impedance is introduced. When the switch is open the voltage of the gate input is pulled up to the level of Vin. When the switch is closed, the input voltage at the gate goes to ground.  A pull-up resistor weakly "pulls" the voltage of the wire it is connected to towards its voltage source level when the other components on the line are inactive. A pull-down resistor works in the same way but is connected to ground." (source)



No comments:

Post a Comment

Please be respectful.