An adaptive fault-tolerant and information reading circuit for RS-485 bus communication
By using an STM32F407ZET6 microcontroller to control MOSFETs and relays to automatically switch between the A and B lines of RS-485 communication, the problem of communication failure caused by incorrect wiring was solved, the system's fault tolerance was improved, and the information viewing process was simplified.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- SHENYANG HUARUAN TECH CO LTD
- Filing Date
- 2025-07-30
- Publication Date
- 2026-05-29
Smart Images

Figure CN224304165U_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication circuit technology, and in particular to an adaptive fault-tolerant and information reading circuit for RS-485 bus communication. Background Technology
[0002] RS-485 communication has been widely used in industrial control, traffic automation control, and other fields. Its high data transmission rate, good data transmission reliability, and effective noise suppression capabilities make it outstanding in many areas. Specific application scenarios include industrial control, traffic automation control, and fieldbus communication networks. RS-485 communication typically uses half-duplex communication, meaning that at any given time, the device can only be in either a transmitting or receiving state. It uses a master-slave architecture and differential signal transmission, requiring only the correct connection of two signal lines (A and B) for communication.
[0003] Because RS485 communication requires A to be connected to A and B to be connected to B, there is a possibility of incorrect A / B connection. Connecting A to B or B to A will cause communication failure. Utility Model Content
[0004] The purpose of this application is to provide an adaptive fault-tolerant and information reading circuit for RS-485 bus communication, which solves the problem of communication failure caused by incorrect connection of AB lines in the prior art, improves the system fault tolerance rate, and simplifies the steps of viewing 485 bus device information.
[0005] To achieve the above objectives, this application provides an adaptive fault-tolerant and information reading circuit for RS-485 bus communication, comprising:
[0006] The main control unit U1 is equipped with serial communication pins and I / O control pins;
[0007] The RS-485 transceiver U3 has its receiver RO connected to the serial port receive pin RX of the main control unit, its transmitter DI connected to the serial port transmit pin TX, and its enable control RE / DE connected to the I / O pin PA8 of the main control unit.
[0008] Device interface H1 includes differential signal lines A and B;
[0009] The signal switching module consists of MOSFET Q1 and single-pole double-throw relay K4.
[0010] The coil drive terminal of relay K4 is connected to the drain of MOSFET Q1, and the gate of MOSFET is connected to the control pin PD10 of main control unit U1;
[0011] The common terminals COM1 and COM2 of relay K4 are connected to the A and B signal output terminals of RS-485 transceiver U3, respectively;
[0012] The two sets of moving contacts NC1 / NO1 and NC2 / NO2 of relay K4 are cross-connected to lines A and B of device interface H1;
[0013] The clock pin SCL and data pin SDA of the display module U2 are connected to the PB6 and PB7 pins of the main control unit U1, respectively.
[0014] Furthermore, the moving contact connection of the relay K4 is as follows:
[0015] The first set of moving contacts NC1 is connected to device interface B line, and NO1 is connected to device interface A line;
[0016] The second set of moving contacts has NC2 connected to device interface A line and NO2 connected to device interface B line.
[0017] Furthermore, the main control unit U1 adopts an STM32F407ZET6 microcontroller and integrates a reset circuit, a high-speed crystal oscillator Y2, and a low-speed crystal oscillator Y1 to form a minimum system.
[0018] Furthermore, the display module U2 is an OLED display screen, which is connected via I... 2 The C protocol communicates with the main control unit U1.
[0019] Furthermore, it also includes a USB communication interface JP2, whose data pins are connected to the USB protocol pins of the main control unit U1.
[0020] Furthermore, it also includes a program download interface JP1, which is connected to the SWD debugging pin of the main control unit U1.
[0021] Furthermore, the RS-485 transceiver U3 is model MAX3485ESA, and its RE and DE pins are shorted and connected to the I / O pin PA8 of the main control unit U1.
[0022] Furthermore, the MOSFET Q1 is an N-channel MOSFET with its source grounded and its gate connected to the control pin PD10 of the main control unit U1 via a series current-limiting resistor.
[0023] Furthermore, the device interface H1 is a terminal block, with a terminating matching resistor R11 connected in parallel between its A and B lines.
[0024] Furthermore, it also includes a power conversion circuit to convert the external input voltage to 3.3V to power the main control unit and RS-485 transceiver U3.
[0025] As can be seen from the above, the technical solution provided in this application uses key components such as a microcontroller, an RS-485 communication transceiver, and a display screen. The microcontroller controls relays to achieve automatic switching between the A and B lines in RS-485 communication, and the display screen shows device information in real time. This effectively avoids communication failures caused by incorrect A and B line connections, improves system fault tolerance, ensures RS-485 communication quality, and simplifies the steps for viewing RS-485 bus device information. It provides strong support for the stable operation of communication systems in industrial control and other fields, and has good practicality and application value. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the microcontroller minimum system and peripheral circuit in an adaptive fault-tolerant and information reading circuit for RS-485 bus communication in an embodiment of this application.
[0027] Figure 2 This is a schematic diagram of the RS-485 communication section in an adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to an embodiment of this application. Detailed Implementation
[0028] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0029] In this embodiment of the utility model, the RS-485 communication circuit is mainly used in electronic control environments to connect various sensors, actuators, etc., to realize long-distance high-speed data transmission and low-power operation of multi-node communication devices.
[0030] To read device information, baud rate, address, parameter range, and real-time data from the RS-485 bus, this invention provides an adaptive fault-tolerant and information reading circuit for RS-485 bus communication. The overall circuit mainly consists of a RS-485 communication section, a microcontroller minimum system section, and a display section. (Please refer to...) Figure 1 and Figure 2 Specifically, it includes: a main control unit U1, which has serial communication pins and I / O control pins; an RS-485 transceiver U3, whose receiver RO is connected to the serial port receive pin RX of the main control unit, its transmitter DI is connected to the serial port transmit pin TX, and its enable control RE / DE is connected to the I / O pin PA8 of the main control unit; and a device interface H1, which includes differential signal lines A and B.
[0031] The signal switching module consists of a MOSFET Q1 and a single-pole double-throw relay K4. The coil drive terminal of relay K4 is connected to the drain of MOSFET Q1, and the gate of MOSFET Q1 is connected to the control pin PD10 of the main control unit U1. The common terminals COM1 and COM2 of relay K4 are connected to the A and B signal output terminals of RS-485 transceiver U3, respectively. The two sets of moving contacts NC1 / NO1 and NC2 / NO2 of relay K4 are cross-connected to the A and B lines of device interface H1.
[0032] The clock pin SCL and data pin SDA of the display module U2 are connected to the PB6 and PB7 pins of the main control unit U1, respectively.
[0033] U1 is the microcontroller in this invention, model STM32F407ZET6. JP1 is the download interface, JP2 is the USB interface, U2 is the display screen, Y1 is the low-speed crystal oscillator, and Y2 is the high-speed crystal oscillator. U3 is the RS-485 communication transceiver, Q1 is the MOSFET, K4 is the relay, and H1 is the 485 device interface.
[0034] Furthermore, the moving contact connection method of the relay K4 is as follows: NC1 of the first set of moving contacts is connected to the device interface B line, and NO1 is connected to the device interface A line; NC2 of the second set of moving contacts is connected to the device interface A line, and NO2 is connected to the device interface B line.
[0035] Furthermore, the main control unit U1 adopts an STM32F407ZET6 microcontroller and integrates a reset circuit, a high-speed crystal oscillator Y2, and a low-speed crystal oscillator Y1 to form a minimum system.
[0036] Furthermore, the display module U2 is an OLED display screen, which is connected via I... 2 The C protocol communicates with the main control unit U1.
[0037] Furthermore, it also includes a USB communication interface JP2, whose data pins are connected to the USB protocol pins of the main control unit U1.
[0038] Furthermore, it also includes a program download interface JP1, which is connected to the SWD debugging pin of the main control unit U1.
[0039] Furthermore, the RS-485 transceiver U3 is model MAX3485ESA, and its RE and DE pins are shorted and connected to the I / O pin PA8 of the main control unit U1.
[0040] Furthermore, the MOSFET Q1 is an N-channel MOSFET with its source grounded and its gate connected to the control pin PD10 of the main control unit U1 via a series current-limiting resistor.
[0041] Furthermore, the device interface H1 is a terminal block, with a terminating matching resistor R11 connected in parallel between its A and B lines.
[0042] The microcontroller's serial port is connected to the control chip for 485 communication. Pin 1 of U3 is connected to the receiver of serial port 1 on the microcontroller, and pin 4 of U3 is connected to the transmitter of serial port 1 for serial communication. Pin RE of U33 is the enable control pin for receiving data; it is active low to allow data reception. Pin DE of U33 is the enable control pin for transmitting data; it is active high to allow data transmission. Pins 2 and 3 of U3 are then connected to pin PA8 of the microcontroller to complete the communication connection on the microcontroller side. By controlling the level of pin PA8 on the microcontroller, the transmit and receive modes in 485 communication are switched.
[0043] The microcontroller's PD10 controls MOSFET Q1, which in turn controls relay K4. In the event of RS-485 communication failure, software can be used to switch communication lines A and B to check for correct device connections. Circuit operation and device information, such as baud rate, are displayed in real-time on the OLED screen. Pin 3 of screen U2 is connected to microcontroller PB6, and pin 4 of U2 is connected to microcontroller PB7.
[0044] Furthermore, it also includes a power conversion circuit to convert the external input voltage to 3.3V to power the main control unit and RS-485 transceiver U3, and also includes a filter circuit, crystal oscillator circuit, reset circuit and program download circuit.
[0045] This utility model embodiment avoids communication failures caused by incorrect connection of AB lines during assembly, provides strong support for ensuring the quality of 485 communication, and simplifies the steps for viewing device information on the 485 bus.
[0046] The foregoing description of various embodiments of this application is provided to those skilled in the art for illustrative purposes. It is not intended to be exhaustive or to limit the invention to a single disclosed embodiment. As mentioned above, various alternatives and variations of this application will be apparent to those skilled in the art to which the foregoing pertains. Therefore, while some alternative embodiments have been specifically discussed, other embodiments will be obvious or readily apparent to those skilled in the art. This application is intended to include all alternatives, modifications, and variations of the invention already discussed herein, as well as other embodiments falling within the spirit and scope of the foregoing application.
Claims
1. An adaptive fault-tolerant and information reading circuit for RS-485 bus communication, characterized in that, include: The main control unit (U1) is equipped with serial communication pins and I / O control pins; The RS-485 transceiver (U3) has its receiver (RO) connected to the serial port receive pin (RX) of the main control unit, its transmitter (DI) connected to the serial port transmit pin (TX), and its enable control pin (RE / DE) connected to the I / O pin (PA8) of the main control unit. The device interface (H1) includes differential signal lines A and B; The signal switching module consists of a MOSFET (Q1) and a single-pole double-throw relay (K4): The coil drive terminal of the relay (K4) is connected to the drain of the MOSFET (Q1), and the gate of the MOSFET is connected to the control pin (PD10) of the main control unit (U1). The common terminals (COM1, COM2) of the relay (K4) are connected to the A and B signal output terminals of the RS-485 transceiver (U3) respectively; The two sets of moving contacts (NC1 / NO1, NC2 / NO2) of the relay (K4) are cross-connected to the A and B lines of the device interface (H1); The display module (U2) has its clock pin (SCL) and data pin (SDA) connected to the PB6 and PB7 pins of the main control unit (U1), respectively.
2. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The moving contact connection method of the relay (K4) is as follows: The first set of moving contacts NC1 is connected to device interface B line, and NO1 is connected to device interface A line; The second set of moving contacts has NC2 connected to device interface A line and NO2 connected to device interface B line.
3. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The main control unit (U1) uses an STM32F407ZET6 microcontroller and integrates a reset circuit, a high-speed crystal oscillator (Y2), and a low-speed crystal oscillator (Y1) to form a minimum system.
4. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The display module (U2) is an OLED display screen, which is connected via I 2 The C protocol communicates with the main control unit (U1).
5. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, It also includes a USB communication interface (JP2), whose data pins are connected to the USB protocol pins of the host unit (U1).
6. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, It also includes a program download interface (JP1) and an SWD debug pin connected to the main control unit (U1).
7. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The RS-485 transceiver (U3) is model MAX3485ESA, and its RE and DE pins are shorted and connected to the I / O pin (PA8) of the main control unit (U1).
8. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The MOSFET (Q1) is an N-channel MOSFET with its source grounded and its gate connected to the control pin (PD10) of the main control unit (U1) via a series current-limiting resistor.
9. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, The device interface (H1) is a terminal block, with a terminating resistor (R11) connected in parallel between its A and B lines.
10. The adaptive fault-tolerant and information reading circuit for RS-485 bus communication according to claim 1, characterized in that, It also includes a power conversion circuit that converts the external input voltage to 3.3V to power the main control unit and RS-485 transceiver (U3).