The output structure is shown in Figure 1. The collector of the transistor on the right is not connected to anything, so it is called an 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 end is "0", the front transistor is cut off, 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; when the input on the left end is "1", the front transistor is turned on, and the rear transistor is cut off.
We simplify Figure 1 to Figure 2. 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 the next resistor loads to the ground, the level of the output terminal is pulled to a low level by this load, so this circuit cannot output a high level. The 1k resistor in Figure 3 is the pull-up resistor. If the switch is closed, current flows through the 1k resistor and the switch, but since the resistance is 0 when the switch is closed (for the convenience of our discussion, the switch resistance is not 0 in actual situations, and there is also a saturation voltage drop for the triode), the voltage on the switch is 0, that is, the output level is 0. If the switch is open, since the switch resistance is infinite (same as above, the actual leakage current is not considered), the current flowing is 0, so the voltage drop on the 1k resistor is also 0, so the voltage at the output terminal is 5v, so a high level can be output.
However, the internal resistance of this output is relatively large, that is, 1k. If a load with a resistance of r is connected, the final output voltage can be calculated by voltage division to be 5*r/(r+1000) volts. Therefore, if a certain voltage is to be achieved, r cannot be too small. If r is really too small and the output voltage is not enough, then we can only increase the driving capability by reducing the 1k pull-up resistor. However, the pull-up resistor cannot be too small, because when the switch is closed, current will be generated. Since the current that can flow through the switch is limited, the value of the pull-up resistor is limited. In addition, it is necessary to consider that when the output is low, the load may also provide a part of the current to flow through the switch. Therefore, it is necessary to comprehensively consider these currents to select a suitable pull-up resistor. If we connect an input terminal for reading data to the output terminal, this is an IO port. The IO port of 51 has such a structure, in which the P0 port does not have an internal pull-up, while the other three ports have internal pull-ups. When we want to use the input function, we just 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.
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.
OC gates are mainly used in three aspects: to implement AND/OR logic, to be used as level conversion, and to be used as drivers.
The open-drain circuit has the following characteristics:
1. Use the driving capability of external circuits to reduce the internal drive of the IC, or drive loads that are higher than the chip power supply voltage.
2. Multiple open-drain output pins can be connected to one line. Through a pull-up resistor, without adding any components
In this case, an "AND logic" relationship is formed. This is also the principle of I2C, SMBus and other buses to determine the bus occupancy status.
3. Since the drain is open, the subsequent circuit must be connected to a pull-up resistor. The power supply voltage of the pull-up resistor can determine the output voltage.
In this way, any level conversion can be performed.
4. The open source provides a flexible output mode, but it also has its weakness, which is the delay of the rising edge.
The load is charged through an external pull-up passive resistor, so 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 large.
Therefore, if there is a requirement for delay, it is recommended to use falling edge output.
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, this 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. However, 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.
The logic inside the microcontroller needs to be output to the outside after the internal logic operation. The external device may require a large current to drive it, so there must be a drive circuit at the output port of the microcontroller. This drive circuit has two forms:
One of them is to use an N-type transistor - NPN or N-channel. Taking the NPN transistor as an example, e is grounded, b is connected to the internal logic operation, and c is led out. b is driven internally to control whether the transistor is turned on or not, but if the c pole of the transistor is always suspended, even if the b pole changes high or low, there will be no high or low changes on the c pole. Therefore, under this condition, a resistor must be provided externally, with one end of the resistor connected to c (lead-out pin) and the other end connected to the power supply. In this way, when the b of the transistor has a high voltage, the transistor is turned on and the c voltage is low. When b is a low voltage, the transistor is not connected, and the c pole is a high voltage under the pull of the resistor. This driving circuit has a characteristic: the low voltage is driven by the transistor, and the high voltage is driven by the resistor - asymmetric up and down. The internal resistance of ec when the transistor is turned on is very small, so it can provide a large current, which can directly drive the LED or even the relay, but the drive of the resistor is limited, and the maximum high-level output current = (VCC-Vh)/r;
The other is complementary push-pull output,
Two transistors are used, one on top and one on the bottom. The upper one is n-type and the lower one is p-type (taking a triode as an example). The connection between the two tubes is: the c of the NPN (upper) is connected to VCC, and the c of the PNP (lower) is grounded. The ee and bb of the two tubes are connected, of which ee is used as the output (lead-out pin) and bb is connected to the internal logic. This circuit is usually used in the final stage of the power amplifier circuit (audio). When bb is connected to a high voltage, the NPN tube is turned on to output a high voltage. Since the ec resistance of the triode is very small, the output high voltage has a strong driving ability. When bb is connected to a low voltage, the NPN is cut off and the PNP is turned on. Since the ec resistance of the triode is very small, the output low voltage has a strong driving ability. A simple example, when 9013 is turned on, the ec resistance is less than 10 ohms. Calculated with Vh=2.5v, VCC=5v, the maximum high-level output current = 250MA, and the short-circuit current is 500ma. This calculation also tells us that when using push-pull output, we must be careful not to have the possibility of external circuit short circuit, otherwise the chip will definitely burn out, especially when driving the transistor externally, don't forget to add a current limiting resistor to the base of the transistor. There are many forms of push-pull output circuits. Some microcontrollers use n-type tubes on both the top and bottom, but the internal logic provides complementary outputs. The above description is only to illustrate the principle of push-pull. For a deeper understanding, you can refer to the power amplifier circuit.
If the pull-up resistor is very large and the driving current provided is very small, it is called a weak pull-up; otherwise it is called a strong pull-up.
Why use pull-up resistors:
Pull-up is to embed an uncertain signal at a high level through a resistor. The resistor also acts as a current limiter. The same is true for pull-down. Pull-up is to inject current into the device, and pull-down is to output current. The difference between weak and strong is just the resistance value of the pull-up resistor. There is no strict distinction.
For non-OC and OD output circuits, the ability to increase current and voltage is limited. The function of the pull-up resistor is mainly to output current channels for open collector output circuits.
The main applications 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 (generally 3.5V), a pull-up resistor needs to be connected to the output end of the TTL to increase the value of the output high level.
2. When the OC gate circuit outputs "1", a pull-up resistor needs to be added. Without it, there will be no high level at all.
3. In order to increase the driving capability of the output pin, some microcontroller pins often use pull-up resistors. However, when using the OC gate as a driver (for example: controlling an LED) to sink current, the pull-up resistor does not need to be added.
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. Improve the anti-electromagnetic interference capability of the bus. If the pin is left floating, it is more susceptible to external electromagnetic interference.
6. Resistance mismatch in long-distance transmission can easily cause reflected wave interference. Adding a pull-down resistor can effectively suppress reflected wave interference.
The principles for selecting the pull-up resistor value include:
1. Considering power consumption and the chip's current sinking capability, it should be large enough; the larger the resistance, the smaller the current.
2. It should be small enough to ensure sufficient driving current; the smaller the resistance, the larger the current.
3. For high-speed circuits, a pull-up resistor that is too large may flatten the edge.
Considering the above three points, it is usually selected between 1k and 10k. The same is true for pull-down resistors.
In the high-impedance state, the resistance of the pin to the ground is infinite. At this time, the real level value can be read when reading the pin level. The important role of the high-impedance state is to read the external level at the I/O (input/output) port when inputting.
The connection between the general gate and other circuits is nothing more than two states, 1 or 0. In a more complex system, in order to transmit the signals of different components on a transmission line, a corresponding logic device called a three-state gate is developed. In addition to these two states, the three-state gate also has a high-impedance state, which is high impedance (large resistance, equivalent to an open circuit). It is equivalent to the gate being disconnected from the circuit connected to it. The three-state gate is an output stage that expands the logic function and is also a control switch. It is mainly used for bus connection, because the bus only allows one user at the same time. Usually, multiple devices are connected to the data bus, and each device is selected by a signal such as OE/CE. If the device is not selected, it is in a high-impedance state, which is equivalent to not being connected to the bus and does not affect the work of other devices.
The quasi-bidirectional port can only read 0 effectively, and for 1, it uses the method of reading non-zero, that is, when reading, you must first write 1 to the IO, and then read. The
real bidirectional port is just as its name suggests, that is, the real bidirectional IO can read directly without any pre-operation.
Previous article:Playing with MCU, you and I are both rookies (Continued 3)
Next article:SD card pin arrangement and bus read and write methods
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- How do you calculate the cost of PCB materials?
- [MM32 eMiniBoard Review] Part 7: IIC Read and Write EEPROM
- Altium Designer's dirty tricks to combat piracy
- TMS320F2812 generates PWM waveform process
- TI Power Stage Designer Tool Introduction Documentation
- I would like to ask you, the STM32CUBEMX+SPI+DMA method always sends incorrectly. My chip is STM32F103RC
- Keysight Technology Award-winning Live Broadcast | Thanksgiving Month Opening Ceremony - Oscilloscope Lecture Hall Registration Starts~
- LLC resonance start-up conditions
- MLX90640 infrared imaging - red eye camera (Chinese information/development notes/source code test)
- I would like to ask, what is the inductor routing problem of this buck power supply circuit?