在这篇文章中,我们将探索上拉电阻器和下拉电阻,为什么它们通常用于电子电路,没有拉式或下拉电阻的电子电路会发生什么,以及如何计算上拉和下拉电阻值,最后我们将看到有关开放收集器配置的信息。
How Logic Inputs and Outputs Work in Digital Circuits
在数字电子和大多数基于微控制器的电路中,相关数字信号以Logic1或Logic0的形式处理,即“高”或“低”。
Digital logic gates become the fundamental units of any digital circuit, and by utilizing “AND”, “OR” and “NOT” gate we are able to build complex circuits, however as noted above digital gates can accept only two voltage levels which “HIGH” and “LOW”.
The “HIGH” and “LOW” are generally in the form of 5V and 0V respectively. “HIGH” is also referred as “1” or positive signal of the supply and “LOW” is also referred as “0” or negative signal of the supply.
当FED输入在2V和0V之间的未定义区域中时,逻辑电路或微控制器出现问题。
In such a situation a logic circuits or microcontroller may not recognize the signal properly, and the circuit will make some wrong assumptions and execute.
Generally a logic gate can recognize the signal as “LOW” if the input is below 0.8V and can recognize the signal as “HIGH” if the input is above 2V. For microcontrollers this can actually vary a lot.
未定义的输入逻辑级别
The problems arise when the signal is between 0.8V and 2V and varies randomly at the input pins, this issue can be explained with an example circuit using a switch connected to an IC or a microcontroller.
假设使用微控制器或IC的电路,如果我们关闭电路,输入引脚将“低”,继电器“打开”。
If we open the switch, the relay should turn “OFF” right? Well not really.
We know that the digital ICs and digital microcontrollers only takes input as either “HIGH” or “LOW”, when we open the switch, the input pin is just open circuited. It is neither “HIGH” nor “LOW”.
输入引脚必须“高”才能关闭中继,但是在开放情况下,该引脚很容易受到流浪拾音器,流浪静态电荷和其他周围的电气噪声的影响,这可能会导致继电器继续下去随机。
To prevent such random triggers due to stray voltage, in this example it becomes mandatory to tie the shown digital input pin to a “HIGH” logic, so that when the switch is flipped off, the pin automatically connects to a defined state “HIGH” or the positive supply level of the IC.
To keep the pin “HIGH” we can connect the input pin to Vcc.
In the below circuit the input pin is connected to Vcc, which keeps the input “HIGH” if we open the switch, which prevents random triggering of the relay.
You may think, now we have the solution worked out. But no....not yet!
As per the diagram if we close the switch there will be short circuit and shut off and short circuit the whole system. Your circuit can never have any worst situation than a short circuit.
The short circuit is due to very large current flowing through a low resistance path which burns the PCB traces, blowing of fuse, triggering safety switches and even may cause fatal damage to your circuit.
To prevent such heavy current flow and also to keep the input pin in “HIGH” condition, we can utilize a resistor which is connected to Vcc, that is between the "red line".
In this situation the pin will be in a “HIGH” state if we open the switch, and on closing the switch there won’t be any short circuit, and also the input pin is allowed to directly connect with the GND, making it “LOW”.
If we close the switch there will be negligible voltage drop via the pull-Up resistor and rest of the circuit will remain unaffected.
One must choose the Pull-Up / Pull-Down resistor value optimally so that it won’t draw excess through the resistor.
Calculating Pull-Up Resistor value:
To calculate an optimum value, we have to know 3 parameters: 1) Vcc 2) Minimum threshold input voltage which can guarantee to make the output “HIGH” 3) High level input current (The required current). All these data are mentioned in the datasheet.
Let’s take the example of logic NAND gate. According to its datasheet Vcc is 5V, minimum threshold input voltage (High level Input voltage VIH) is 2V and High level input current (IIH) is 40 uA.
By applying ohm’s law we can find the correct resistor value.
R = Vcc - VIH (MIN)/ IIH
Where,
Vcc is the operating voltage,
VIH (MIN)is HIGH Level Input voltage,
IIH是高级输入电流。
Now let’s do the matching,
R = 5 - 2 / 40 x 10^-6 = 75K ohm.
We can use a resistor value maximum of 75K ohm.
NOTE:
This value is calculated for ideal conditions, but we don’t live in an ideal world. For best operation you may connect a resistor slightly lower than calculated value say 70K, 65k or even 50K ohm but don’t reduce the resistance low enough that it will conduct huge current for example 100 ohm, 220 ohm for the above example.
多门上拉电阻
In the above example, we saw how to pick a Pull-up resistor for one gate. What If we have 10 gates which all are need to be connected to Pull-Up resistor?
One of the ways is to connect 10 Pull-Up resistors at each of the gate, but this isn’t cost effective and easy solution. The best solution would be connecting all the input pins together to single Pull-Up resistor.
To calculate the Pull-Up resistor value for the above condition follow the formula below:
R = Vcc - VIH (MIN)/ N x IIH
The “N” is the number of gates.
You will notice that the above formula is the same as the previous one; the only difference is multiplying the number of gates.
So, let’s do the math again,
R = 5 -2 / 10 x 40 x 10^-6 = 7.5K ohm (maximum)
Now for the 10 NAND gates, we got the resistor value in a way that the current is 10 times higher than one NAND gate (In previous example), so that the resistor can maintain minimum of 2V at peak load, which can guarantee the required output without any error.
You can use the same formula for calculating Pull-Up resistor for any application.
Pull-Down Resistors:
上拉电阻使销如果没有“高”put is connected; with Pull-down resistor, it keeps the pin “LOW” if no input is connected.
The pull-down resistor is made by connecting the resistor to ground instead of Vcc.
The Pull-Down can be calculated by:
R = VIL (MAX)/ IIL
Where,
VIL (MAX)is LOW level input voltage.
IILis LOW level input current.
所有这些参数都datashee中提到t.
R = 0.8 / 1.6 x 10 ^-3 = 0.5K ohm
We can use maximum of 500 ohm resistor for Pull-down.
But again, we should use a resistor value less than 500 ohms.
Open collector output / Open Drain:
We can say a pin is “open collector output” when the IC can’t drive the output “HIGH” but can only drive its output “LOW”. It simply connects the output to the ground or disconnect from ground.
We can see how the open collector configuration is made in an IC.
由于输出是接地或开路,因此我们需要连接一个外部上拉电阻,该电阻在晶体管关闭时可以将销钉“高”转动。
This is same for Open drain; the only difference is that the internal transistor inside the IC is a MOSFET.
Now, you may ask why do we need an open drain configuration? We need to connect a Pull-Up resistor anyway.
好吧,可以通过在开放收集器输出处选择不同的电阻值来改变输出电压,从而为负载提供了更大的灵活性。我们可以在具有较高或更低工作电压的输出处连接负载。
如果我们具有固定的上拉电阻值,我们将无法控制输出处的电压。
One disadvantage of this configuration is that, it consumes huge current and may not be battery friendly, it need higher current for its correct operation.
Let’s take example of IC 7401 open drain logic “NAND” gate and see how to calculate pull-up resistor value.
We need to know the following parameters:
VOL(MAX)which is the maximum input voltage to IC 7401 which can guarantee to turn the output “LOW” (0.4V).
IOL(MAX)这是低水平输入电流(16mA)。
VCC是5V的工作电压。
So, we here we can connect a Pull-Up resistor value around 287 ohm.
有任何疑问吗?请使用下面的评论框来表达您的想法,您的查询将尽快回答
How to rewire xl6009 with pull up pull down on a xl6009 buck booster ? Where coul I find a diagram ?
Why would you need a pull up or pull down resistor in xl6009?