The difference between push-pull output and open-drain output of microcontroller I/O port

Publisher:脑电风暴Latest update time:2013-05-30 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Push-pull output: can output high and low levels and connect digital devices;

Open drain output: The output terminal is equivalent to the collector of the transistor. A pull-up resistor is required to obtain a high level state. It is suitable for current-type driving and has a relatively strong ability to absorb current (generally within 20ma).

The push-pull structure generally refers to two transistors being controlled by two complementary signals, and one transistor is always turned on while the other is turned off.

Let's first talk about the structure of open collector output. The structure of open collector output is shown in Figure 1. The collector of the transistor on the right is not connected to anything, so it is called open collector (the transistor on the left is used for inversion, so that when the input is "0", the output is also "0"). For Figure 1, when the input on the left is "0", the front transistor is cut off (that is, the collector C and the emitter E are equivalent to being disconnected), so the 5V power supply is added to the transistor on the right through the 1K resistor, and the transistor on the right is turned on (that is, it is equivalent to a closed switch); when the input on the left is "1", the front transistor is turned on, and the back transistor is cut off (equivalent to a closed switch).

The difference between push-pull output and open-drain output of microcontroller I/O port

We simplify Figure 1 to Figure 2. The switch in Figure 2 is controlled by software and is open when "1" and closed when "0". It is obvious that when the switch is closed, the output is directly grounded, so the output level is 0. When the switch is open, the output terminal is suspended, that is, high impedance state. At this time, the level state is unknown. If a resistive load (even a very light load) is connected to the ground, the level of the output terminal will be pulled to a low level by this load, so this circuit cannot output a high level.

Let's look at Figure 3 again. The 1K resistor in Figure 3 is the pull-up resistor. If the switch is closed, current will flow through the 1K resistor and the switch, but because the switch has internal pull-ups on the other three ports, when we want to use the input function, we only need to set the output port to 1, which is equivalent to the switch being disconnected, and for the P0 port, it is in a high impedance state. [page]

For open drain (OD) output, it is very similar to open collector output. Just replace the above transistor with a field effect transistor. In this way, the collector becomes the drain, and OC becomes OD. The principle analysis is the same.

Another output structure is push-pull output. The push-pull output structure is to replace the upper pull-up resistor with a switch. When a high level is to be output, the upper switch is turned on and the lower switch is turned off; when a low level is to be output, it is just the opposite. Compared with OC or OD, such a push-pull structure has strong high and low level driving capabilities. If two output ports with different output levels are connected together, a large current will be generated, which may burn out the output port. The OC or OD output mentioned above will not have such a situation because the current provided by the pull-up resistor is relatively small. If the push-pull output is to be set to a high impedance state, the two switches must be disconnected at the same time (or a transmission gate is used on the output port), so that it can be used as an input state. Some IO ports of AVR microcontrollers have this structure.

Open-drain circuit characteristics and applications

When designing circuits, we often encounter the concepts of open drain and open collector.

The "drain" mentioned in the concept of the so-called open-drain circuit refers to the drain of the MOSFET. Similarly, the "collector" in the open-collector circuit refers to the collector of the transistor. The open-drain circuit refers to a circuit with the drain of the MOSFET as the output. The general usage is to add a pull-up resistor to the circuit outside the drain. The complete open-drain circuit should be composed of an open-drain device and an open-drain pull-up resistor. As shown in Figure 1:

The difference between push-pull output and open-drain output of microcontroller I/O port

Figure 1

The circuit that makes up the open-drain form has the following characteristics:

1. Use the driving capability of the external circuit to reduce the internal drive of the IC (or drive a load higher than the chip power supply voltage). When the internal MOSFET of the IC is turned on, the driving current flows from the external VCC through R pull-up, MOSFET to GND. Only a very low gate drive current is required inside the IC. See Figure 1.

2. Multiple open-drain output pins can be connected to one line. This forms an "AND logic" relationship. As shown in Figure 1, when any one of PIN_A, PIN_B, and PIN_C becomes low, the logic on the open-drain line becomes 0. This is also the principle of I2C, SMBus and other buses to determine the bus occupancy status. If used as an output, a pull-up resistor must be connected. When connected to a capacitive load, the falling delay is the transistor in the chip, which is an active drive with a faster speed; the rising delay is a passive external resistor with a slow speed. If high speed is required, the resistance should be small and the power consumption will be large. Therefore, the selection of load resistance should take into account both power consumption and speed.

3. You can change the transmission level by changing the voltage of the pull-up power supply. As shown in Figure 2, the logic level of the IC is determined by the power supply Vcc1, and the output high level is determined by Vcc2 (the power supply voltage of the pull-up resistor). In this way, we can use low-level logic to control the output high-level logic (so you can perform arbitrary level conversion). (For example, adding a pull-up resistor can provide TTL/CMOS level output, etc.)

The difference between push-pull output and open-drain output of microcontroller I/O port

Figure 2[page]

4. If the open drain pin is not connected to an external pull-up resistor, it can only output a low level (therefore, for the P0 port of the classic 51 single-chip microcomputer, an external pull-up resistor must be added if it wants to have input and output functions, otherwise it cannot output high-level logic). Generally speaking, open drain is used to connect devices of different levels and match the levels.

5. Standard open-drain pins generally only have output capabilities. Adding other judgment circuits can enable bidirectional input and output capabilities.

6. The normal CMOS output stage consists of two tubes, upper and lower. Removing the upper tube will result in OPEN-DRAIN. This output has two main purposes: level conversion and line-and.

7. The wired-and function is mainly used in situations where multiple circuits pull down the same signal. If this circuit does not want to pull down, it will output a high level. Because the tube on the OPEN-DRAIN is removed, the high level is achieved by an external pull-up resistor. (For a normal CMOS output stage, if one output is high and the other is low, it is equivalent to a power short circuit.)

8. OPEN-DRAIN provides a flexible output mode, but it also has its weakness, which is the delay of the rising edge. Because the rising edge charges the load through an external pull-up passive resistor, when the resistor is small, the delay is small, but the power consumption is large; on the contrary, the delay is large and the power consumption is small. Therefore, if there is a requirement for delay, it is recommended to use the falling edge output.

Note in application:

1. The principles of open drain and open collector are similar. In many applications, we use open collector circuits instead of open drain circuits. For example, an input pin is required to be driven by an open drain circuit. Then our common driving method is to use a triode to form an open collector circuit to drive it, which is convenient and cost-saving. As shown in Figure 3.

The difference between push-pull output and open-drain output of microcontroller I/O port

2. The resistance value of the pull-up resistor R pull-up determines the speed of the edge of the logic level conversion. The larger the resistance value, the lower the speed and the lower the power consumption. Vice versa.

Push-Pull output is generally called push-pull output. It should be more suitable than CMOS output in CMOS circuits because the push-pull output capacity in CMOS cannot be as large as bipolar. The output capacity depends on the area of ​​the N-tube and P-tube of the internal output electrode of the IC. Compared with open-drain output, the high and low levels of push-pull are determined by the power supply of the IC, and simple logic operations cannot be performed. Push-pull is the most commonly used output stage design method in CMOS circuits.

Of course, open drain is not without cost, that is, the output drive capability is very poor. It is not accurate to say that the output drive capability is very poor. The drive capability depends on the power of the final transistor in the IC. OD only brings a delay on the rising edge, because the rising edge charges the load through an external pull-up passive resistor. When the resistor is small, the delay is small, but the power consumption is large. On the contrary, the delay is large and the power consumption is small. OPEN DRAIN provides a flexible output method, but it also has a price. If there is a requirement for delay, it is recommended to use the falling edge output.

The premise of small resistance and small delay is that the principle of resistor selection should be within the allowable range of power consumption of the final transistor. Experienced designers will not choose a 1 ohm resistor as a pull-up resistor when using logic chips. At the rising edge of the pulse, the power supply charges the load through the pull-up passive resistor. Obviously, the smaller the resistance, the shorter the rise time. At the falling edge of the pulse, in addition to the load discharging through the active transistor, the power supply also forms a path to the ground through the pull-up resistor and the turned-on transistor, which brings problems such as power consumption and power consumption of the chip. The resistor affects the rising edge but not the falling edge. If you don't care about the rising edge during use, the pull-up resistor can be selected as large as possible to reduce the current in the path to the ground. If the rising edge time is required to be high, the selection of the resistor size should be based on the chip power consumption.

Open-drain output means no output voltage, it is grounded when low level, and not grounded when high level. If an external pull-up resistor is connected, the voltage will be pulled to the power supply voltage of the pull-up resistor when the output is high level. This method is suitable when the voltage of the connected peripheral is lower than the voltage of the microcontroller.

Push-pull output means that the microcontroller pin can directly output a high-level voltage. It is grounded when it is low level, and outputs the microcontroller power supply voltage when it is high level. This method does not require a pull-up resistor. However, if the output terminal may be grounded, outputting a high level at this time may cause the microcontroller to run unstably, and may even burn out the pin.

Keywords:MCU Reference address:The difference between push-pull output and open-drain output of microcontroller I/O port

Previous article:From the bottom of my heart - for beginners who like single chip microcomputers
Next article:Microcontroller knowledge - structure and related companies

Recommended ReadingLatest update time:2024-11-23 08:17

Analysis of the significance of using M430/OS on the microcontroller to the system
introduction 1 The significance of using RTOS on MSP430 It is understandable that it is meaningless to use RTOS on MSP430. Because the hardware resources of MSP430 are limited (for example, MSP430F149 has only 2KB RAM), it is impossible to port any commercial operating system to MSP430. Currently, the only
[Microcontroller]
Design of RTU Microcontroller Based on ARM7
introduction With the acceleration of the informatization and modernization of my country's water data collection system, the types of data that need to be collected have increased, and the number of collection sites has increased, which has put forward new requirements for the speed and quality of data collect
[Microcontroller]
Design of RTU Microcontroller Based on ARM7
Stm8L series microcontrollers have low power consumption
The Stm8L series microcontroller has five low power modes: Wait mode Low power run mode Low power wait mode Active-halt with full RTC mode Halt Mode The lowest power consumption is the halt mode. Here we will mainly summarize how to enter the halt mode, how to wake up after entering, and how to automatical
[Microcontroller]
AVR MCU Voltage Meter Program
AVR voltmeter program: #include iom16v.h #include macros.h #define uchar unsigned char #define uint unsigned int #define setb(val,bitn) (val|=(1 (bitn)))//Set a bit of an IO port to 1 #define clr(val,bitn) (val&=~(1 (bitn)))//Set a bit of an IO port to 0 #define get(val,bitn) (val&(1 (bitn)))//Read a bit statu
[Microcontroller]
Design of Barometric Altimeter Based on Single Chip Microcomputer
Abstract: The design of digital pressure altimeter based on C8051F353 single chip microcomputer is completed by using highly integrated piezoresistive silicon pressure sensor and modular design method. The measurement accuracy is optimized and improved by using segmented interpolation method through simulation softw
[Industrial Control]
Design of Barometric Altimeter Based on Single Chip Microcomputer
How to light up an LED lamp using a 51 single chip microcomputer
First, we should understand the 51 MCU minimum system: the 51 minimum system is also called the 51 minimum application system, which refers to the system that can work with the 51 MCU composed of the least components. As shown in Figure 2.1.1, the 51 minimum system should generally include: MCU, crystal oscillator cir
[Microcontroller]
How to light up an LED lamp using a 51 single chip microcomputer
How to add PWM/analog channels to a microcontroller
A microcontroller is a single-chip microcomputer that integrates the main parts of a microcomputer on a single chip. Low-cost 8-bit single-chip microcontrollers are very stingy when it comes to on-chip PWM (pulse width modulation) resources. Designers are often forced to sacrifice a capture/compare channel or a timer
[Microcontroller]
How to add PWM/analog channels to a microcontroller
Make an alcohol tester based on 8051 microcontroller
We often see traffic police using breathalyzers to check whether drivers are under the influence of alcohol when checking for drunk driving. In fact, the alcohol tester is actually very easy to make. Here is how to make a homemade alcohol tester with a 3-digit display output. Of course, after all, it is used as a simp
[Microcontroller]
Make an alcohol tester based on 8051 microcontroller
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号