Control circuit for automatically matching serial port level of master device with serial port level of slave device
By designing an automatic matching control circuit in the serial port circuit, using the main control module, level conversion chip, electronic switch and signal recognition module, the slave serial port level is automatically recognized and matched, solving the problems of operation troubles and logic complexity in the existing technology, and realizing automated level matching and signal processing.
Patent Information
- Application Number
- CN202411993392.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
AI Technical Summary
When the existing serial port circuit changes in the serial port signal level of the slave device, it is necessary to disassemble the machine to switch the resistor switching channel or switch the switch channel. The operation is troublesome and the hardware logic or software judgment logic is complicated.
Design a control circuit that automatically matches the slave serial port level through the main control module, level conversion chip, electronic switch and signal recognition module to achieve automatic identification and matching, thereby automatically controlling the switch to turn off the level conversion circuit, signal through or signal conversion.
Regardless of whether the slave serial port signal is TTL or RS232 level, the master device can automatically identify and match, avoiding the need to disassemble the machine and switch the level channels when the serial port level of different slave devices is different. The hardware circuit is simple and the software control logic is simple.
Smart Images

Figure CN119903007A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of serial port circuits, in particular to a control circuit for automatically matching the level of a serial port of a master device with that of a slave device. Background Art
[0002] The serial port circuit, also known as the serial communication interface circuit, is a code converter used for data exchange between the CPU and serial devices. When data is sent from the CPU to the serial port, the byte data is converted into serial bits; when receiving data, the serial bits are converted into byte data. Serial port communication uses three wires: ground, transmit (TXD), and receive (RXD) to complete basic communication functions.
[0003] After searching, the patent with application number CN201520607857.X discloses a serial port server with automatic communication interface matching, including: a serial port server body 1, including a network interface 1.1, a processor 1.2, an interface conversion circuit 1.3, a default interface selection circuit 1.4, and a DB9 interface 1.5; the network interface 1.1, the processor 1.2, the interface conversion circuit 1.3, and the DB9 interface 1.5 are connected in sequence, and the default interface selection circuit 1.4 is connected to the interface conversion circuit 1.3; an interface converter 2, including: a DB9 interface 2.1, an RS422 / RS485 interface selection circuit 2.2, and an RS422 / RS485 hardware interface 2.3; the DB9 interface 2.1 is respectively connected to the RS422 / RS485 interface selection circuit 2.2 and the RS422 / RS485 hardware interface 2.3; the RS422 / RS485 interface selection circuit 2.2 and the interface conversion circuit 1.3 are connected when the serial port server body 1 and the interface converter 2 are connected. The utility model completes the automatic matching of the communication interface through the matching of the interface converter, and is convenient to use.
[0004] In order to support TTL level and RS232 level, the current serial port circuit usually selects TTL level channel or RS232 level channel through 0Ω resistor, or switches through switches;
[0005] When the signal level type (TTL / RS232) of the slave device serial port changes, it is necessary to disassemble the device to switch the channel with a resistor, or to switch the channel with a switch, which is troublesome. Even if some technologies disclose TTL / RS232 circuit adaptation, the hardware logic circuit is relatively complex, or the software judgment logic is relatively complex. Therefore, we need to propose a control circuit for the master device serial port to automatically match the slave device serial port level. Summary of the invention
[0006] The purpose of the present invention is to provide a control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device. No matter whether the serial port signal of the slave device is TTL or RS232 level, the master device end can automatically identify the match, and automatically disconnect the level conversion circuit through the control switch, the signal is directly passed, or the signal needs to be converted and disconnected, so as to avoid the situation that the machine needs to be disassembled and the level channel needs to be switched when the serial port levels of different slave devices are different. The hardware circuit is simple and the software control logic is simple, so as to solve the problems raised in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solution: a control circuit for automatically matching the level of a serial port of a master device with the level of a serial port of a slave device, comprising:
[0008] The main control module responsible for sending and receiving signals;
[0009] A level conversion chip used to convert a signal of one voltage level into a signal of another voltage level;
[0010] An application module that is responsible for receiving signals sent by the main control module and can send response signals;
[0011] Two electronic switches for switching signal transmission channels;
[0012] A signal identification module for identifying the type of signal level of the application module;
[0013] The two electronic switches are electrically connected to the main control module to achieve switch switching control;
[0014] The two electronic switches include an electronic switch 1 connected between the main control module and the level conversion chip, and an electronic switch 2 connected between the application module and the level conversion chip. The signal identification module is connected between the main control module and the application module.
[0015] Preferably, the signal output interface 1 of the level conversion chip is connected to the RXD interface of the application module, and the signal output interface 2 of the level conversion chip is connected to the RXD interface of the main control module.
[0016] Preferably, the input end of the electronic switch 1 is connected to the main control module, the output end 1 of the electronic switch 1 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the application module.
[0017] Preferably, the input end of the electronic switch 1 is connected to the TXD interface of the main control module, the output end 1 of the electronic switch 1 is connected to the signal input interface 1 of the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the RXD interface of the application module.
[0018] Preferably, the input end of the electronic switch 2 is connected to the application module, the output end 1 of the electronic switch 2 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the main control module.
[0019] Preferably, the input end of the electronic switch 2 is connected to the TXD interface of the application module, the output end 1 of the electronic switch 2 is connected to the signal input interface 2 of the level conversion chip, and the output end 2 of the electronic switch 2 is connected to the RXD interface of the main control module.
[0020] Preferably, the signal identification module includes an analog-to-digital converter capable of collecting positive and negative voltages, the analog-to-digital converter samples the waveform of the signal sent by the TXD interface of the application module, and identifies the level type of the signal sent by the application module.
[0021] Preferably, when the signal sent by the TXD interface of the application module is divided, the analog-to-digital converter collects the divided signal and identifies the signal type according to the TTL / 232 signal amplitude range and whether the signal has a negative voltage.
[0022] Compared with the prior art, the present invention has the following beneficial effects:
[0023] The present invention can automatically identify and match the serial port signal of the slave device whether it is TTL or RS232 level, and automatically disconnect the level conversion circuit and pass the signal directly through the control switch, or the signal needs to be converted and disconnected, thereby avoiding the situation where the machine needs to be disassembled and the level channel needs to be switched when the serial port levels of different slave devices are different, and the hardware circuit is simple and the software control logic is simple. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a circuit diagram of the 232 level mode of the present invention;
[0025] Figure 2 It is a circuit diagram of the TTL level mode of the present invention. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] See also Figure 1-2The present invention provides a technical solution: a control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device, comprising: a main control module responsible for sending and receiving signals; a level conversion chip used to convert a signal of one voltage level into a signal of another voltage level; an application module responsible for receiving the signal sent by the main control module and sending a response signal; two electronic switches used to switch the signal transmission channel; and a signal identification module used to identify the signal level type of the application module.
[0028] When the TXD interface of the main control module sends an RS232 level signal, the signal transmission channel is connected to the RS232 end through the switch. When the TXD interface of the main control module sends a TTL level signal, the signal transmission channel is connected to the TTL end through the switch.
[0029] The main control module detects that the signal sent by the application module is RS232 level, and the signal channel is connected to the RS232 end. The main control module detects that the signal sent by the application module is TTL level, and the signal channel is connected to the TTL end.
[0030] The main control module (i.e., the master device) and the application module (i.e., the slave device) are both provided with an RXD interface and a TXD interface. The TXD interface is used to send signal data, and the RXD interface is used to receive signal data.
[0031] The model of the level conversion chip is MAX232, and the level conversion chip is respectively provided with a signal input interface 1 (IN1), a signal output interface 1 (OUT1), a signal input interface 2 (IN2), and a signal output interface 2 (OUT2).
[0032] The connection of the above modules, switches and chips forms four signal transmission channels, as follows:
[0033] Signal transmission channel 1: main control module - electronic switch 1 - application module, used for direct signal transmission from the main control module to the application module;
[0034] Signal transmission channel 2: main control module - electronic switch 1 - level conversion chip - application module, used for signal conversion from main control module to application module;
[0035] Signal transmission channel three: application module - electronic switch 2 - main control module, used for direct signal transmission from application module to main control module;
[0036] Signal transmission channel four: application module - electronic switch 2 - level conversion chip - main control module, used for signal conversion from application module to main control module;
[0037] Through the design of the above four signal transmission channels, no matter whether the serial port signal of the slave device is TTL or RS232 level, the master device can automatically identify and match it, and automatically control the switch to end 2 (disconnect the level conversion circuit, signal pass through) or end 1 (signal needs to be converted, disconnect and pass through).
[0038] End 1 of the switch is output terminal one, and end 2 of the switch is output terminal two.
[0039] The two electronic switches are electrically connected to the main control module to achieve switch switching control;
[0040] The two electronic switches include an electronic switch 1 connected between the main control module and the level conversion chip, and an electronic switch 2 connected between the application module and the level conversion chip. The signal identification module is connected between the main control module and the application module.
[0041] The signal output interface 1 of the level conversion chip is connected to the RXD interface of the application module, and the signal output interface 2 of the level conversion chip is connected to the RXD interface of the main control module. The input end of the electronic switch 1 is connected to the main control module, the output end 1 of the electronic switch 1 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the application module. The input end of the electronic switch 1 is connected to the TXD interface of the main control module, the output end 1 of the electronic switch 1 is connected to the signal input interface 1 of the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the RXD interface of the application module.
[0042] The input end of the electronic switch 2 is connected to the application module, the output end 1 of the electronic switch 2 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the main control module. The input end of the electronic switch 2 is connected to the TXD interface of the application module, the output end 1 of the electronic switch 2 is connected to the signal input interface 2 of the level conversion chip, and the output end 2 of the electronic switch 2 is connected to the RXD interface of the main control module.
[0043] The software control part is:
[0044] (1) Actively send data from the device (application module):
[0045] The slave device sends TTL level:
[0046] If the serial port of the main device is TTL level, control the two switches (electronic switch 1 and electronic switch 2) to the 2nd end, and the TTL signal will pass directly (disconnect the signal conversion).
[0047] If the serial port of the master device is 232 level, control the two switches to end 1, and the signal is first converted to TTL level through the level conversion chip before communicating with the master device.
[0048] The slave device sends 232 level:
[0049] If the serial port of the master device is TTL level, control the two switches to end 1, and the signal is first converted to 232 level through the level conversion chip before communicating with the master device.
[0050] If the serial port of the main device is at 232 level, control the two switches to 2, and the 232 signal will pass directly (disconnect the signal conversion).
[0051] (2) The master device (master control module) actively sends data:
[0052] The master device sends TTL level:
[0053] If the slave device does not respond (or does not answer) or recognizes that the slave device is 232 level, control the two switches to end 1, and the signal is first converted to TTL level through the level conversion chip before communicating with the slave device.
[0054] If the slave device responds (or answers) or recognizes that the slave device is TTL level, the two switches are controlled to the 2 ends, and the TTL signal is passed directly (signal conversion is disconnected).
[0055] The master device sends 232 level:
[0056] If the slave device does not respond (or does not answer) or recognizes that the slave device is TTL level, the two switches are controlled to end 1, and the signal is first converted to TTL level through the level conversion chip before communicating with the slave device.
[0057] If the slave device responds (or answers) or recognizes that the slave device signal level is 232, control the two switches to end 2, and the 232 signal passes directly (disconnects the signal conversion).
[0058] The signal identification module includes an analog-to-digital converter capable of collecting positive and negative voltages. The analog-to-digital converter samples the waveform of the signal sent by the TXD interface of the application module and identifies the level type of the signal sent by the application module.
[0059] When the signal sent by the TXD interface of the application module is divided, the analog-to-digital converter collects the divided signal and identifies the signal type based on the TTL / 232 signal amplitude range and whether the signal has negative voltage. If there is negative voltage, it is a 232 signal.
[0060] You can also use a common analog-to-digital converter (ADC) that can only collect positive voltage to collect signals, but after the signal is divided, a bias voltage must be added (to ensure that the negative voltage of the 232 signal is greater than 0V after voltage division and bias voltage addition). Then convert the actual voltage, and the negative voltage is the 232 signal.
[0061] The way the signal recognition module recognizes the level type of the application module is as follows:
[0062]
[0063] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device, characterized in that: include: The main control module responsible for sending and receiving signals; A level conversion chip used to convert a signal of one voltage level into a signal of another voltage level; An application module that is responsible for receiving signals sent by the main control module and can send response signals; Two electronic switches for switching signal transmission channels; A signal identification module for identifying the type of signal level of the application module; The two electronic switches are electrically connected to the main control module to achieve switch switching control; The two electronic switches include an electronic switch 1 connected between the main control module and the level conversion chip, and an electronic switch 2 connected between the application module and the level conversion chip. The signal identification module is connected between the main control module and the application module.
2. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 1, characterized in that: The signal output interface 1 of the level conversion chip is connected to the RXD interface of the application module, and the signal output interface 2 of the level conversion chip is connected to the RXD interface of the main control module.
3. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 1, characterized in that: The input end of the electronic switch 1 is connected to the main control module, the output end 1 of the electronic switch 1 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the application module.
4. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 3, characterized in that: The input end of the electronic switch 1 is connected to the TXD interface of the main control module, the output end 1 of the electronic switch 1 is connected to the signal input interface 1 of the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the RXD interface of the application module.
5. The control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 1, characterized in that: The input end of the electronic switch 2 is connected to the application module, the output end 1 of the electronic switch 2 is connected to the level conversion chip, and the output end 2 of the electronic switch 1 is connected to the main control module.
6. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 5, characterized in that: The input end of the electronic switch 2 is connected to the TXD interface of the application module, the output end 1 of the electronic switch 2 is connected to the signal input interface 2 of the level conversion chip, and the output end 2 of the electronic switch 2 is connected to the RXD interface of the main control module.
7. A control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 1, characterized in that: The signal identification module includes an analog-to-digital converter capable of collecting positive and negative voltages. The analog-to-digital converter samples the waveform of the signal sent by the TXD interface of the application module and identifies the level type of the signal sent by the application module.
8. The control circuit for automatically matching the serial port level of a master device with the serial port level of a slave device according to claim 1, characterized in that: When the signal sent by the TXD interface of the application module is divided, the analog-to-digital converter collects the divided signal and identifies the signal type according to the TTL / 232 signal amplitude range and whether the signal has a negative voltage.
Citation Information
Patent Citations
Automatic serial server who matches of communication interface
CN204856480U