Detailed explanation and selection of pull-up resistors and pull-down resistors for microcontrollers

Publisher:神雕Latest update time:2018-11-19 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 I. Definition


1. Pull-up means clamping the uncertain signal at a high level through a resistor! "The resistor also acts as a current limiter"! The same applies to pull-down!


2. Pull-up is to inject current into the device, and pull-down is to output current


3. Weak and strong are just different in the resistance value of the pull-up resistor, there is no strict distinction


4. For non-collector (or drain) open-circuit output circuits (such as ordinary gate circuits), the ability to increase current and voltage is limited. The function of the pull-up resistor is mainly to output the current channel for the collector open-circuit output circuit.


2. Pull-up resistor function


1. Generally, when used as a single-key trigger, if the IC itself does not have an internal resistor, in order to keep the single key in an untriggered state or return to the original state after being triggered, a resistor must be connected outside the IC.


2. Digital circuits have three states: high level, low level, and high resistance. In some applications, high resistance is not desirable. Pull-up resistors or pull-down resistors can be used to stabilize the circuit, depending on the design requirements.


3. Generally speaking, I/O ports are referred to as ports. Some can be set, some cannot be set, some are built-in, and some need to be connected externally. The output of the I/O port is similar to the C of a transistor. When C is connected to the power supply through a resistor, the resistor becomes the C pull-up resistor, that is to say, if the port is normally at a high level; when C is connected to the ground through a resistor, the resistor is called a pull-down resistor, making the port usually at a low level. What is its function? For example: "When a port connected to a pull-up resistor is set to input state, its normal state is high level, which is used to detect low level input".


4. Pull-up resistors are used to provide current when the bus driving capability is insufficient. Generally speaking, it is called pulling current, and pull-down resistors are used to absorb current, which is what we usually call sinking current.


5. Connecting a resistor is to prevent the input terminal from being left floating


6. Reduce the interference of external current on the chip


7. Protect the protection diode in CMOS, the current is generally not more than 10mA


8. Increase or decrease the drive current by pulling up or down


9. Potential that changes the level, commonly used in TTL-CMOS matching


10. There is a certain state when the pin is floating


11. Increase the driving capability at high level output.


12. Provide current for OC gate


3. Application principles of pull-up resistors


1. When the TTL circuit drives the COMS circuit, if the high level output by the TTL circuit is lower than the lowest high level of the COMS circuit (usually 3.5V), then it is necessary to connect a pull-up resistor to the output end of the TTL to increase the value of the output high level. ……………………..


2. The OC gate circuit "must be added with a pull-up resistor before it can be used."


3. In order to increase the driving capability of the output pins, pull-up resistors are often used on some microcontroller pins.


4. On COMS chips, in order to prevent damage caused by static electricity, unused pins cannot be left floating. Generally, pull-up resistors are connected to reduce input impedance and provide a discharge path.


5. Add pull-up resistors to the chip pins to increase the output level, thereby improving the noise tolerance of the chip input signal and enhancing anti-interference capabilities.


6. Improve the anti-electromagnetic interference capability of the bus. If the pin is left floating, it is more susceptible to external electromagnetic interference.


7. Resistance mismatch in long-line transmission can easily cause reflected wave interference. Adding a pull-down resistor can achieve resistance matching and effectively suppress reflected wave interference.


8. In digital circuits, unused input pins must be connected to a fixed level and connected to a high level or ground through a 1k resistor.


4. Pull-up resistor value selection principle


1. Considering the power saving and the current sinking capability of the chip, it should be large enough; the larger the resistance, the smaller the current.


2. It should be small enough to ensure sufficient driving current; small resistance means large current.


3. For high-speed circuits, excessively large pull-up resistors may cause the edge to become flat.


The above three points are usually selected between 1k and 10k. The same is true for pull-down resistors.


The selection of pull-up resistors and pull-down resistors should be "set in combination with the switch characteristics and the input characteristics of the lower circuit, mainly considering the following factors":


1. Balance between driving capability and power consumption. Taking the pull-up resistor as an example, generally speaking, the smaller the pull-up resistor, the stronger the driving capability, but the greater the power consumption. The design should pay attention to the balance between the two.


2. Driving requirements of the lower circuit. Taking the pull-up resistor as an example, when the output is high, the switch tube is disconnected, and the pull-up resistor should be appropriately selected to provide sufficient current to the lower circuit.


3. Setting of high and low levels. The threshold levels of high and low levels of different circuits will be different, and the resistors should be set appropriately to ensure that the correct level can be output. Taking the pull-up resistor as an example, when the output is low level, the switch tube is turned on, and the voltage divider value of the pull-up resistor and the switch tube on resistance should be ensured to be below the zero level threshold.


4. Frequency characteristics. Taking the pull-up resistor as an example, the capacitance between the pull-up resistor and the drain-source level of the switch tube and the input capacitance between the lower circuit will form an "RC delay". The larger the resistance, the greater the delay. The setting of the pull-up resistor should take into account the circuit's needs in this regard.


The principle of setting the pull-down resistor is the same as that of the pull-up resistor.


When the OC gate outputs a high level, it is in a high-impedance state, and its pull-up current is provided by a pull-up resistor. Assume that the input current of each port is no more than 100uA, and the output port driving current is about 500uA. The standard operating voltage is 5V, and the high and low level thresholds of the input port are 0.8V (lower than this value is a low level); 2V (high level threshold value).


When selecting a pull-up resistor: 500uA x 8.4K = 4.2, that is, when it is greater than 8.4K, the output end can be pulled down to below 0.8V. This is the minimum resistance value. If it is smaller, it cannot be pulled down. If the output port driving current is large, the resistance value can be reduced to ensure that it can be lower than 0.8V when pulled down. When the output is high, ignoring the leakage current of the tube, the two input ports require 200uA, 200uA x15K = 3V, that is, the pull-up resistor voltage drop is 3V, and the output port can reach 2V. This resistance value is the maximum resistance value. If it is larger, it cannot pull 2V. Select 10K for use. [Maximum voltage drop/maximum current, minimum voltage drop/minimum current]


The COMS gate can refer to the 74HC series. The leakage current of the tube cannot be ignored when designing. The actual current of the IO port is also different at different levels. The above is just the principle. It can be summarized in one sentence: "When outputting a high level, feed the input port behind it, and when outputting a low level, do not feed the output port too much" (otherwise, the excess current will be fed to the cascade input port, and it will be unreliable if it is higher than the low level threshold value)


In addition, the following points should be noted:


A. It depends on what device the output port drives. If the device requires a high voltage and the output voltage of the output port is not enough, a pull-up resistor needs to be added.


B. If there is a pull-up resistor, its port is at a high level by default. If you want to control it, you must use a low level to control it, such as the collector of a transistor in a three-state gate circuit, or the anode of a diode to control the current of the pull-up resistor to a low level.


C. Especially used in interface circuits, in order to obtain a certain level, this method is generally used to ensure the correct circuit state to avoid accidents. For example, in motor control, the upper and lower bridge arms of the inverter bridge cannot be directly connected. If they are driven by the same microcontroller, the initial state must be set. Prevent direct connection!


Try to use current sinking for driving.


When selecting a resistor, choose the one that is closest to the standard value after calculation!


The reasons why P0 needs a pull-up resistor are:


1. There is no pull-up resistor inside the P0 port


2. When P0 is in the I/O port working state, the upper FET is turned off, so the output pin is floating, so when P0 is used as an output line, it is an open drain output.


3. Since there is no pull-up resistor on the chip and the upper FET is turned off, the port level cannot be pulled up when P0 outputs 1.


P0 is a bidirectional port, and the others P1, P2, and P3 are quasi-bidirectional ports. The quasi-bidirectional port is because it needs to be "prepared" before reading external data. Why is it necessary to prepare?


When the microcontroller reads the port of a bidirectional port, it should first assign 1 to the port latch in order to turn off the FET so that the port is not clamped at a low level due to the on-chip FET being turned on.


Generally choose 10k for pull up and down!


Keywords:MCU Reference address:Detailed explanation and selection of pull-up resistors and pull-down resistors for microcontrollers

Previous article:Metal tracking car based on MSP430F5529
Next article:About the status of STC microcontroller IO port

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号