Introduction: When the P0 port of the 51 single-chip microcomputer works in the normal IO port mode, it is a quasi-bidirectional IO port. When it works in the second function state, it is a standard bidirectional IO port. Since the output of the bidirectional IO port requires the output of high and low levels, a complementary push-pull circuit is usually used.
Bidirectional IO port output: complementary push-pull
When the P0 port of the 51 single-chip microcomputer works in the normal IO port mode, it is a quasi-bidirectional IO port. When it works in the second functional state, it is a standard bidirectional IO port. Since the output of the bidirectional IO port requires the output of high and low levels, a complementary push-pull circuit is usually used.
In the second functional state, the 51 single-chip microcomputer P0 port adopts the complementary push-pull output mode. What is complementary push-pull? The following is its equivalent circuit diagram.
When the second function of P0 is used as output, the two switches K1 and K2 are turned on in turn. When K2 is closed and K1 is open, a high level is output, and its driving ability is very large because the resistance of the electronic switch is small (not as large as the value of the pull-up resistor). On the contrary, when K2 is opened and K1 is closed, a low level is output.
The two switches are turned on alternately and complement each other. "Pull" means "pull". The two electronic switches are respectively responsible for "pushing" and "pulling" current at the output of the IO port, so it is called complementary push-pull.
The advantages of this IO port structure are obvious, with strong driving capability, stability and reliability. The disadvantage is that it is difficult to implement. In the process of switching the output level, for example, switching from a low level to a high level, when K1 is disconnected, it is required to output a high level as quickly as possible, that is, K2 should be closed immediately; at the same time, if K1 is not disconnected, K2 is closed in advance, which is equivalent to the two switches being turned on at the same time, which will directly short-circuit and the consequences will be very serious. Therefore, it is necessary to use a circuit to control the coordinated work of the two switches.
Bidirectional IO port input: high impedance, input resistance
The output of the bidirectional IO port only requires the output of high and low levels, so it is not necessary to use a complementary push-pull circuit. The advantage of using a complementary push-pull circuit is that this circuit can also achieve high-impedance input, thereby realizing a standard bidirectional IO port.
When K1 and K2 in the figure are disconnected at the same time, the IO port can work in the high-impedance input state. What is the concept of high-impedance state?
When the IO port is in a high impedance state, it is also called a floating input state, and its level is floating and uncertain, neither high nor low. We can imagine that when the microcontroller detects the level of the IO port, it is equivalent to having something like a voltmeter in the CPU, and the internal resistance of this voltmeter is very large, such as the 100MΩ shown in the figure. Here, we can call the internal resistance of this voltmeter the input resistance of the P0.0 port at this time (it can also be roughly regarded as the output impedance, resistance is for direct current, and impedance is for alternating current. This is the knowledge of analog circuits, and I will not go into details here).
Now imagine that if you accidentally touch the P0.0 port with your hand, and because the human body itself is a conductor with a large resistance, there are many electromagnetic waves around, and there may be some very weak current on your hand, at this time, the reading of the voltmeter will change, and the level read by the microcontroller will change. The result of the high impedance state is that even a small interference from the outside world may cause the read level to change, and even if the IO port is not touched, the result of each reading may be different, because the electromagnetic waves from the outside world may interfere with the IO port. Later we will use the 51 microcontroller to do an experiment to experience the high impedance state of the P0 port.
The meaning of high impedance state, output resistance
Why is the bidirectional IO port required to be in high impedance state when inputting?
Let's assume there is a device with an equivalent circuit as shown below. When the switch is switched up and down, it will output high and low levels, which can be detected by a voltmeter. However, its driving ability is very weak and it cannot even drive an LED. The 100kΩ in the device can be called the output resistance of the device (it can also be roughly considered as the output impedance).
Let this device output low level, and then connect to the P1.0 port of 51 MCU. At this time, VCC reaches the IO port through the 10kΩ pull-up resistor, and then to the 100kΩ resistor inside the device, and is connected to GND through switch K. According to the voltage division principle, the voltage value on P1.0 is about 4.55V, so the MCU reads a high level. But the fact is that the device wants to output a low level to inform the 51 MCU. Here, the MCU pin is used as an input function, but it interferes with the output value of the external device, which is equivalent to the IO port of the MCU also outputting.
When the P0 port of the microcontroller works in the input state of the second function, or works in the input state of the ordinary IO port, and there is no external pull-up and pull-down resistor, the two internal electronic switches are disconnected and present a high impedance state to the outside. As can be seen from the figure, the output level of the device can be accurately read into the microcontroller. The reason for accurate reading is that the output resistance of the device is smaller than the input resistance of the microcontroller IO port.
Some people may say that if the resistance in the device is replaced with 1000MΩ, the microcontroller will not be able to read the voltage level accurately. However, in general, we do not need to consider such extremes. If it is an ideal high-impedance state, its input impedance should be infinite, which is a bit like a superconductor. In general, it is believed that the resistance of the wire is almost 0, and it is also believed that the input resistance of the high-impedance state is infinite.
In general, in the high-impedance state, the input resistance of the IO port is very large, and it is not easy to interfere with the output level of devices with large output resistance and weak driving capability to the IO port.
Previous article:Design of intelligent solar street light based on STC12C2051 microcontroller
Next article:Parallel interface design based on printer parallel interface
Recommended ReadingLatest update time:2024-11-16 11:44
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Functions and applications of MS90C386B and MS90C385B
- STM32F429DISC runs DOOM game
- About Water Meter 188 Agreement
- High-performance motor for an excellent vacuum cleaner
- What is an RF filter?
- Where does the DC bias at the output of the op amp in the figure below come from?
- Is this understanding of variable types correct?
- DE1SOC transfers the available memory address in demo2_axi_app in BMP
- Share a cost-effective headset
- Program file does not exist problem occurs in ON Semiconductor IDE