A TTL-level serial port multi-device communication device with automatic switching function
By using the SN74LVC2G157 multiplexer for automatic switching in TTL level serial communication, the problems of level conflict and anti-interference in multi-device communication are solved, achieving high reliability and low loss multi-device communication, simplifying hardware design and reducing maintenance costs.
Patent Information
- Application Number
- CN202621600903.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-15
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2036-10-15
AI Technical Summary
In TTL level serial multi-device communication, when the receive pin of the microcontroller is connected in parallel with multiple transmit pins, level conflicts and signal distortion are likely to occur. Existing diode solutions and multiplexer solutions each have their limitations and cannot effectively solve the problems of level conflicts and anti-interference.
The SN74LVC2G157 multiplexer is used, and its channel selection terminal is shorted to the first input channel. The channel is automatically switched by the change of input level. Combined with the characteristics of CMOS switching, the signal transmission without voltage drop is realized, which simplifies the hardware design and realizes automatic switching without external control.
Eliminates level distortion, improves communication reliability, extends noise margin, reduces hardware complexity and maintenance costs, adapts to burst data transmission, and enhances electromagnetic interference resistance.
Smart Images

Figure CN224987424U_ABST
Abstract
Description
Technical Field
[0001] This utility model belongs to the field of integrated circuit technology, specifically relating to a TTL level serial port multi-device communication device with automatic switching function. Background Technology
[0002] TTL (Transistor-Transistor Logic) level serial communication is a full-duplex communication interface based on single-ended signals. Its core uses two data lines to achieve bidirectional data transmission: the transmit pin sends data by outputting a logic high level H (typically 1.8V / 3.3V / 5V) or a logic low level L, while the receive pin receives information by detecting changes in the level of external input. Two TTL devices communicate through a cross-connection, meaning the transmit pin of the first device is connected to the receive pin of the second device, and vice versa. Data is transmitted independently on the two channels without interference, supporting simultaneous transmission and reception. Figure 1 As shown.
[0003] When the microcontroller unit needs to connect to two or more devices via a single TTL serial port or has reserved expansion interfaces, such as Figure 2 As shown, the following key issues exist: The transmit pin of the microcontroller can be directly connected in parallel to the receive pins of multiple devices because the level signal output by the transmit pin can be read simultaneously by multiple receive pins without signal conflict. However, if the receive pin of the microcontroller is directly connected in parallel to the transmit pins of multiple devices, level conflicts will occur. Specifically, in the idle state, the transmit pins of each device output a high level H by default. When one device sends data to the microcontroller, its transmit pin is pulled low to a low level L, but the transmit pins of other devices remain high at level H. At this time, the receive pins of the microcontroller will simultaneously receive high and low level signals from different devices, causing signal superposition and distortion, making it impossible to accurately interpret the data.
[0004] To address the level conflict issue caused by connecting multiple device transmit pins in parallel to the microcontroller's receive pin, one existing solution is to connect a diode in series between the transmit pin of each peripheral and the receive pin of the microcontroller, such as... Figure 3 As shown. Its core principle is based on the unidirectional conductivity of a diode: when the first peripheral sends data to the microcontroller, its transmit pin is pulled low (L), the diode conducts in the forward direction, and the microcontroller's receive pin can normally read the low-level L signal; simultaneously, the second peripheral's transmit pin remains high (H), but because the diode is reverse-biased, the high-level H cannot be transmitted to the microcontroller's receive pin through the diode, thus avoiding level conflicts. This scheme only allows the low-level L signal to pass through the diode, effectively isolating the high-level H interference in the idle state H, ensuring that a single receive pin can stably receive time-division multiplexing data from multiple peripherals.
[0005] Another solution in the prior art is an active control multi-device switching scheme based on multiplexers, such as the SN74LVC2G157 multiplexer. Its core logic is to actively control the channel selection pins of the multiplexer through the additional general-purpose input / output pins of the microcontroller unit, thereby switching between the microcontroller unit's receive pins and the transmit pins of different peripherals. Specific connections are as follows... Figure 4 As shown: The first and second input channels of the multiplexer are connected to the transmit pins of the first and second peripherals, respectively, and the output is connected to the receive pin of the microcontroller. The channel selection terminal of the multiplexer is connected to the dedicated general-purpose input / output pin of the microcontroller. When data from the first peripheral needs to be received, the microcontroller outputs a low level L through the general-purpose input / output pin, and the multiplexer selects the first input channel; when data from the second peripheral needs to be received, the microcontroller outputs a high level H, and the second input channel is selected.
[0006] In summary, in multi-device expansion scenarios using TTL level serial ports, level conflicts on the receive pins are a core technical challenge. The series diode solution achieves signal isolation through unidirectional conductivity, providing a feasible path for low-cost, compact multi-device communication; while the active control solution based on multiplexers can achieve precise and stable inter-device communication. However, the aforementioned existing solutions still have their own technical limitations and require further improvement. Utility Model Content
[0007] To solve the above-mentioned technical problems, this utility model provides a TTL level serial port multi-device communication device with automatic switching function. The channel selection terminal of the multiplexer is directly shorted to its first input channel. The channel selection signal is synchronously driven by the level change when the first input channel sends data, realizing hardware automatic channel switching without the intervention of an external controller. At the same time, zero-level loss transmission is achieved by taking advantage of the CMOS switching characteristics of the multiplexer.
[0008] To achieve the above objectives, the technical solution adopted by this utility model is as follows:
[0009] A TTL level serial port multi-device communication device with automatic switching function, comprising:
[0010] Multiplexer, first pull-up resistor, second pull-up resistor, power supply and ground terminal;
[0011] The enable terminal of the multiplexer is connected to the ground terminal;
[0012] The first input channel of the multiplexer is connected to the power supply via the first pull-up resistor and is used to connect to the transmit pin of the first peripheral.
[0013] The second input channel of the multiplexer is connected to the power supply via the second pull-up resistor and is used to connect to the transmit pin of the second peripheral.
[0014] The channel selection terminal of the multiplexer is shorted to the first input channel;
[0015] The output of the multiplexer is used to connect to the receive pin of the microcontroller unit;
[0016] The channel selection terminal automatically switches the output channel according to the level change of the first input channel, so as to transmit the level signal of the first input channel or the second input channel to the output terminal.
[0017] Furthermore, the multiplexer is an SN74LVC2G157 dual-channel 2-to-1 multiplexer.
[0018] Furthermore, the channel selection terminal of the multiplexer is shorted to the first input channel, such that when the first peripheral device sends data to the microcontroller unit, the first input channel outputs a low level, the channel selection terminal synchronously becomes low level, and the output terminal follows the level of the first input channel; when the first peripheral device finishes sending data and the first input channel returns to a high level, the channel selection terminal synchronously becomes high level, and the output terminal follows the level of the second input channel.
[0019] Furthermore, the enable terminal of the multiplexer is connected to the ground terminal, so that the multiplexer is always in working condition.
[0020] Furthermore, the multiplexer uses complementary metal-oxide-semiconductor switches for signal transmission, and there is no additional voltage drop during signal transmission to maintain the integrity of low-level signals.
[0021] Furthermore, the power supply voltage range of the multiplexer is -0.5V to 6.5V, and it is compatible with TTL level standards of 1.8V, 3.3V and 5V.
[0022] Furthermore, when both the first peripheral and the second peripheral are in an idle state, both the first input channel and the second input channel output a high level, the channel selection terminal is high, the output terminal follows the second input channel, and the default communication channel is the second peripheral.
[0023] Furthermore, when the second peripheral sends data to the microcontroller, the first input channel remains at a high level, the channel selection terminal is at a high level, and the output terminal follows the level of the second input channel; when the second input channel outputs a low level, the output terminal is synchronously at a low level, and when the second input channel outputs a high level, the output terminal is synchronously at a high level.
[0024] Furthermore, the resistance values of the first pull-up resistor and the second pull-up resistor are 1kΩ.
[0025] Furthermore, the device also includes a cascaded structure, which is composed of multiple multiplexers to achieve N-to-1 multi-device expansion, where N is a positive integer greater than 2. The automatic switching logic of the cascaded structure is the same as that of a single multiplexer and requires no additional control signals.
[0026] The beneficial effects of this utility model are as follows:
[0027] First, it eliminates level distortion and improves the reliability of low-voltage communication. Existing series diode solutions have an inherent voltage drop during forward conduction, which can easily cause the microcontroller to misinterpret a low-level L signal as a high-level H signal in low-voltage TTL scenarios. This invention uses the CMOS switch of the SN74LVC2G157 multiplexer for signal transmission, eliminating the need for additional voltage drops and ensuring the integrity of the low-level L signal, thus fundamentally solving the level distortion problem.
[0028] Second, it expands the noise margin and enhances anti-interference capability. In diode solutions, the voltage drop compresses the available noise margin of the signal, and external electromagnetic interference can easily cause misjudgment. This invention retains the complete signal voltage range through a voltage drop-free design, extending the noise margin to full range and significantly improving the anti-electromagnetic interference capability.
[0029] Third, it frees up the pin resources of the microcontroller unit, simplifying hardware design. Traditional active control schemes require the use of the microcontroller unit's general-purpose input / output pins for channel switching. This invention uses a hardware design that shorts the channel selection terminal to the first input channel, automatically triggering switching based on changes in input level, eliminating the need for any general-purpose input / output pins and reducing hardware wiring complexity.
[0030] Fourth, it eliminates the need for software development and reduces maintenance costs. This invention achieves automatic channel switching entirely at the hardware level, eliminating the need to write and debug channel switching control code, thus avoiding communication failures caused by software logic errors. Furthermore, no software modifications are required when expanding the device, further reducing development and maintenance costs.
[0031] Fifth, it boasts a fast response speed and adapts to burst data transmission. Based on automatic hardware level switching, this invention achieves a response time only a nanosecond-level switching delay of a multiplexer. It eliminates the need for microcontroller polling or intervention, enabling real-time response to burst data from peripherals and preventing data loss. Attached Figure Description
[0032] Figure 1 This is a schematic diagram of the TTL level serial port operating mode in the existing technology;
[0033] Figure 2 This is a schematic diagram illustrating the connection between a microcontroller unit and two peripherals via a single TTL level serial port in the prior art.
[0034] Figure 3 This is a schematic diagram illustrating the level isolation principle of a series diode scheme in the prior art;
[0035] Figure 4 This is a connection diagram of an existing active control multi-device handover scheme based on a multiplexer.
[0036] Figure 5 This is a circuit schematic diagram of a TTL level serial port multi-device communication device with automatic switching function according to this utility model.
[0037] Figure 6 The logic diagram of the SN74LVC2G157 multiplexer;
[0038] Figure 7 This is a schematic diagram of the channel switching and data transmission timing of the automatic switching circuit of this utility model. Detailed Implementation
[0039] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0040] like Figure 5 As shown, this utility model provides a TTL level serial port multi-device communication device with automatic switching function. The device mainly includes an SN74LVC2G157 dual-channel 2-to-1 multiplexer, pull-up resistors R1, R2, and R3, a power supply VCC, and a ground plane GND. The SN74LVC2G157 multiplexer has a power supply voltage range of -0.5V to 6.5V and is compatible with 1.8V, 3.3V, and 5V TTL level standards. Its pin functions are shown in Table 1.
[0041] Table 1
[0042] The logic diagram of the SN74LVC2G157 multiplexer is as follows: Figure 6 As shown, its truth table is shown in Table 2.
[0043] Table 2
[0044] Where H represents high level H, L represents low level L, and X represents any state.
[0045] In terms of hardware connections, in practical implementation, the enable pin (#G pin) of the multiplexer is directly connected to the logic ground level GND, ensuring the multiplexer is always operational. The first input channel (pin A) of the multiplexer is connected to the transmit pin TXD1 of the first peripheral, and the second input channel (pin B) is connected to the transmit pin TXD2 of the second peripheral. Simultaneously, pins A and B are connected to the power supply VCC via pull-up resistors R1 and R2, respectively, ensuring that the input levels of pins A and B are both logic high (H) in idle state H. The resistance values of pull-up resistors R1 and R2 can be selected according to the actual level standard; as a preferred implementation, the resistance value is 1kΩ. The channel selection pin (#A / B pin, i.e., pin 6) of the multiplexer is shorted to the first input channel pin A, ensuring the channel selection signal is completely consistent with the level state of pin A. The output pin (Y pin) of the multiplexer is directly connected to the receive pin RXD of the microcontroller unit, and the level signal of the selected channel is output from the Y pin. In addition, the inverting output terminal (#Y pin) of the multiplexer may be left unconnected or left floating in this embodiment.
[0046] The following combination Figure 5 , Figure 6 , Figure 7 Table 2, along with the truth table, details the automatic switching working principle of this utility model.
[0047] The core function of the SN74LVC2G157 multiplexer is to select one input channel (either the first input channel A or the second input channel B) to output to the Y terminal based on the level state of the channel selection pins #A / B. Since the #A / B pins are shorted to the A pin, the level of #A / B always follows the level of the A pin. When all peripherals are in idle state H, both the A and B pins are held high by pull-up resistors H, and the #A / B pin is high H. According to the truth table in Table 2, when #G is low L and #A / B is high H, the Y pin follows the level of the B pin; therefore, the default communication channel is the second peripheral.
[0048] When the first peripheral (peripheral 1 in the diagram, channel A) sends data to the microcontroller unit (MCU), its transmit pin TXD1 outputs a data signal. Specifically, when TXD1 outputs a logic low level L, pin A is pulled low to a low level L. Since #A / B is shorted to pin A, pins #A / B synchronously become low level L. At this time, according to the truth table in Table 2 (#G is low level L, #A / B is low level L, Y follows A), pin Y outputs the same low level L as pin A, and the MCU's receive pin RXD receives the low level L. When TXD1 outputs a logic high level H, pin A is high level H, and pins #A / B synchronously become high level H. According to the truth table (#G is low level L, #A / B is high level H, Y follows B), pin Y outputs the level of pin B. Since the second peripheral is in an idle state H at this time, pin B is kept high level H through a pull-up resistor, therefore pin Y outputs high level H, and the MCU receives high level H. Therefore, during the data transmission of the first peripheral, when the first peripheral sends a low level L, the multiplexer automatically selects channel A; when the first peripheral sends a high level H, the multiplexer automatically switches to channel B, but since channel B is idle and at a high level H, the output remains at a high level H. This means that the complete data sequence transmitted by the first peripheral can be correctly transmitted to the RXD pin of the microcontroller unit through the multiplexer.
[0049] When the second peripheral (peripheral 2, channel B in the diagram) sends data to the microcontroller unit, the transmit pin TXD1 of the first peripheral remains idle (H), pin A is held high (H) by a pull-up resistor, and pins #A / B are synchronously held high (H). According to the truth table, when #A / B is high (H), pin Y follows the level of pin B. Therefore, the low-level (L) or high-level (H) signal output by the transmit pin TXD2 of the second peripheral is directly transmitted to pin Y through pin B and then correctly received by the receive pin RXD of the microcontroller unit. During this period, since channel A is not selected, the idle high level (H) of the first peripheral will not interfere with the output.
[0050] Figure 7 The complete process of the aforementioned channel switching and data transmission is illustrated in the form of a timing diagram. For example... Figure 7 As shown, when channel A (the first peripheral) sends data, the level change of pin A directly drives the synchronous change of pins #A / B, thereby controlling pin Y to automatically switch between channels A and B, so that pin Y outputs the correct data level; when channel B (the second peripheral) sends data, since pin A remains at a high level H, pins #A / B remain at a high level H, pin Y continuously selects channel B, and outputs the data level of pin B.
[0051] As shown above, the device of this invention achieves automatic channel switching through hardware logic, eliminating the need for the microcontroller to provide additional general-purpose input / output pins for channel selection control, and requiring no channel switching software code. Throughout the communication process, the microcontroller's receive pin RXD always correctly receives the level signal of the peripheral currently transmitting data, provided that only one peripheral is transmitting data to the microcontroller at any given time. In cases where multiple peripherals transmit data simultaneously, the multiplexer can only select one channel, potentially leading to chaotic received data. Therefore, in practical applications, it is recommended to use protocol layer coordination mechanisms (such as address frames, handshake signals, etc.) for communication scheduling to ensure that at most one device transmits data at any given time, thereby achieving stable time-division communication.
[0052] The device of this invention transmits signals using the CMOS switching characteristics of the SN74LVC2G157 multiplexer. Since there is no PN junction voltage drop like in a diode along the signal path, the signal level is maintained intact during transmission, preventing low-level voltage rise. This characteristic enables reliable communication even in low-voltage TTL scenarios (e.g., 1.8V), while preserving full signal noise margin and enhancing electromagnetic interference immunity.
[0053] The device of this invention also has good scalability. When more peripherals need to be connected, an N-to-1 multi-device expansion structure can be constructed by cascading multiple SN74LVC2G157 multiplexers, where N is a positive integer greater than 2. When cascading, the automatic switching logic of each multiplexer is the same as that of a single multiplexer, that is, the channel selection terminal of each stage is short-circuited with the corresponding first input channel. After cascading, no additional control signals are required to achieve automatic switching communication between multiple devices.
[0054] In summary, the specific embodiments of this utility model provide a TTL level serial port multi-device communication device with automatic switching function. Through reasonable hardware connection design, utilizing the truth table logic of the multiplexer and the self-driving characteristics of the input level, it achieves control-free, lossless, and highly reliable multi-device serial communication. Those skilled in the art should understand that various modifications and variations can be made to this utility model without departing from its principles, and all such modifications and variations fall within the protection scope of the appended claims.
[0055] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this utility model. It should be understood that the above description is only a specific embodiment of this utility model and is not intended to limit this utility model. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this utility model should be included within the protection scope of this utility model.
Claims
1. A TTL level serial port multi-device communication device with automatic switching function, characterized in that, include: Multiplexer, first pull-up resistor, second pull-up resistor, power supply and ground terminal; The enable terminal of the multiplexer is connected to the ground terminal; The first input channel of the multiplexer is connected to the power supply via the first pull-up resistor and is used to connect to the transmit pin of the first peripheral. The second input channel of the multiplexer is connected to the power supply via the second pull-up resistor and is used to connect to the transmit pin of the second peripheral. The channel selection terminal of the multiplexer is shorted to the first input channel; The output of the multiplexer is used to connect to the receive pin of the microcontroller unit; The channel selection terminal automatically switches the output channel according to the level change of the first input channel, so as to transmit the level signal of the first input channel or the second input channel to the output terminal.
2. The TTL level serial multi-device communication device with automatic switching function according to claim 1, characterized in that, The multiplexer is an SN74LVC2G157 dual-channel 2-to-1 multiplexer.
3. A TTL level serial port multi-device communication device with automatic switching function according to claim 2, characterized in that, The channel selection terminal of the multiplexer is shorted to the first input channel, such that when the first peripheral device sends data to the microcontroller unit, the first input channel outputs a low level, the channel selection terminal synchronously becomes low level, and the output terminal follows the level of the first input channel; when the first peripheral device finishes sending data and the first input channel returns to a high level, the channel selection terminal synchronously becomes high level, and the output terminal follows the level of the second input channel.
4. A TTL level serial port multi-device communication device with automatic switching function according to claim 2, characterized in that, The enable terminal of the multiplexer is connected to the ground terminal, so that the multiplexer is always in working condition.
5. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, The multiplexer uses complementary metal-oxide-semiconductor switches for signal transmission, and there is no additional voltage drop during signal transmission to maintain the integrity of low-level signals.
6. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, The multiplexer has a power supply voltage range of -0.5V to 6.5V and is compatible with TTL level standards of 1.8V, 3.3V and 5V.
7. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, When both the first peripheral and the second peripheral are in an idle state, both the first input channel and the second input channel output a high level, the channel selection terminal is high, the output terminal follows the second input channel, and the default communication channel is the second peripheral.
8. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, When the second peripheral sends data to the microcontroller, the first input channel remains at a high level, the channel selection terminal is at a high level, and the output terminal follows the level of the second input channel; when the second input channel outputs a low level, the output terminal is synchronously at a low level, and when the second input channel outputs a high level, the output terminal is synchronously at a high level.
9. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, The resistance values of the first pull-up resistor and the second pull-up resistor are 1kΩ.
10. A TTL level serial port multi-device communication device with automatic switching function according to claim 1, characterized in that, The device also includes a cascaded structure, which consists of multiple multiplexers to achieve N-to-1 multi-device expansion, where N is a positive integer greater than 2. The automatic switching logic of the cascaded structure is the same as that of a single multiplexer and requires no additional control signals.
