RS485 and RS232 self-switching circuit
Patent Information
- Application Number
- CN202522251234.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2035-10-24
AI Technical Summary
[0005]本实用新型的目的是提供一种RS485与RS232自切换电路,用于解决现有技术中不能切换以及切换可靠性不高的技术问题
[0014]本实用新型的有益效果为:通过设置RS485通信电路、RS232通信电路、通信切换电路,其中,RS485通信电路包括:第一控制器、第一连接器,RS232通信电路包括:第二控制器、第二连接器,通信切换电路包括第三控制器,将第一控制器分别与第一连接器、第三控制器电连接,将第二控制器分别与第二连接器、第三控制器电连接,将第二连接器与第三控制器电连接,第二连接器向第三控制器发送触发信号,将第三控制器与主控制电连接,当第三控制器收到第二连接器的触发信号时,第三控制器此时开启RS232通信电路,即主控制器通过RS232通信电路进行通信,当第二连接器未发送触发信号时,第三控制器此时开启RS485通信电路,即主控制器通过RS485通信电路进行通信。该自切换电路实现简单,仅依靠硬件电路即可实现,并且电路功能可靠、稳定;实现了在主控制器的一个串口下,将RS232和RS485两种通信方式集成在一个装置上,且可以做到自适应。
Smart Images

Figure CN224803453U_ABST
Abstract
Description
Technical Field
[0001] This utility model belongs to the field of communication port switching technology, specifically relating to an RS485 and RS232 self-switching circuit. Background Technology
[0002] In existing technologies, both RS232 and RS485 interfaces are used for data transmission, but they have some significant differences. RS232 is a full-duplex communication standard that supports point-to-point data transmission, offering advantages such as simple wiring and wide compatibility. However, its transmission distance is relatively short (typically no more than 15 meters) and its anti-interference capability is weak, making it suitable for short-range communication. In contrast, RS485 uses differential signal transmission, features a half-duplex mode, supports multi-point communication (up to 32 nodes), has a transmission distance exceeding 1500 meters, and possesses strong noise immunity, making it more suitable for long-distance communication in industrial environments. However, RS485 requires additional control signals (such as an enable pin) to switch between transmit and receive states, increasing circuit complexity.
[0003] In practical applications, due to the wide variety of devices and inconsistent communication interfaces—some devices use RS232 interfaces while others use RS485 interfaces—the main controller terminal must be compatible with both interfaces to ensure seamless integration with various devices. However, embedded systems have limited processor resources and a limited number of UART (Universal Asynchronous Receiver / Transmitter) ports. Allocating separate UART ports for RS232 and RS485 interfaces would lead to excessive processor resource consumption, increased hardware costs, and wasted resources. In existing technologies, most solutions employ a discrete design, using multiple UART ports for interface expansion. However, this approach not only increases circuit complexity but also reduces system flexibility and scalability. To address the switching issue between RS232 and RS485 communication, Chinese utility model patent CN214376432U discloses an RS485 / RS232 switching circuit for a smart fusion terminal in a distribution area, which includes a 485 level conversion circuit, a 232 level conversion circuit, and an analog switch circuit. The 485 level conversion circuit connects to an external RS485 port, and the 232 level conversion circuit connects to an external RS232 interface. Both circuits are connected to an analog switch circuit, which in turn connects to the processor's UART port or other ports with communication capabilities. The RS485 and RS232 interfaces are multiplexed using the analog switch circuit to select the channel, sharing a single UART port. This circuit can communicate with both RS485 and RS232 interfaces, greatly expanding the types of downlink devices that can interact with the intelligent converged terminal in the distribution area. However, due to the reliance on the analog switch circuit, which inherently possesses on-resistance (RON) and parasitic capacitance, these non-ideal characteristics can cause signal edges to become smoothed (distorted) and increase signal rise / fall times when communication rates are high (e.g., reaching 115200 bps or higher for UART) or communication cables are long. This limits the maximum reliable communication rate and introduces the risk of bit errors.
[0004] A new RS485 to RS232 switching circuit is needed to solve the above-mentioned technical problems. Summary of the Invention
[0005] The purpose of this invention is to provide an RS485 and RS232 self-switching circuit to solve the technical problems of non-switching and low switching reliability in the prior art.
[0006] The technical solution of this utility model to solve its technical problem is as follows: An RS485 to RS232 self-switching circuit includes: an RS485 communication circuit, an RS232 communication circuit, and a communication switching circuit. The RS485 communication circuit includes: a first controller and a first connector. The RS232 communication circuit includes: a second controller and a second connector. The communication switching circuit includes: a third controller. The first controller is electrically connected to the first connector and the third controller. The second controller is electrically connected to the second connector and the third controller. The second connector is electrically connected to the third controller. The second connector sends a trigger signal to the third controller. The third controller is electrically connected to a main controller.
[0007] Preferably, the RS485 communication circuit further includes: a first resistor, a second resistor, a third resistor, and a first capacitor; the first pin of the first controller is electrically connected to the third controller as an input pin; the second and third pins of the first controller are connected and then electrically connected to the main controller port as port pins; the fourth pin of the first controller is electrically connected to the third controller as an output pin; the fifth pin of the first controller is grounded; the sixth pin of the first controller is electrically connected to one end of the second resistor, one end of the third resistor, and the second pin of the first connector; the other end of the third resistor is grounded; the seventh pin of the first controller is electrically connected to the other end of the second resistor, one end of the first resistor, and the first pin of the first connector; the other end of the first resistor is electrically connected to the power supply voltage; the eighth pin of the first connector is electrically connected to the power supply voltage and one end of the first capacitor; the other end of the first capacitor is grounded.
[0008] Preferably, the RS232 communication circuit further includes: a second capacitor, a third capacitor, a fourth capacitor, a fifth capacitor, and a sixth capacitor; the first and third pins of the second controller are electrically connected to the two ends of the fifth capacitor; the fourth and fifth pins of the second controller are electrically connected to the two ends of the sixth capacitor; the tenth pin of the second controller is an output pin and electrically connected to the third controller; the ninth pin of the second controller is an input pin and electrically connected to the third controller; the seventh pin of the second controller is electrically connected to the second pin of the second connector; the eighth pin of the second controller is electrically connected to the third pin of the second connector; the second and sixth pins of the second controller are electrically connected to one end of the third capacitor and one end of the fourth capacitor, respectively; the other ends of the third capacitor and the fourth capacitor are electrically connected to one end of the second capacitor and the fifteenth pin of the second controller and then grounded; the sixteenth pin of the second controller and the other end of the second capacitor are electrically connected to the power supply voltage; the fourth pin of the second connector is a trigger pin and electrically connected to the communication switching circuit; and the fifth pin of the second connector is grounded.
[0009] Preferably, the communication switching circuit further includes: a fourth resistor and a fifth resistor; the twelfth pin of the third controller is electrically connected to the first pin of the first controller; the first pin of the third controller is electrically connected to the fourth pin of the first controller; the fourteenth pin of the third controller is electrically connected to the ninth pin of the second controller; the fifth pin of the third controller is electrically connected to the tenth pin of the second controller; the sixteenth pin of the third controller is electrically connected to the power supply voltage; the thirteenth pin of the third controller is electrically connected as an input pin to the output pin of the main controller; the third pin of the third controller is electrically connected as an output pin to the input pin of the main controller; the tenth pin of the third controller is electrically connected to the fourth pin of the second connector and one end of the fourth resistor, the other end of the fourth resistor is grounded; the ninth and sixth pins of the third controller are electrically connected to one end of the fifth resistor, the other end of the fifth resistor is grounded; and the eighth pin of the third controller is grounded.
[0010] Preferably, the power supply voltage is 3.3V.
[0011] Preferably, the first controller is model GM75176E.
[0012] Preferably, the second controller is a MAX232 and the second connector is a DB9.
[0013] Preferably, the third controller is model 74HC4052.
[0014] The beneficial effects of this utility model are as follows: By setting up an RS485 communication circuit, an RS232 communication circuit, and a communication switching circuit, wherein the RS485 communication circuit includes a first controller and a first connector, the RS232 communication circuit includes a second controller and a second connector, and the communication switching circuit includes a third controller, the first controller is electrically connected to the first connector and the third controller respectively, the second controller is electrically connected to the second connector and the third controller respectively, the second connector is electrically connected to the third controller, the second connector sends a trigger signal to the third controller, and the third controller is electrically connected to the main controller. When the third controller receives the trigger signal from the second connector, the third controller activates the RS232 communication circuit, that is, the main controller communicates through the RS232 communication circuit. When the second connector does not send a trigger signal, the third controller activates the RS485 communication circuit, that is, the main controller communicates through the RS485 communication circuit. This self-switching circuit is simple to implement, relying only on hardware circuitry, and the circuit function is reliable and stable; it realizes the integration of RS232 and RS485 communication methods into one device under one serial port of the main controller, and can achieve self-adaptation. Attached Figure Description
[0015] Figure 1This is a circuit diagram of the RS485 communication circuit of this utility model; Figure 2 This is a circuit diagram of the RS232 communication circuit of this utility model; Figure 3 This is a circuit diagram of the communication switching circuit of this utility model. Detailed Implementation
[0016] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention.
[0017] This utility model discloses an RS485 and RS232 self-switching circuit, including: an RS485 communication circuit, an RS232 communication circuit, and a communication switching circuit. The RS485 communication circuit includes: a first controller U1 and a first connector J1. The RS232 communication circuit includes: a second controller U2 and a second connector J2. The communication switching circuit includes: a third controller U3. The first controller U1 is electrically connected to both the first connector J1 and the third controller U3. The second controller U2 is electrically connected to both the second connector J2 and the third controller U3. The second connector J2 is electrically connected to the third controller U3. The second connector J2 sends a trigger signal to the third controller U3. The third controller U3 is electrically connected to a main controller. Specifically, the first controller U1 is model GM75176E, the second controller U2 is model MAX232, the second connector J2 is model DB9, and the third controller U3 is model 74HC4052.
[0018] like Figure 1 As shown, the RS485 communication circuit further includes: a first resistor R1, a second resistor R2, a third resistor R3, and a first capacitor C1. The first pin of the first controller U1 is electrically connected to the third controller U3 as an input pin. The second and third pins of the first controller U1 are connected and then electrically connected to the main controller port as port pins. The fourth pin of the first controller U1 is electrically connected to the third controller U3 as an output pin. The fifth pin of the first controller U1 is grounded. The sixth pin of the first controller U1 is electrically connected to one end of the second resistor R2, one end of the third resistor R3, and the second pin of the first connector J1. The other end of the third resistor R3 is grounded. The seventh pin of the first controller U1 is electrically connected to the other end of the second resistor R2, one end of the first resistor R1, and the first pin of the first connector J1. The other end of the first resistor R1 is electrically connected to the power supply voltage VDD. The eighth pin of the first connector J1 is electrically connected to the power supply voltage VDD and one end of the first capacitor C1. The other end of the first capacitor C1 is grounded. The power supply voltage VDD is 3.3V.
[0019] like Figure 2As shown, the RS232 communication circuit further includes: a second capacitor C2, a third capacitor C3, a fourth capacitor C4, a fifth capacitor C5, and a sixth capacitor C6. The first and third pins of the second controller U2 are electrically connected to the two ends of the fifth capacitor C5, respectively. The fourth and fifth pins of the second controller U2 are electrically connected to the two ends of the sixth capacitor C6, respectively. The tenth pin of the second controller U2 is used as an output pin and is electrically connected to the third controller U3. The ninth pin of the second controller U2 is used as an input pin and is electrically connected to the third controller U3. The seventh pin of the second controller U2 is electrically connected to the second pin of the second connector J2. The connection is as follows: pin 8 of the second controller U2 is electrically connected to pin 3 of the second connector J2; pins 2 and 6 of the second controller U2 are electrically connected to one end of the third capacitor C3 and one end of the fourth capacitor C4, respectively; the other ends of the third capacitor C3 and the fourth capacitor C4 are electrically connected to one end of the second capacitor C2 and pin 15 of the second controller U2, and then grounded; pin 16 of the second controller U2 and the other end of the second capacitor C2 are electrically connected to the power supply voltage VDD; pin 4 of the second connector J2 serves as a trigger pin and is electrically connected to the communication switching circuit; pin 5 of the second connector J2 is grounded. The power supply voltage VDD is 3.3V.
[0020] like Figure 3 As shown, the communication switching circuit further includes: a fourth resistor R4 and a fifth resistor R5. The twelfth pin of the third controller U3 is electrically connected to the first pin of the first controller U1; the first pin of the third controller U3 is electrically connected to the fourth pin of the first controller U1; the fourteenth pin of the third controller U3 is electrically connected to the ninth pin of the second controller U2; the fifth pin of the third controller U3 is electrically connected to the tenth pin of the second controller U2; the sixteenth pin of the third controller U3 is electrically connected to the power supply voltage VDD; the thirteenth pin of the third controller U3 serves as an input pin and is electrically connected to the output pin of the main controller; the third pin of the third controller U3 serves as an output pin and is electrically connected to the input pin of the main controller; the tenth pin of the third controller U3 is electrically connected to the fourth pin of the second connector J2 and one end of the fourth resistor R4, with the other end of the fourth resistor R4 grounded; the ninth and sixth pins of the third controller U3 are electrically connected to one end of the fifth resistor R5, with the other end of the fifth resistor R5 grounded; and the eighth pin of the third controller U3 is grounded. The power supply voltage VDD is 3.3V.
[0021] In practical applications, when the third controller U3 receives a trigger signal from the second connector J2, it activates the RS232 communication circuit, allowing the main controller to communicate via RS232. When the second connector J2 does not send a trigger signal, the third controller U3 activates the RS485 communication circuit, allowing the main controller to communicate via RS485. This self-switching circuit can be implemented using hardware, and its function is reliable and stable. It integrates both RS232 and RS485 communication methods onto a single serial port of the main controller, and it can adapt to different communication modes.
[0022] Based on the embodiments of this utility model, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this utility model.
Claims
1. An RS485 to RS232 self-switching circuit, characterized in that, include: The system includes an RS485 communication circuit, an RS232 communication circuit, and a communication switching circuit. The RS485 communication circuit includes a first controller and a first connector. The RS232 communication circuit includes a second controller and a second connector. The communication switching circuit includes a third controller. The first controller is electrically connected to the first connector and the third controller. The second controller is electrically connected to the second connector and the third controller. The second connector is electrically connected to the third controller. The second connector sends a trigger signal to the third controller. The third controller is electrically connected to the main controller.
2. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The RS485 communication circuit further includes: a first resistor, a second resistor, a third resistor, and a first capacitor. The first pin of the first controller is used as an input pin and electrically connected to the third controller. The second and third pins of the first controller are connected and used as port pins and electrically connected to the main controller port. The fourth pin of the first controller is used as an output pin and electrically connected to the third controller. The fifth pin of the first controller is grounded. The sixth pin of the first controller is electrically connected to one end of the second resistor, one end of the third resistor, and the second pin of the first connector. The other end of the third resistor is grounded. The seventh pin of the first controller is electrically connected to the other end of the second resistor, one end of the first resistor, and the first pin of the first connector. The other end of the first resistor is electrically connected to the power supply voltage. The eighth pin of the first connector is electrically connected to the power supply voltage and one end of the first capacitor. The other end of the first capacitor is grounded.
3. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The RS232 communication circuit further includes: a second capacitor, a third capacitor, a fourth capacitor, a fifth capacitor, and a sixth capacitor. The first and third pins of the second controller are electrically connected to the two ends of the fifth capacitor, respectively. The fourth and fifth pins of the second controller are electrically connected to the two ends of the sixth capacitor, respectively. The tenth pin of the second controller is used as an output pin and is electrically connected to the third controller. The ninth pin of the second controller is used as an input pin and is electrically connected to the third controller. The seventh pin of the second controller is electrically connected to the second pin of the second connector. The eighth pin of the second controller is electrically connected to the third pin of the second connector. The second and sixth pins of the second controller are electrically connected to one end of the third capacitor and one end of the fourth capacitor, respectively. The other ends of the third capacitor and the fourth capacitor are electrically connected to one end of the second capacitor and the fifteenth pin of the second controller and then grounded. The sixteenth pin of the second controller and the other end of the second capacitor are electrically connected to the power supply voltage. The fourth pin of the second connector is used as a trigger pin and is electrically connected to the communication switching circuit. The fifth pin of the second connector is grounded.
4. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The communication switching circuit further includes: a fourth resistor and a fifth resistor; the twelfth pin of the third controller is electrically connected to the first pin of the first controller; the first pin of the third controller is electrically connected to the fourth pin of the first controller; the fourteenth pin of the third controller is electrically connected to the ninth pin of the second controller; the fifth pin of the third controller is electrically connected to the tenth pin of the second controller; the sixteenth pin of the third controller is electrically connected to the power supply voltage; the thirteenth pin of the third controller is electrically connected as an input pin to the output pin of the main controller; the third pin of the third controller is electrically connected as an output pin to the input pin of the main controller; the tenth pin of the third controller is electrically connected to the fourth pin of the second connector and one end of the fourth resistor, the other end of the fourth resistor is grounded; the ninth and sixth pins of the third controller are electrically connected to one end of the fifth resistor, the other end of the fifth resistor is grounded; and the eighth pin of the third controller is grounded.
5. The RS485 and RS232 self-switching circuit according to any one of claims 2-4, characterized in that: The power supply voltage is 3.3V.
6. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The model of the first controller is GM75176E.
7. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The second controller is model MAX232, and the second connector is model DB9.
8. The RS485 and RS232 self-switching circuit according to claim 1, characterized in that: The third controller is model 74HC4052.
Citation Information
Patent Citations
RS485 and RS232 switching circuit for intelligent fusion terminal in transformer area
CN214376432U