经常配制GPIO时,看到GPIO口可以pull up/down,有些不理解,正好在网上看到一些有用的东西。
Question:
by Surendar
What is the purpose of Pull up and Pull down resistors and how the absence of these will affect the circuits?
Thanks
Answers:
1.by Papabravo
The purpose of these resistors is to force an output or input to go to a defined state. This may happen for lots of different reasons. The alternative is to let that point in the circuit float. If it is an input then sometimes it will be a zero and somtimes it will be a one. Clearly an undesireable situation.
Some outputs are called "open collector" or "open drain". In these cases the pullup resistor is essential for establishing the high state. Without them the output will be stuck at zero(low).
2.by SparkMan
Pull Up/Down resistors are very important for optimized logic operation.
For example, TTL Logic:
Logic low is defined as 0.8 volts or less, but not negative. Logic High is 2.0 volts to 5 volts
Voltages higher than 0.8 and lower than 2.0 are "Undefined" or Illegal.
TTL Logic Integrated Circuits are pretty much transistors. Well, the definition is Transistor-Transistor Logic.
The inputs, when left untied to any connection, are not always at the same voltage from one to another. Meaning, however the transistor logic is designed inside the chip, determines what the voltage on the unconnected input will "float" at.
Some definitions:
Active low - For an input, a Low is required to cause a change. For an output, When the output is activated, it will be a low.
Active High - For an input, a High is required to cause a change. For an output, when the output is activated, it will be a high.
For example, a "AND" gate has 2 inputs and one output. To activate the output, both inputs need to be high (Active High). When the output is activated, it will be high.
So the output of the AND gate is only high when both inputs are high.
So where do the resistors come in?
Lets say you want to use 2 Normally open push button switches to trigger the AND gate inputs.
You would connect one end of the switches to the +5V Power supply, and the other ends to the AND inputs.
So theoretically when you push both buttons, the AND output will be high.
But that might not happen. Because the switches are normally open, you have left both inputs in an open circuit, thus they are free to go to the voltages they float at.
So if one input happens to float at 4.2 volts, then it is high, even without pussing the button, thus the logic you want, will not be what you want.
So you use "Pull-Down" resistors, and you connect them between the inputs and ground. They close the circuit and drop the voltage on the inputs to less than .8 volts, or a low.
When you hit a button, the voltage on the pin rises to above 2 volts, enough to be a high.
You also dont use 100 ohm resistors, because the current draw would be too much. You use 1k or higher, typically 5-10k or more.
Pull up resistors do the opposite, they force the inputs to be a high, or greator than 2 volts.
The same applies to outputs as well.
I know that was a lot of talking, so I'll try to simplify things:
When you are not activating any inputs, or doing anything to the circuit, basically when it's in "Standby" mode, you have designed the logic to work a certain way.
In Logic, we have whats called the "Normal" or "Standby" state of the inputs or outputs. The Pull resistors are there to help keep the inputs/outputs at the state they are supposed to be during standby.
What happens when you dont use pull resistors is you get erratic or incorrect logic operation.
3.by Papabravo
A TTL input is actually the emitter of a multiple emitter transistor. It wants to source current into some kind of load. The amount of current is a "standard TTL load" of 1.6 mA. The biggest pulldown resistor you could use would be 0.8V/1.6 mA or 500 ohms. A smaller resistor would pull the voltage to a lower value. A larger resistor would allow the input to exist in the no-mans land between 0.8V and 2.0V Another kind of current sinking load would be an NPN transistor in an open collector gate or the NPN transistor in the bottom of a totem pole output. One problem with TTL totem pole outputs is that they have a hard time sourcing current and the have a hard time getting all the way to the 5V rail.
The drawback of a pulldown in TTL is that it wastes power. It is much more common to pull TTL inputs up. Then the emitters on the inputs are not able to source current.
It's all different with CMOS. Those inputs are high impeadance; they neither sink nor source any appreciable current.
4.by SparkMan
Papabravo has added something I forgot to mention: the maximum currents, and he also mentioned "sinking" and "sourcing".
~Tries to remove dust off of the TTL theroy I learned~
If I remember correctly, sinking means current flows into an input/output, and sourcing means current flows out of the input/output.
Pull resistors are properly calculated using these values.
For inputs, 1.6mA is the sinking, and 40uA is sourcing
For outputs, 800uA is sinking, 16mA is sourcing.
I am still dusty on TTL, so there is a lot more to the calculations, but I think this will give you somewhat of an Idea.
Now to answer your questions:
When I said "when there are no inputs, the voltages they float at" I mean that the inputs are an "open circuit", meaning that electrically, there is nothing connected to them. When this occurs, the voltages on the inputs are floating (and nobody knows execatly where).
This is a schematic representation of an OR gate:
Why and where the voltages float, I don't fully remember, but as you can see, the inputs go directly to emiters of transistors, just like Papabravo said.
I don't know if this would be a correct analogy, but if you know anything about transistor amplifiers or transistor circuits, the pull resistors act kinda like biasing.
Hope that clears some things up better for you.
5.by Antseezee
Pull Up/Pull Down resistors are placed into circuits for the purpose of setting a high or low, rather than letting the pin float. Sometimes, a chip will not operate if a pin is floating because there is not a definitive voltage value. No defined voltage value means the chip receives no logic. Some pins can be left floating; depends on the data sheets.
Usually you place a VCC above the resistor, with the other end of the resistor connecting to the pin. Sometimes DIP switches or a pushbutton are placed nearby to ground. A good setup is to link ground to a DIP switch, then place a pull-up resistor right of the switch with VCC above it. This way, you can alter between a HI voltage or a LO quite easily without requiring a STDP switch.
from:"ALL ABOUT CIUCUIT"
补充:上下拉电阻阻值的选择
Most digital circuits use a 10k or a 47k resistor for pullups. The exact value doesn't actually matter, as long as it is high enough to prevent too much current from flowing. 10k seems to be the most common, but if you are hoping to save as much power as possible, the a 47k resistor may be right for your application. In some cases, you can go higher, but then you are depending on characteristics of the pins on the chip.
Most logic parts are capable of handling around 20mA of current per pin.The same holds true for most microcontrollers. This means that you need to consider carefully the device being attached.
Most LED's seem to handle at least 15mA. If you are using a 5 volt circuit, then Ohms law tells you what resistor value to use. R = V / I, so R = 5v / .015A = 333 ohms.
In Summary
You will find that pull-up resistors are extremely common is most digital circuits. The key function for a pull-up is to prevent input lines from floating. The key function for the resistor itself is to prevent too much current from flowing through the pull-up circuit.
The output from gates acts very much like a switch. When the gate is logic low, it goes to ground. Most gates can only handle about 20mA of current without burning up. You should always understand how much current will flow when the device is connected to a logic low gate.
by Surendar
What is the purpose of Pull up and Pull down resistors and how the absence of these will affect the circuits?
Thanks
Answers:
1.by Papabravo
The purpose of these resistors is to force an output or input to go to a defined state. This may happen for lots of different reasons. The alternative is to let that point in the circuit float. If it is an input then sometimes it will be a zero and somtimes it will be a one. Clearly an undesireable situation.
Some outputs are called "open collector" or "open drain". In these cases the pullup resistor is essential for establishing the high state. Without them the output will be stuck at zero(low).
2.by SparkMan
Pull Up/Down resistors are very important for optimized logic operation.
For example, TTL Logic:
Logic low is defined as 0.8 volts or less, but not negative. Logic High is 2.0 volts to 5 volts
Voltages higher than 0.8 and lower than 2.0 are "Undefined" or Illegal.
TTL Logic Integrated Circuits are pretty much transistors. Well, the definition is Transistor-Transistor Logic.
The inputs, when left untied to any connection, are not always at the same voltage from one to another. Meaning, however the transistor logic is designed inside the chip, determines what the voltage on the unconnected input will "float" at.
Some definitions:
Active low - For an input, a Low is required to cause a change. For an output, When the output is activated, it will be a low.
Active High - For an input, a High is required to cause a change. For an output, when the output is activated, it will be a high.
For example, a "AND" gate has 2 inputs and one output. To activate the output, both inputs need to be high (Active High). When the output is activated, it will be high.
So the output of the AND gate is only high when both inputs are high.
So where do the resistors come in?
Lets say you want to use 2 Normally open push button switches to trigger the AND gate inputs.
You would connect one end of the switches to the +5V Power supply, and the other ends to the AND inputs.
So theoretically when you push both buttons, the AND output will be high.
But that might not happen. Because the switches are normally open, you have left both inputs in an open circuit, thus they are free to go to the voltages they float at.
So if one input happens to float at 4.2 volts, then it is high, even without pussing the button, thus the logic you want, will not be what you want.
So you use "Pull-Down" resistors, and you connect them between the inputs and ground. They close the circuit and drop the voltage on the inputs to less than .8 volts, or a low.
When you hit a button, the voltage on the pin rises to above 2 volts, enough to be a high.
You also dont use 100 ohm resistors, because the current draw would be too much. You use 1k or higher, typically 5-10k or more.
Pull up resistors do the opposite, they force the inputs to be a high, or greator than 2 volts.
The same applies to outputs as well.
I know that was a lot of talking, so I'll try to simplify things:
When you are not activating any inputs, or doing anything to the circuit, basically when it's in "Standby" mode, you have designed the logic to work a certain way.
In Logic, we have whats called the "Normal" or "Standby" state of the inputs or outputs. The Pull resistors are there to help keep the inputs/outputs at the state they are supposed to be during standby.
What happens when you dont use pull resistors is you get erratic or incorrect logic operation.
3.by Papabravo
A TTL input is actually the emitter of a multiple emitter transistor. It wants to source current into some kind of load. The amount of current is a "standard TTL load" of 1.6 mA. The biggest pulldown resistor you could use would be 0.8V/1.6 mA or 500 ohms. A smaller resistor would pull the voltage to a lower value. A larger resistor would allow the input to exist in the no-mans land between 0.8V and 2.0V Another kind of current sinking load would be an NPN transistor in an open collector gate or the NPN transistor in the bottom of a totem pole output. One problem with TTL totem pole outputs is that they have a hard time sourcing current and the have a hard time getting all the way to the 5V rail.
The drawback of a pulldown in TTL is that it wastes power. It is much more common to pull TTL inputs up. Then the emitters on the inputs are not able to source current.
It's all different with CMOS. Those inputs are high impeadance; they neither sink nor source any appreciable current.
4.by SparkMan
Papabravo has added something I forgot to mention: the maximum currents, and he also mentioned "sinking" and "sourcing".
~Tries to remove dust off of the TTL theroy I learned~
If I remember correctly, sinking means current flows into an input/output, and sourcing means current flows out of the input/output.
Pull resistors are properly calculated using these values.
For inputs, 1.6mA is the sinking, and 40uA is sourcing
For outputs, 800uA is sinking, 16mA is sourcing.
I am still dusty on TTL, so there is a lot more to the calculations, but I think this will give you somewhat of an Idea.
Now to answer your questions:
When I said "when there are no inputs, the voltages they float at" I mean that the inputs are an "open circuit", meaning that electrically, there is nothing connected to them. When this occurs, the voltages on the inputs are floating (and nobody knows execatly where).
This is a schematic representation of an OR gate:
Why and where the voltages float, I don't fully remember, but as you can see, the inputs go directly to emiters of transistors, just like Papabravo said.
I don't know if this would be a correct analogy, but if you know anything about transistor amplifiers or transistor circuits, the pull resistors act kinda like biasing.
Hope that clears some things up better for you.
5.by Antseezee
Pull Up/Pull Down resistors are placed into circuits for the purpose of setting a high or low, rather than letting the pin float. Sometimes, a chip will not operate if a pin is floating because there is not a definitive voltage value. No defined voltage value means the chip receives no logic. Some pins can be left floating; depends on the data sheets.
Usually you place a VCC above the resistor, with the other end of the resistor connecting to the pin. Sometimes DIP switches or a pushbutton are placed nearby to ground. A good setup is to link ground to a DIP switch, then place a pull-up resistor right of the switch with VCC above it. This way, you can alter between a HI voltage or a LO quite easily without requiring a STDP switch.
from:"ALL ABOUT CIUCUIT"
补充:上下拉电阻阻值的选择
Most digital circuits use a 10k or a 47k resistor for pullups. The exact value doesn't actually matter, as long as it is high enough to prevent too much current from flowing. 10k seems to be the most common, but if you are hoping to save as much power as possible, the a 47k resistor may be right for your application. In some cases, you can go higher, but then you are depending on characteristics of the pins on the chip.
Most logic parts are capable of handling around 20mA of current per pin.The same holds true for most microcontrollers. This means that you need to consider carefully the device being attached.
Most LED's seem to handle at least 15mA. If you are using a 5 volt circuit, then Ohms law tells you what resistor value to use. R = V / I, so R = 5v / .015A = 333 ohms.
In Summary
You will find that pull-up resistors are extremely common is most digital circuits. The key function for a pull-up is to prevent input lines from floating. The key function for the resistor itself is to prevent too much current from flowing through the pull-up circuit.
The output from gates acts very much like a switch. When the gate is logic low, it goes to ground. Most gates can only handle about 20mA of current without burning up. You should always understand how much current will flow when the device is connected to a logic low gate.