Pull up and Pull Down.
Pull up and Pull down is a very simple concept.
Let's try to understand it through an example.
Let's try to understand it through an example.
Take the case of a simple NOT gate. It simply negates the input.
Input | Output |
0 | 1 |
1 | 0 |
But, What would appear at the output if the input is left unconnected? Will it be a Logic 0 or a Logic 1?
You might say that since there is no connection at the input, the voltage at the input pin would be Logic 0 and hence the output of the NOT gate shall be high.
But, have any of you ever observed an output from a not gate without any input?.
When nothing is connected to the input pin, the pin isn’t at zero volts but its “floating”. (In electronics, an unconnected input pin is termed as floating) In the digital world, particularly TTL, any floating input is considered as Logic 1. But it’s never a good idea to leave the input pins unconnected. Why? Well, that’s because noise generated by adjacent electrical activity can induce a significant amount of voltage across the input which could result in errant behavior of the system.
You might say that since there is no connection at the input, the voltage at the input pin would be Logic 0 and hence the output of the NOT gate shall be high.
But, have any of you ever observed an output from a not gate without any input?.
When nothing is connected to the input pin, the pin isn’t at zero volts but its “floating”. (In electronics, an unconnected input pin is termed as floating) In the digital world, particularly TTL, any floating input is considered as Logic 1. But it’s never a good idea to leave the input pins unconnected. Why? Well, that’s because noise generated by adjacent electrical activity can induce a significant amount of voltage across the input which could result in errant behavior of the system.
Hence, its always advisable to have a default value at the inputs. This can be achieved by connecting pull-up or pull-down resistors at the inputs.
The same logic applies while interfacing devices to the microcontroller. Most of the microcontrollers available have inbuilt pull-up resistors which can be enabled or disabled through software. These prove to be very handy while connecting external devices, say for example a switch. But, when internal pull-ups are not available, we need to connect external pull-ups. Pull-downs can also be connected, but we need to make sure that there are no internal pull-ups activated on that particular port.
In the figure above, the switch is connected in an active-low configuration. Which means whenever you press the switch, logic 0 appears at the input. Thus, the code will be written accordingly.
eg:
if (switch==0)
{
//switch pressed
}
{
//switch pressed
}
else //switch open
There are no specific values for such pull-ups or pull-downs; they could be anywhere between 1K and 47K.
( source: ThinkLabs Technosolutions)
( source: ThinkLabs Technosolutions)