How to solve the pull-up resistor problem of pin microcontroller?

Publisher:VelvetDreamerLatest update time:2014-01-16 Source: 电源网 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The pins of a microcontroller can be controlled by a program to output high or low levels, which can be considered the output voltage of the microcontroller. However, the program cannot control the output current of the microcontroller. The output current of the microcontroller depends largely on the external devices on the pins.

When the microcontroller outputs a low level, external devices are allowed to input current into the microcontroller pins. This current is called "injection current" and the external circuit is called "injection current load" . When the microcontroller outputs a high level, external devices are allowed to pull current out from the microcontroller pins. This current is called "source current" and the external circuit is called "source current load".

What are the typical currents? What is the maximum limit? This is a common question about the output drive capability of a microcontroller.

The load capacity of the early 51 series microcontrollers was very small, and was only described by "how many TTL inputs it could drive". Each pin of the P1, P2 and P3 ports can drive 3 TTL inputs, and only the P0 port has a strong capacity, which can drive 8!

If we analyze the input characteristics of TTL, we can find that the 51  MCU basically has no driving ability. Its pins can't even drive the LEDs at that time to emit light normally. I remember that it was only after the AT89C51 MCU became popular that we found that the ability of the MCU pins was greatly enhanced and could directly drive the LEDs to emit light.

From the PDF manual of the AT89C51 microcontroller, we can see that the upper limit of the "sink current" in steady-state output is:

Maximum IOL per port pin: 10 mA;

Maximum IOL per 8-bit port

port 0: 26mA,Ports 1, 2, 3: 15mA;

Maximum total I for all output pins: 71 mA.

Here it says:

When each single pin outputs a low level, the external circuit is allowed to sink a maximum current of 10 mA into the pin; each 8-bit interface (P1, P2 and P3) allows a maximum total current of 15 mA to be injected into the pin, while P0 is more capable and allows a maximum total current of 26 mA to be injected into the pin; the maximum sum of the currents allowed by all four interfaces is 71 mA.

When these pins "output high level", what about the "current source" capability of the microcontroller? It can be said to be too poor, less than 1 mA.

The conclusion is: when the microcontroller outputs a low level, the driving capability is acceptable, but when it outputs a high level, it has no ability to output current. This conclusion is based on the data given in the manual.

These characteristics of the 51 microcontroller are derived from the internal structure of the pins. I will not draw a diagram of the internal structure of the pins here, as it can be found in many books.

Inside the chip, there is a transistor between the pin and the ground, so the pin has the ability to pull down, and when the output is low, it allows 10mA of current to be injected; and there is an "internal pull-up resistor" of several hundred K between the pin and the positive power supply, so when the pin is at a high level, the pull-up current that can be output is very small. Especially for the P0 port, there is no pull-up resistor inside, so the P0 port has no ability to output high-level current.

Oh, I see. If the external circuit is a "current-pulling load" and requires the microcontroller to function when outputting a high level, then a "pull-up resistor" must be used to assist in generating the current required by the load.

The following discussion will specifically talk about the problems with pull-up resistors.

As mentioned above, D2 emits light due to the current provided by the pull-up resistor R2. The voltage when D2 is turned on is about 2V, so the current is: (5 - 2) / 1K, which is about 3mA.

When the microcontroller outputs a low level (0V) and D2 does not emit light, is the pull-up resistor R2 idle? No! The voltage across it is higher than when the LED emits light, now it is 5V, and the current is 5mA! Have you noticed? When the LED does not emit light, the pull-up resistor gives a larger current! And this current, which is greater than the normal light-emitting current, is all poured into the pins of the microcontroller! If 8 1K pull-up resistors are installed in an 8-bit interface, when the microcontroller outputs a low level, a current of 40mA will be poured into this 8-bit interface! If four 8-bit interfaces are all equipped with 1K pull-up resistors, the maximum possible current is 32 × 5 = 160mA, all flowing into the microcontroller! This value has exceeded the upper limit given in the microcontroller manual. If the microcontroller is unstable at this time, it is natural.

Moreover, these currents appear when the load is in an invalid state. They are completely useless currents and only cause heat, high power consumption, fast battery consumption and other consequences.

Especially now, energy conservation, emission reduction and low carbon are being advocated.

So, can we make the pull-up resistor larger?

The answer is: No, because it is needed to provide current for the current-pulling load. For LEDs, if the resistance is increased, the current will be too small, the light will be dim, and the function of the light-emitting diode will be lost.

For D1, it is a current sinking load. When the microcontroller outputs a low level, there will be current sinking in the R1 and D1 paths. When the microcontroller outputs a high level, there will be no current, and no additional power consumption will be generated.

In summary, current sinking load is reasonable, while "current pulling load" and "pull-up resistor" will generate a lot of invalid current, and this circuit is unreasonable. Some netizens have a special liking for pull-up resistors, and they want to install a pull-up resistor on the pin, whether it is useful or not, and they can even give some reasons: stability and speed.

In fact, "pull-up resistors" and "current pull-up load" circuits will cause adverse consequences to the microcontroller system. I have read many books and reference materials about microcontroller pins and pull-up resistors, but basically they have not discussed the disadvantages of using pull-up resistors in detail.

Here, Zuoerlundao solemnly proposes to everyone: When designing the load circuit of the microcontroller , the circuit form of "current injection load" should be used to avoid unnecessary current consumption. The pull-up resistor is only considered at the P0 port: when the P0 port is used as an input port, it needs to be added; when the P0 port is used to output a high level to drive a MOS type load, it also needs to be added. At other times, the P0 port does not need to add a pull-up resistor. Pull-up resistors should not be added to other interfaces (P1, P2 and P3), especially when the output is valid at a low level, the external device has the function of pull-up.

Reference address:How to solve the pull-up resistor problem of pin microcontroller?

Previous article:FPGA microcontroller shows you how to implement multi-machine serial communication network
Next article:"Power failure" cannot be ignored. The single-chip microcomputer system provides conditions for circuit protection

Latest Power Management 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号