Serial communication interface switching circuit and electronic equipment

By identifying the voltage range of the serial communication signal through voltage sampling and control circuits, and automatically switching between RS232 and RS485 protocols using a multi-protocol transceiver, the problems of large circuit size, high cost and low reliability in the existing technology are solved, and convenient and efficient communication interface switching is achieved.

CN223582477UActive Publication Date: 2025-11-21CYG SUNRI CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202423092266.1
Authority / Receiving Office
CN · China
Patent Type
Utility models(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-11-21
Estimated Expiration
2034-12-13

AI Technical Summary

Technical Problem

Existing serial communication interface switching circuits are bulky, costly, inconvenient, and unreliable. Furthermore, relays cannot automatically switch between RS232 and RS485 interfaces, resulting in wasted hardware resources and reduced reliability.

Method used

By employing voltage sampling and control circuits, the RS232 and RS485 communication protocols are automatically switched by identifying serial communication signals in different voltage ranges. The signal conversion is achieved using a multi-protocol transceiver, eliminating the need for relay switching and simplifying circuit design.

Benefits of technology

It enables automatic switching between different communication protocols within a single communication circuit, reducing circuit size, lowering hardware costs, and improving convenience and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN223582477U_ABST
    Figure CN223582477U_ABST
Patent Text Reader

Abstract

The utility model discloses a serial communication interface switching circuit and electronic equipment, and belongs to the technical field of serial communication. A voltage sampling circuit samples the voltage of a first serial communication signal to output a sampled voltage; the control circuit is used for outputting a first control signal in response to the sampling voltage located in a first voltage interval and outputting a second control signal in response to the sampling voltage located in a second voltage interval; the communication circuit is used for converting the first serial communication signal into a second serial communication signal according to the first control signal, or converting the first serial communication signal into a third serial communication signal according to the second control signal; the control circuit is also used for executing corresponding actions based on the second serial communication signal or the third serial communication signal; wherein the second serial communication signal is based on an RS485 communication protocol; the third serial communication signal is based on an RS232 communication protocol; therefore, the size of the serial communication interface switching circuit is reduced, the hardware cost is reduced, and the use convenience and reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of serial communication, and particularly relates to a serial communication interface switching circuit and an electronic device. BACKGROUND

[0002] With the rapid development of power system technology, the demand for distribution network equipment is becoming more and more complex and variable, and the number of distribution network equipment is becoming larger and larger. The difference between distribution network equipment in different regions is mostly that the external terminal interface demand is different, that is, some distribution network equipment adopts an RS485 interface, and other distribution network equipment adopts an RS232 interface.

[0003] In traditional distribution network equipment, different interface types of circuits are usually designed according to project requirements, resulting in a large number of similar interface devices. In actual use, the utilization rate of part of the interface devices is low, causing waste of hardware resources of the distribution network equipment. At the same time, a large number of similar interface devices need to be manually adapted to different control circuits, which wastes a lot of manpower, and the manual adaptation failure rate is high, which increases the complexity of product management of the distribution network equipment and reduces the reliability of the product. For the above problems, the existing distribution network equipment circuit simultaneously welds an RS232 chip and an RS485 chip, connects an RS232 interface and an RS485 interface through a relay, and realizes switching of the RS232 interface and the RS485 interface through the switching relay. However, this scheme has a large circuit size, high hardware cost, and the relay cannot automatically switch the RS232 interface and the RS485 interface, which reduces the convenience of use. In addition, the relay is prone to failure during long-term use, and has low reliability. CONTENT OF THE INVENTION

[0004] The application aims to provide a serial communication interface switching circuit and an electronic device, and aims to solve the problems of a large size, high cost, low convenience and low reliability of the existing serial communication interface switching circuit.

[0005] The application embodiment provides a serial communication interface switching circuit, which comprises:

[0006] A voltage sampling circuit is configured to access a first serial communication signal, sample a voltage of the first serial communication signal, and output a sampling voltage.

[0007] A control circuit is connected with the voltage sampling circuit, configured to output a first control signal in response to the sampling voltage being located in a first voltage interval, and output a second control signal in response to the sampling voltage being located in a second voltage interval.

[0008] A communication circuit is connected with the voltage sampling circuit and the control circuit, configured to convert the first serial communication signal into a second serial communication signal according to the first control signal, or convert the first serial communication signal into a third serial communication signal according to the second control signal.

[0009] The control circuit is further configured to perform a corresponding action based on the second serial communication signal or the third serial communication signal.

[0010] The second serial communication signal is based on an RS485 communication protocol, and the third serial communication signal is based on an RS232 communication protocol.

[0011] In one of the embodiments, the first voltage interval is between a first preset voltage and a second preset voltage, and the second voltage interval is greater than the first preset voltage or less than the second preset voltage.

[0012] The first preset voltage is greater than the second preset voltage.

[0013] In one of the embodiments, the first serial communication signal includes a first sub-communication signal and a second sub-communication signal, and the voltage sampling circuit includes:

[0014] A first voltage sampling module, connected with the communication circuit and the control circuit, configured to sample a voltage of the first sub-communication signal to output a first sub-sampling voltage.

[0015] A second voltage sampling module, connected with the communication circuit and the control circuit, configured to sample a voltage of the second sub-communication signal to output a second sub-sampling voltage.

[0016] The control circuit is specifically configured to output the first control signal in response to the first sub-sampling voltage and the second sub-sampling voltage being located in the first voltage interval, and output the second control signal in response to the first sub-sampling voltage and / or the second sub-sampling voltage being located in the second voltage interval.

[0017] In one of the embodiments, the control circuit includes a microprocessor, a seventh resistor, an eighth resistor, a ninth resistor, a thirteenth resistor, and a fourteenth resistor.

[0018] The fifth general input and output end of the microprocessor is connected with the communication circuit as a first control signal output end of the control circuit and a second control signal output end of the control circuit, to output the first control signal or the second control signal; the third general input and output end of the microprocessor is connected with the first end of the eighth resistor, and the second end of the eighth resistor is connected with the microprocessor as a second serial communication signal input end and a third serial communication signal input end, to input the second serial communication signal or the third serial communication signal; the eighth general input and output end of the microprocessor is connected with the first end of the fourteenth resistor, and the second end of the fourteenth resistor is connected with the control circuit as a first sub-sampling voltage input end, to input the first sub-sampling voltage; the fourth general input and output end of the microprocessor is connected with the first end of the thirteenth resistor, and the second end of the thirteenth resistor is connected with the control circuit as a second sub-sampling voltage input end, to input the second sub-sampling voltage.

[0019] In one of the embodiments, the first serial communication signal includes a first sub-communication signal and a second sub-communication signal; and the voltage sampling circuit includes:

[0020] A first sampling module connected with the communication circuit and the control circuit, to divide the voltage of the first sub-communication signal, to output a third sub-sampling voltage;

[0021] A first detection module connected with the first sampling module, the communication circuit and the control circuit, to output a first detection signal in response to the first sub-communication signal being negative voltage;

[0022] A second sampling module connected with the communication circuit and the control circuit, to divide the voltage of the second sub-communication signal, to output a fourth sub-sampling voltage;

[0023] A second detection module connected with the second sampling module, the communication circuit and the control circuit, to output a second detection signal in response to the second sub-communication signal being negative voltage;

[0024] The control circuit is specifically configured to output the first control signal in response to the third sub-sampling voltage and the fourth sub-sampling voltage being in the first voltage interval, to output the second control signal in response to the third sub-sampling voltage and / or the fourth sub-sampling voltage being in the second voltage interval, or in response to the first detection signal or the second detection signal.

[0025] In one of the embodiments, the first sampling module includes a first resistor, a third resistor and a first capacitor.

[0026] The first end of the first resistor is connected with the communication circuit as a first sub-communication signal input end of the first sampling module, to input the first sub-communication signal; the second end of the first resistor, the first end of the third resistor and the first end of the first capacitor are connected together as a third sub-sampling voltage output end of the first sampling module, to output the third sub-sampling voltage; the second end of the third resistor and the second end of the first capacitor are connected to a power supply ground.

[0027] In one of the embodiments, the first detection module comprises a first optocoupler, a tenth resistor and a twelfth resistor.

[0028] The first end of the tenth resistor is connected with the first sampling module and the communication circuit as a first sub-communication signal input end of the first detection module, to input the first sub-communication signal; the negative electrode of the first optocoupler is connected with the second end of the tenth resistor, the collector of the first optocoupler and the first end of the twelfth resistor are connected together as a first detection signal output end of the first detection module, to output the first detection signal; the second end of the twelfth resistor is connected with a first power supply, the emitter of the first optocoupler and the positive electrode of the first optocoupler are connected to a power supply ground.

[0029] In one of the embodiments, the control circuit comprises:

[0030] An interface identification module connected with the voltage sampling circuit, configured to output a first identification signal in response to that the sampling voltage is located in the first voltage interval, and output a second identification signal in response to that the sampling voltage is located in the second voltage interval;

[0031] A control module connected with the interface identification module, configured to output the first control signal according to the first identification signal, and output the second control signal according to the second identification signal.

[0032] In one of the embodiments, the communication circuit comprises a multi-protocol transceiver.

[0033] The interface selection input end of the multi-protocol transceiver and the RS485 terminal enable end of the multi-protocol transceiver are used as the first control signal input end of the communication circuit and the second control signal input end of the communication circuit, and are connected with the control circuit to input the first control signal or the second control signal; the receiver output end of the multi-protocol transceiver is used as the second serial communication signal output end of the multi-protocol transceiver and the third serial communication signal output end of the multi-protocol transceiver, and is connected with the control circuit to output the second serial communication signal or the third serial communication signal; the RS485 positive receiver input end, the driver output end and the RS232 driver output end of the multi-protocol transceiver are used as the first serial communication signal input end of the multi-protocol transceiver together with the RS485 negative input end and the RS232 receiver input end of the multi-protocol transceiver, and are connected with the communication circuit to input the first serial communication signal.

[0034] The embodiment of the present application also provides an electronic device, which comprises the serial communication interface switching circuit.

[0035] Compared with the prior art, the embodiment of the present application has the beneficial effects that: the control circuit outputs the first control signal in response to the sampling voltage being located in the first voltage interval, the communication circuit converts the first serial communication signal into the second serial communication signal conforming to the RS232 communication protocol according to the first control signal, the control circuit outputs the second control signal in response to the sampling voltage being located in the second voltage interval, and the communication circuit converts the first serial communication signal into the third serial communication signal conforming to the RS485 communication protocol according to the second control signal, so that only one communication circuit is used to realize the selection of the communication signals of different communication protocols according to the different voltages of the first serial communication signal, without the need to separately set two communication circuits of the RS485 communication circuit and the RS232 communication circuit, and without the need to set a relay, so that the size of the serial communication interface switching circuit is reduced, the hardware cost is lowered, and the convenience and reliability of use are improved. BRIEF DESCRIPTION OF DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative effort.

[0037] Figure 1 A structural schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application;

[0038] Figure 2Another structural schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application is shown in FIG. 6.

[0039] Figure 3 Another structural schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application is shown in FIG. 6.

[0040] Figure 4 Another structural schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application is shown in FIG. 6.

[0041] Figure 5 A partial example circuit schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application is shown in FIG. 7.

[0042] Figure 6 Another partial example circuit schematic diagram of the serial communication interface switching circuit provided by an embodiment of the present application is shown in FIG. 8. DETAILED DESCRIPTION

[0043] In order to make the technical problems solved by the present application, the technical solutions and the beneficial effects clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.

[0044] It should be noted that when an element is referred to as being "fixed to" or "set on" another element, it can be directly on the other element or indirectly on the other element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or indirectly connected to the other element.

[0045] It should be understood that the terms "length", "width", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only used to facilitate the description of the present application and simplify the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application.

[0046] In addition, the terms "first", "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise specifically limited.

[0047] Figure 1A structural diagram of a serial communication interface switching circuit is shown, and only parts related to the embodiment are shown for the convenience of description. Details are as follows:

[0048] The serial communication interface switching circuit includes a voltage sampling circuit 10, a control circuit 20, and a communication circuit 30.

[0049] The voltage sampling circuit 10 is configured to access a first serial communication signal and sample a voltage of the first serial communication signal to output a sampling voltage.

[0050] The control circuit 20 is connected to the voltage sampling circuit 10 and configured to output a first control signal in response to the sampling voltage being in a first voltage interval and output a second control signal in response to the sampling voltage being in a second voltage interval.

[0051] The communication circuit 30 is connected to the voltage sampling circuit 10 and the control circuit 20 and configured to convert the first serial communication signal into a second serial communication signal according to the first control signal or convert the first serial communication signal into a third serial communication signal according to the second control signal.

[0052] The control circuit 20 is further configured to perform a corresponding action based on the second serial communication signal or the third serial communication signal.

[0053] The second serial communication signal is based on an RS485 communication protocol, and the third serial communication signal is based on an RS232 communication protocol.

[0054] By way of example and not limitation, the first voltage interval is between a first preset voltage and a second preset voltage, and the second voltage interval is greater than the first preset voltage or less than the second preset voltage.

[0055] The first preset voltage is greater than the second preset voltage.

[0056] The control circuit 20 can further output a power-on signal in response to the sampling voltage being in the first voltage interval or the sampling voltage being in the second voltage interval.

[0057] The communication circuit 30 is specifically configured to convert the first serial communication signal into the second serial communication signal according to the first control signal and the power-on signal or convert the first serial communication signal into the third serial communication signal according to the second control signal and the power-on signal.

[0058] It should be noted that the voltage sampling circuit 10 can output a low-level signal when stopping accessing the first serial communication signal, and the control circuit 20 stops outputting the power-on signal in response to the low-level signal, so that the communication circuit 30 stops working when stopping accessing the first serial communication signal, thereby reducing the power consumption of the communication circuit 30 when not accessing the first serial communication signal.

[0059] The control circuit 20 can also output a request to send (RTS) signal in response to the sampling voltage being in the first voltage interval, to improve the reliability of data transmission when the control circuit 20 and the communication circuit 30 perform RS485 communication.

[0060] In a specific implementation, when the first serial communication signal is transmitted on the communication bus based on the RS485 communication protocol, the voltage of the first serial communication signal is in the first voltage interval. In this case, there are two situations: in the first situation, the communication bus is in an idle state, and the first sub-sampling voltage is always high (the maximum high voltage is 5V), and the second sub-sampling voltage is always low (the minimum low voltage is 0V); in the second situation, the communication bus is in a communication state, and the first sub-sampling voltage is high or the second sub-sampling voltage is high, i.e., when the first serial communication signal complies with the RS485 protocol, the voltage range thereof is 0 to 5V.

[0061] When the first serial communication signal is transmitted on the communication bus based on the RS232 communication protocol, the voltage of the first serial communication signal is in the second voltage interval. In this case, the first sub-sampling voltage and the second sub-sampling voltage can both be high (greater than -15V and less than -5V) or low (greater than 5V and less than 15V), i.e., when the first serial communication signal complies with the RS232 protocol, the voltage range thereof is -15V to 5V or 5V to 15V.

[0062] In summary, in actual use, the first preset voltage can be set to 5V, and the second preset voltage can be set to 0V.

[0063] By skillfully utilizing the different voltage characteristics of the first serial communication signal under different communication protocols, setting the first preset voltage and the second preset voltage, and identifying different voltages of the first serial communication signal, serial communication signals of different protocols can be output, thereby improving the convenience of use.

[0064] By way of example, and not limitation, as further illustrated Figure 2 The first serial communication signal includes a first sub-communication signal and a second sub-communication signal; and the voltage sampling circuit 10 includes a first voltage sampling module 11 and a second voltage sampling module 12.

[0065] The first voltage sampling module 11 is connected to the communication circuit 30 and the control circuit 20, and is configured to sample the voltage of the first sub-communication signal to output a first sub-sampling voltage.

[0066] The second voltage sampling module 12 is connected to the communication circuit 30 and the control circuit 20, and is configured to sample the voltage of the second sub-communication signal to output a second sub-sampling voltage.

[0067] The control circuit 20 is specifically configured to output a first control signal in response to the first sub-sampling voltage and the second sub-sampling voltage being located in the first voltage interval, and output a second control signal in response to the first sub-sampling voltage and / or the second sub-sampling voltage being located in the second voltage interval.

[0068] In actual use, the first voltage sampling module 11 and the second voltage sampling module 12 can be built with resistors, or built with operational amplifiers, or built with special analog-to-digital conversion chips, etc. The specific circuit of the voltage sampling module is not limited in the present application, and existing circuits with voltage sampling function can be selected according to actual needs.

[0069] It should be noted that if the control circuit 20 does not support the negative voltage detection function, the control circuit 20 cannot recognize the sampling voltage as negative voltage (the control circuit defaults to 0V). Since the first serial communication signal is stopped from being accessed, the sampling voltage obtained by the control circuit 20 is also low (0V), so that the control circuit 20 cannot distinguish whether the communication circuit 30 is in an idle state or in an RS232 communication state at this time. If the control circuit 20 supports the negative voltage detection function, it can accurately determine that the first sub-sampling voltage or the second sub-sampling voltage is located in the second voltage interval when it is negative. Therefore, in the case that the control circuit 20 supports the negative voltage detection function, there is no need to additionally design a negative voltage detection circuit, and the first voltage sampling module 11 and the second voltage sampling module 12 can be directly used for sampling, which can simplify the peripheral circuit design and reduce the circuit size.

[0070] As an example but not limitation, as shown in Figure 3 The first serial communication signal includes a first sub-communication signal and a second sub-communication signal; and the voltage sampling module 11 includes a first sampling module 13, a first detection module 14, a second sampling module 15, and a second detection module 16.

[0071] The first sampling module 13 is connected with the communication circuit 30 and the control circuit 20, and is configured to sample the positive voltage of the first sub-communication signal to output a third sub-sampling voltage.

[0072] The first detection module 14 is connected with the first sampling module 13, the communication circuit 30 and the control circuit 20, and is configured to sample the negative voltage of the first sub-communication signal to output a first detection signal.

[0073] The second sampling module 15 is connected with the communication circuit 30 and the control circuit 20, and is configured to sample the positive voltage of the second sub-communication signal to output a fourth sub-sampling voltage.

[0074] The second detection module 16 is connected with the second sampling module 15, the communication circuit 30 and the control circuit 20, and is configured to sample the negative voltage of the second sub-communication signal to output a second detection signal.

[0075] The control circuit 20 is specifically configured to output the first control signal in response to the third sub-sampling voltage and the fourth sub-sampling voltage being located in the first voltage interval, and output the second control signal in response to the third sub-sampling voltage and / or the fourth sub-sampling voltage and / or the first detection signal and / or the second detection signal being located in the second voltage interval.

[0076] In the case that the control circuit 20 does not support the negative voltage detection function, the first detection module 14 can be used to detect the first sub-communication signal of the negative voltage, and the second detection module 16 can be used to detect the second sub-communication signal of the negative voltage, so as to realize the negative voltage detection function, thereby reducing the requirement on the performance of the microprocessor in the control circuit 20 and improving the adaptability of the serial communication interface switching circuit to different microprocessors.

[0077] By way of example, and not limitation, such computer-readable storage media can include Figure 4 As shown in the figure, the control circuit 20 includes an interface identification module 21 and a control module 22.

[0078] The interface identification module 21 is connected with the voltage sampling circuit 10, and is configured to output a first identification signal in response to the sampling voltage being located in the first voltage interval, and output a second identification signal in response to the sampling voltage being located in the second voltage interval.

[0079] The control module 22 is connected with the interface identification module 21, and is configured to output the first control signal according to the first identification signal, and output the second control signal according to the second identification signal.

[0080] In the case that the performance of the microprocessor in the control module 22 is low and is insufficient to support the realization of the logical function judgment, the interface identification module 21 can be additionally arranged to identify the sampling voltage, wherein the interface identification module 21 can be realized by using a programmable device such as a programmable logic gate array or a complex programmable logic device, thereby reducing the requirement on the performance of the microprocessor in the control module 22 and improving the adaptability of the serial communication interface switching circuit to different microprocessors.

[0081] Figure 5 A part of the serial communication interface switching circuit provided by the embodiment of the present application is shown in the figure, Figure 6 Another part of the serial communication interface switching circuit provided by the embodiment of the present application is shown in the figure, only the part related to the embodiment of the present application is shown, and the details are as follows:

[0082] As shown in the figure, Figure 5 The first voltage sampling module 11 includes a first resistor R1, a third resistor R3 and a first capacitor C1.

[0083] The first end of the first resistor R1 is connected with the communication circuit 30 as the first sub-communication signal input end of the first voltage sampling module 11 to input the first sub-communication signal; the second end of the first resistor R1, the first end of the third resistor R3 and the first end of the first capacitor C1 are connected together as the third sub-sampling voltage output end of the first voltage sampling module 11 to output the third sub-sampling voltage; and the second end of the third resistor R3 and the second end of the first capacitor C1 are connected to the power supply ground.

[0084] As shown in Figure 5 , the second voltage sampling module 12 comprises a second resistor R2, a fourth resistor R4 and a second capacitor C2.

[0085] The first end of the second resistor R2 is connected with the communication circuit 30 as the second sub-communication signal input end of the second voltage sampling module 12 to input the second sub-communication signal; the second end of the second resistor R2, the first end of the fourth resistor R4 and the first end of the second capacitor C2 are connected together as the fourth sub-sampling voltage output end of the second voltage sampling module 12 to output the fourth sub-sampling voltage; and the second end of the fourth resistor R4 and the second end of the second capacitor C2 are connected to the power supply ground.

[0086] As shown in Figure 5 , the control circuit 20 comprises a microprocessor U1, a seventh resistor R7, an eighth resistor R8, a ninth resistor R9, a thirteenth resistor R13 and a fourteenth resistor R14.

[0087] The fifth general input and output end PA5 of the microprocessor U1 is connected with the communication circuit 30 as the first control signal output end of the control circuit 20 and the second control signal output end of the control circuit 20 to output the first control signal or the second control signal; the third general input and output end PA3 of the microprocessor U1 is connected with the first end of the eighth resistor R8, the second end of the eighth resistor R8 is connected as the second serial communication signal input end of the microprocessor U1 and the third serial communication signal input end of the microprocessor U1 to input the second serial communication signal or the third serial communication signal; the eighth general input and output end PA0 of the microprocessor U1 is connected with the first end of the fourteenth resistor R14, the second end of the fourteenth resistor R14 is connected as the first sub-sampling voltage input end of the control circuit 20 to be connected with the first voltage sampling module 11 to input the first sub-sampling voltage; the fourth general input and output end PA4 of the microprocessor U1 is connected with the first end of the thirteenth resistor R13, the second end of the thirteenth resistor R13 is connected as the second sub-sampling voltage input end of the control circuit 20 to be connected with the second voltage sampling module 12 to input the second sub-sampling voltage.

[0088] As shown in Figure 6 , the first sampling module 13 comprises the first resistor R1, the third resistor R3 and the first capacitor C1.

[0089] The first end of the first resistor R1 is connected with the communication circuit 30 as the first sub-communication signal input end of the first sampling module 13 to input the first sub-communication signal; the second end of the first resistor R1, the first end of the third resistor R3 and the first end of the first capacitor C1 are connected together as the third sub-sampling voltage output end of the first sampling module 13 to output the third sub-sampling voltage; and the second end of the third resistor R3 and the second end of the first capacitor C1 are connected to the power supply ground.

[0090] The circuit is built only by resistors and capacitors, and has low cost.

[0091] As shown in Figure 6 The first detection module 14 includes a first optocoupler OP1, a tenth resistor R10 and a twelfth resistor R12.

[0092] The first end of the tenth resistor R10 is connected with the first sampling module 13 and the communication circuit 30 as the first sub-communication signal input end of the first detection module 14 to input the first sub-communication signal; the negative electrode of the first optocoupler OP1 is connected with the second end of the tenth resistor R10, the collector of the first optocoupler OP1 and the first end of the twelfth resistor R12 are connected together as the first detection signal output end of the first detection module 14 to output the first detection signal; the second end of the twelfth resistor R12 is connected with the first power supply, the emitter of the first optocoupler OP1 is connected with the positive electrode of the first optocoupler OP1, and the positive electrode of the first optocoupler OP1 is connected to the power supply ground.

[0093] As shown in Figure 6 The control circuit 20 includes a microprocessor U1, a seventh resistor R7, an eighth resistor R8, a ninth resistor R9, a thirteenth resistor R13 and a fourteenth resistor R14.

[0094] The fifth general input and output terminal PA5 of the microprocessor U1 is connected with the second control signal output terminal of the control circuit 20 and the communication circuit 30, to output the first control signal or the second control signal; the third general input and output terminal PA3 of the microprocessor U1 is connected with the first end of the eighth resistor R8, and the second end of the eighth resistor R8 is connected with the second serial communication signal input terminal and the third serial communication signal input terminal of the microprocessor U1, to input the second serial communication signal or the third serial communication signal; the eighth general input and output terminal PA0 of the microprocessor U1 is connected with the first end of the fourteenth resistor R14, and the second end of the fourteenth resistor R14 is connected with the third sub-sampling voltage input terminal of the control circuit 20, to input the third sub-sampling voltage; the seventh general input and output terminal PA7 of the microprocessor U1 is connected with the first detection signal input terminal of the control circuit 20, to input the first detection signal; the fourth general input and output terminal PA4 of the microprocessor U1 is connected with the first end of the thirteenth resistor R13, and the second end of the thirteenth resistor R13 is connected with the fourth sub-sampling voltage input terminal of the control circuit 20, to input the fourth sub-sampling voltage; and the sixth general input and output terminal PA6 of the microprocessor U1 is connected with the second detection signal input terminal of the control circuit 20, to input the second detection signal.

[0095] As shown in Figure 5 and Figure 6 , the control circuit 20 further comprises the fifth resistor R5, the sixth resistor R6 and the seventh resistor R7.

[0096] The first end of the fifth resistor R5, the first end of the sixth resistor R6 and the boot mode control terminal BOOT0 of the microprocessor U1 are connected with the start-up signal output terminal of the control circuit 20 and the communication circuit 30, to output the start-up signal; the first general output terminal PA1 of the microprocessor U1 is connected with the first end of the seventh resistor R7, and the second end of the seventh resistor R7 is connected with the transmission request signal output terminal of the control circuit 20 and the communication circuit 30, to output the transmission request signal; the second end of the fifth resistor R5 is connected with the first power supply, and the second end of the sixth resistor R6 is connected with the power supply ground.

[0097] The circuit is simple and reliable.

[0098] As shown in Figure 5 and Figure 6 , the communication circuit 30 comprises the multi-protocol transceiver U2.

[0099] The interface selection input end 485 / 232 of the multi-protocol transceiver U2 and the RS485 terminal enable end TE485 of the multi-protocol transceiver U2 are jointly used as the first control signal input end of the communication circuit 30 and the second control signal input end of the communication circuit 30, and are connected with the control circuit 20 to input the first control signal or the second control signal; the receiver output end RO of the multi-protocol transceiver U2 is used as the second serial communication signal output end of the multi-protocol transceiver U2 and the third serial communication signal output end of the multi-protocol transceiver U2, and is connected with the control circuit 20 to output the second serial communication signal or the third serial communication signal; the RS485 positive receiver input end, the driver output end and the RS232 driver output end A / TO of the multi-protocol transceiver U2 are jointly used as the first serial communication signal input end of the multi-protocol transceiver U2, and are connected with the communication circuit 30 to input the first serial communication signal.

[0100] The shutdown control end SHDN of the multi-protocol transceiver U2 is used as the power-on signal input end of the communication circuit 30, and is connected with the control circuit 20 to input the power-on signal; the RS485 receiver enable end RE485 of the multi-protocol transceiver U2 and the RS485 driver enable end DE485 of the multi-protocol transceiver U2 are used as the transmission request signal receiving end of the communication circuit 30, and are connected with the control circuit 20 to input the transmission request signal.

[0101] In actual use, when the first serial communication signal complies with the RS485 protocol, the voltage range thereof is 0-5V, when the first serial communication signal complies with the RS232 protocol, the voltage range thereof is greater than 5V and less than 15V, or greater than -15V and less than -5V, when the first serial communication signal is stopped from being transmitted, the sampling voltage is around 0V, therefore, the voltage difference range of the RS485 positive receiver input end, the driver output end and the RS232 driver output end A / TO of the multi-protocol transceiver U2 and the RS485 receiver negative input end and the RS232 receiver input end B / RI of the multi-protocol transceiver U2 is -15V to +15V, the maximum sampling voltage of the analog-to-digital converter of the microprocessor U1 is 3.3V, considering that the analog-to-digital converter is not full-scale, the maximum sampling voltage of the analog-to-digital converter can be set to 3V, the resistance ratio of the resistors R1 / R3 is (15-3) / 3=4 times, considering that there is a 5K pull-down resistor (not shown in the figure) outside the RS485 positive receiver input end, the driver output end and the RS232 driver output end A / TO of the multi-protocol transceiver U2, the sampling resistance can be selected according to the 10 times order (the greater the resistance, the smaller the communication interference of the terminal, but if the resistance is too large, the noise of the analog-to-digital converter reading the sampling voltage will be large), therefore, the first resistor R1 and the second resistor R2 can be 10K, the third resistor R3 and the fourth resistor R4 can be 43K, and the capacitance of the first capacitor C1 and the second capacitor C2 needs to consider the cut-off frequency of the communication, the commonly used baud rate frequency of the RS232 interface is 115200bps, according to the cut-off frequency of 10 times the baud rate, the cut-off frequency is 1.2MHz, and the capacitance of the first capacitor C1 and the second capacitor C2 can be 10pF.

[0102] The multi-protocol transceiver U2 has high integration, thereby reducing the size of the communication circuit 30.

[0103] As shown in Figure 6 , the second sampling module 15 includes the second resistor R2, the fourth resistor R4 and the second capacitor C2.

[0104] The first end of the second resistor R2 serves as the second sub-communication signal input end of the second sampling module 15 and is connected with the communication circuit 30 to input the second sub-communication signal, the second end of the second resistor R2, the first end of the fourth resistor R4 and the first end of the second capacitor C2 jointly serve as the fourth sub-sampling voltage output end of the second sampling module 15 and are connected with the control circuit 20 to output the fourth sub-sampling voltage, and the second end of the fourth resistor R4 and the second end of the second capacitor C2 are connected to the power supply ground.

[0105] As shown in Figure 6 , the second detection module 16 includes the second optoelectronic coupler OP2, the ninth resistor R9 and the eleventh resistor R11.

[0106] The first end of the ninth resistor R9 serves as the second sub-communication signal input terminal of the second detection module 16, and is connected to the second sampling module 15 and the communication circuit 30 to input the second sub-communication signal; the negative terminal of the second optocoupler OP2 is connected to the second end of the ninth resistor R9, and the collector of the second optocoupler OP2 and the first end of the eleventh resistor R11 together serve as the second detection signal output terminal of the second detection module 16, and are connected to the control circuit 20 to output the second detection signal; the second end of the eleventh resistor R11 is connected to the first power supply, and the emitter of the second optocoupler OP2 and the positive terminal of the second optocoupler OP2 are connected to the power supply ground.

[0107] The following is based on the working principle. Figure 5 and Figure 6 Further explanation is provided below:

[0108] When powered on, the multiprotocol transceiver U2 is in the off state.

[0109] like Figure 5 As shown, when the first serial communication signal is connected, the first end of the first resistor R1 and the RS485 positive receiver input, driver output, and RS232 driver output A / TO of the multi-protocol transceiver U2 are connected to the first sub-communication signal. The first resistor R1 and the third resistor R3 divide the voltage of the first sub-communication signal and output the first sub-sampling voltage from the second end of the first resistor R1 and the first end of the third resistor R3 to the second end of the fourteenth resistor R14. The first end of the second resistor R2 and the RS485 receiver negative input and RS232 receiver input B / RI of the multi-protocol transceiver U2 are connected to the second sub-communication signal. The second end of the second resistor R2 and the first end of the fourth resistor R4 output the second sub-sampling voltage to the second end of the thirteenth resistor R13.

[0110] If the first sub-sampling voltage and the second sub-sampling voltage are within the first voltage range, the startup mode control terminal BOOT0 of the microprocessor U1, the first terminal of the fifth resistor R5, and the first terminal of the sixth resistor R6 output a power-on signal to the shutdown control terminal SHDN of the multi-protocol transceiver U2. The fifth general-purpose input / output terminal PA5 of the microprocessor U1 outputs a first control signal to the interface selection input terminal 485 / 232 of the multi-protocol transceiver U2 and the RS485 terminal enable terminal TE485 of the multi-protocol transceiver U2. The multi-protocol transceiver U2 converts the first serial communication signal into a second serial communication signal according to the power-on signal and the first control signal. The second serial communication signal is output from the receiver output terminal RO of the multi-protocol transceiver U2 to the second terminal of the eighth resistor R8. The microprocessor U1 performs corresponding actions based on the second serial communication signal.

[0111] If the first sub-sampling voltage and / or the second sub-sampling voltage are within the second voltage range, the startup mode control terminal BOOT0 of the microprocessor U1, the first terminal of the fifth resistor R5, and the first terminal of the sixth resistor R6 output a power-on signal to the shutdown control terminal SHDN of the multi-protocol transceiver U2. The fifth general-purpose input / output terminal PA5 of the microprocessor U1 outputs a second control signal to the interface selection input terminal 485 / 232 of the multi-protocol transceiver U2 and the RS485 terminal enable terminal TE485 of the multi-protocol transceiver U2. The multi-protocol transceiver U2 converts the first serial communication signal into a third serial communication signal according to the power-on signal and the second control signal. The third serial communication signal is output from the receiver output terminal RO of the multi-protocol transceiver U2 to the second terminal of the eighth resistor R8. The microprocessor U1 performs corresponding actions based on the third serial communication signal.

[0112] When the first serial communication signal is not connected, the first sub-sampling voltage output from the second end of the first resistor R1 and the first end of the third resistor R3 is 0V, and the second sub-sampling voltage output from the second end of the second resistor R2 and the first end of the fourth resistor R4 is 0V. At this time, the microprocessor U1 stops outputting the power-on signal, and the multi-protocol transceiver U2 is in the power-off state.

[0113] like Figure 6 As shown, when the first serial communication signal is connected, the first end of the first resistor R1, the first end of the tenth resistor R10, and the RS485 positive receiver input, driver output, and RS232 driver output A / TO of the multi-protocol transceiver U2 are connected to the first sub-communication signal. The first resistor R1 and the third resistor R3 divide the voltage of the first sub-communication signal, and output the third sub-sampling voltage from the second end of the first resistor R1 and the first end of the third resistor R3 to the second end of the fourteenth resistor R14. When the voltage of the first sub-communication signal is negative, the first optocoupler OP1 is turned on, and the first detection signal is output from the collector of the first optocoupler OP1 and the first end of the twelfth resistor R12 to the seventh general-purpose input / output terminal PA7 of the microprocessor U1. The first terminal of the second resistor R2, the first terminal of the ninth resistor R9, and the negative input terminal of the RS485 receiver and the input terminal B / RI of the RS232 receiver of the multi-protocol transceiver U2 are connected to the second sub-communication signal. The second terminal of the second resistor R2 and the first terminal of the fourth resistor R4 output the fourth sub-sampling voltage to the second terminal of the thirteenth resistor R13. When the voltage of the second sub-communication signal is negative, the second optocoupler OP2 is turned on, and the second detection signal is output from the collector of the second optocoupler OP2 and the first terminal of the eleventh resistor R11 to the sixth general-purpose input / output terminal PA6 of the microprocessor U1.

[0114] If the third sub-sampling voltage and the fourth sub-sampling voltage are in the first voltage interval, the boot mode control terminal BOOT0 of the microprocessor U1, the first end of the fifth resistor R5 and the first end of the sixth resistor R6 output a start-up signal to the shutdown control terminal SHDN of the multi-protocol transceiver U2, the fifth general-purpose input / output terminal PA5 of the microprocessor U1 outputs a first control signal to the interface selection input terminal 485 / 232 of the multi-protocol transceiver U2 and the RS485 terminal enable terminal TE485 of the multi-protocol transceiver U2, and the multi-protocol transceiver U2 converts the first serial communication signal into a second serial communication signal according to the start-up signal and the first control signal, and outputs the second serial communication signal from the receiver output terminal RO of the multi-protocol transceiver U2 to the second end of the eighth resistor R8, and the microprocessor U1 performs corresponding actions based on the second serial communication signal.

[0115] In response to the third sub-sampling voltage and / or the fourth sub-sampling voltage being in the second voltage interval, or in response to the first detection signal or the second detection signal, the boot mode control terminal BOOT0 of the microprocessor U1, the first end of the fifth resistor R5 and the first end of the sixth resistor R6 output a start-up signal to the shutdown control terminal SHDN of the multi-protocol transceiver U2, the fifth general-purpose input / output terminal PA5 of the microprocessor U1 outputs a second control signal to the interface selection input terminal 485 / 232 of the multi-protocol transceiver U2 and the RS485 terminal enable terminal TE485 of the multi-protocol transceiver U2, and the multi-protocol transceiver U2 converts the first serial communication signal into a third serial communication signal according to the start-up signal and the second control signal, and outputs the third serial communication signal from the receiver output terminal RO of the multi-protocol transceiver U2 to the second end of the eighth resistor R8, and the microprocessor U1 performs corresponding actions based on the third serial communication signal.

[0116] When the access to the first serial communication signal is stopped, the third sub-sampling voltage output from the second end of the first resistor R1 and the first end of the third resistor R3 is 0V, and the fourth sub-sampling voltage output from the second end of the second resistor R2 and the first end of the fourth resistor R4 is 0V, at this time, the microprocessor U1 stops outputting the start-up signal, and the multi-protocol transceiver U2 is in a shutdown state.

[0117] The embodiment of the present application also provides an electronic device, which comprises the serial communication interface switching circuit.

[0118] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0119] The above-described embodiments are only used to illustrate the technical solutions of the present application, but not limit them; although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A serial communication interface switching circuit, characterized by The method comprises the following steps: The voltage sampling circuit is used for accessing a first serial communication signal, sampling the voltage of the first serial communication signal to output a sampling voltage; The control circuit is connected with the voltage sampling circuit, and is used for outputting a first control signal in response to the sampling voltage being located in a first voltage interval, and outputting a second control signal in response to the sampling voltage being located in a second voltage interval; The communication circuit is connected with the voltage sampling circuit and the control circuit, and is used for converting the first serial communication signal into a second serial communication signal according to the first control signal, or converting the first serial communication signal into a third serial communication signal according to the second control signal; The control circuit is further used for performing corresponding actions based on the second serial communication signal or the third serial communication signal; The second serial communication signal is based on an RS485 communication protocol, and the third serial communication signal is based on an RS232 communication protocol.

2. The serial communication interface switching circuit of claim 1, wherein, The first voltage interval is located between a first preset voltage and a second preset voltage; and the second voltage interval is greater than the first preset voltage or less than the second preset voltage. The first preset voltage is greater than the second preset voltage.

3. The serial communication interface switching circuit of claim 1, wherein, The first serial communication signal comprises a first sub-communication signal and a second sub-communication signal; and the voltage sampling circuit comprises: A first voltage sampling module is connected with the communication circuit and the control circuit, and is used for sampling the voltage of the first sub-communication signal to output a first sub-sampling voltage; A second voltage sampling module is connected with the communication circuit and the control circuit, and is used for sampling the voltage of the second sub-communication signal to output a second sub-sampling voltage; The control circuit is specifically used for outputting the first control signal in response to the first sub-sampling voltage and the second sub-sampling voltage being located in the first voltage interval, and outputting the second control signal in response to the first sub-sampling voltage and / or the second sub-sampling voltage being located in the second voltage interval.

4. The serial communication interface switching circuit of claim 3, wherein, The control circuit comprises a microprocessor, a seventh resistor, an eighth resistor, a ninth resistor, a thirteenth resistor and a fourteenth resistor; The fifth general input and output end of the microprocessor is connected with the communication circuit as a first control signal output end of the control circuit and a second control signal output end of the control circuit, to output the first control signal or the second control signal; the third general input and output end of the microprocessor is connected with the first end of the eighth resistor, and the second end of the eighth resistor is connected as a second serial communication signal input end of the microprocessor and a third serial communication signal input end of the microprocessor, to input the second serial communication signal or the third serial communication signal; the eighth general input and output end of the microprocessor is connected with the first end of the fourteenth resistor, and the second end of the fourteenth resistor is connected as a first sub-sampling voltage input end of the control circuit, to be connected with the first voltage sampling module to input the first sub-sampling voltage; the fourth general input and output end of the microprocessor is connected with the first end of the thirteenth resistor, and the second end of the thirteenth resistor is connected as a second sub-sampling voltage input end of the control circuit, to be connected with the second voltage sampling module to input the second sub-sampling voltage.

5. The serial communication interface switching circuit of claim 1, wherein, The first serial communication signal comprises a first sub-communication signal and a second sub-communication signal; the voltage sampling circuit comprises: A first sampling module connected with the communication circuit and the control circuit, for voltage division on the first sub-communication signal to output a third sub-sampling voltage; A first detection module connected with the first sampling module, the communication circuit and the control circuit, for outputting a first detection signal in response to the first sub-communication signal being negative voltage; A second sampling module connected with the communication circuit and the control circuit, for voltage division on the second sub-communication signal to output a fourth sub-sampling voltage; A second detection module connected with the second sampling module, the communication circuit and the control circuit, for outputting a second detection signal in response to the second sub-communication signal being negative voltage; The control circuit is specifically configured to output the first control signal in response to the third sub-sampling voltage and the fourth sub-sampling voltage being located in the first voltage interval, output the second control signal in response to the third sub-sampling voltage and / or the fourth sub-sampling voltage being located in the second voltage interval, or in response to the first detection signal or the second detection signal.

6. The serial communication interface switching circuit of claim 5, wherein, The first sampling module comprises a first resistor, a third resistor and a first capacitor; The first end of the first resistor is connected with the communication circuit as a first sub-communication signal input end of the first sampling module, to input the first sub-communication signal; the second end of the first resistor, the first end of the third resistor and the first end of the first capacitor are collectively connected as a third sub-sampling voltage output end of the first sampling module, to be connected with the control circuit to output the third sub-sampling voltage; the second end of the third resistor and the second end of the first capacitor are connected to a power supply ground.

7. The serial communication interface switching circuit of claim 5, wherein, The first detection module comprises a first optoelectronic coupler, a tenth resistor and a twelfth resistor; A first end of the tenth resistor is connected to a first sub-communication signal input end of the first detection module, and is connected to the first sampling module and the communication circuit to input the first sub-communication signal; a negative electrode of the first optoelectronic coupler is connected to a second end of the tenth resistor, a collector of the first optoelectronic coupler and a first end of the twelfth resistor are connected together to form a first detection signal output end of the first detection module, and are connected to the control circuit to output the first detection signal; a second end of the twelfth resistor is connected to a first power supply, and an emitter of the first optoelectronic coupler and a positive electrode of the first optoelectronic coupler are connected to a power supply ground.

8. The serial communication interface switching circuit of claim 1, wherein, The control circuit comprises: an interface identification module connected to the voltage sampling circuit, configured to output a first identification signal in response to the sampling voltage being in the first voltage interval, and output a second identification signal in response to the sampling voltage being in the second voltage interval; a control module connected to the interface identification module, configured to output the first control signal according to the first identification signal, and output the second control signal according to the second identification signal.

9. The serial communication interface switching circuit of claim 1, wherein, The communication circuit comprises a multi-protocol transceiver; an interface selection input end of the multi-protocol transceiver and an RS485 terminal enable end of the multi-protocol transceiver are connected together to form a first control signal input end of the communication circuit and a second control signal input end of the communication circuit, and are connected to the control circuit to input the first control signal or the second control signal; a receiver output end of the multi-protocol transceiver is connected to a second serial communication signal output end of the multi-protocol transceiver and a third serial communication signal output end of the multi-protocol transceiver, and is connected to the control circuit to output the second serial communication signal or the third serial communication signal; an RS485 positive receiver input end, a driver output end and an RS232 driver output end of the multi-protocol transceiver are connected together to form a first serial communication signal input end of the multi-protocol transceiver, and are connected to the communication circuit to input the first serial communication signal.

10. An electronic device, comprising: The serial communication interface switching circuit comprises the serial communication interface switching circuit according to any one of claims 1 to 9.

Citation Information

Cited By

  • Linear tandem type on-line monitoring system and fault self-recovery method thereof

    CN121740127A