RS485 interface supporting hot plug detection, detection circuit and detection method

By setting the switch and voltage acquisition circuit in the RS485 interface, the detection of the increase or decrease of RS485 bus equipment and automatic address update are realized, which solves the problem of cumbersome equipment management in the existing technology and improves the work efficiency and reliability of the system.

CN119357099APending Publication Date: 2025-01-24SICHUAN HUSHAN ELECTRIC APPLIANCE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411539810.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The existing RS485 interface cannot determine the increase or decrease of the equipment on the bus in a timely manner, and cannot automatically update the address number of the equipment, resulting in cumbersome and time-consuming equipment management.

Method used

By setting up switching K1, K2, MCUs, and voltage collection circuits in the RS485 interface, the device changes on the voltage difference to detect the device on the circuit can be used to realize the heat plug -in detection, and the device address number is automatically updated with the program algorithm.

Benefits of technology

The heat insertion and automatic encoding of the device on the RS485 bus, the increase or deletion of the equipment on the bus does not affect the detection, which improves the reliability, rapid maintenance, redundancy, and timely recovery capabilities for disasters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357099A_ABST
    Figure CN119357099A_ABST
Patent Text Reader

Abstract

The invention discloses an RS485 communication interface supporting hot plug detection and a detection method thereof, relates to the technical field of communication, and solves the problems that the traditional RS485 interface cannot determine the increase and decrease conditions of equipment on a bus in time and cannot automatically update the address number of the equipment, and the key points of the technical scheme are as follows: the RS485 communication interface comprises an MCU, a switch K1, a switch K2, a voltage acquisition circuit, an RS485 transceiver and an RS485 port; the RS485 transceiver is connected with an RS485 port through a bus A and a bus B, the bus A is connected with a power supply VCC through a resistor Rp, the bus B is grounded through a resistor Rd, the bus A and the bus B are respectively connected with a switch K1 and a switch K2 in series, the rear ends of the switch K1 and the switch K2 are connected with a resistor Rs in parallel, the two ends of the resistor Rs are connected with a voltage acquisition circuit, the voltage acquisition circuit is connected with an MCU, and the MCU is connected with the control ends of the switch K1 and the switch K2; the voltage difference of the lines A and B is acquired through the cooperation of the switches K1 and K2, the MCU and the voltage acquisition circuit, so that the problem is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of communication technology, and more specifically to an RS485 interface supporting hot plug detection, a detection circuit and a detection method. Background Art

[0002] RS485 communication has been widely used in many fields such as industrial control, communication, instrumentation, security monitoring, smart home, lighting control, etc. However, most of the devices on the market that use RS485 communication do not support hot-swap detection, and when multiple RS485 devices are mounted on the RS485 bus, the devices on the bus need to be manually numbered. This process is cumbersome and time-consuming, thus affecting the working efficiency of the entire system.

[0003] Therefore, the present application provides an RS485 interface, a detection circuit and a detection method supporting hot plug detection to solve the above problems. Summary of the invention

[0004] The purpose of this application is to provide an RS485 interface, detection circuit and detection method that support hot plug detection, to solve the problem that the traditional RS485 interface cannot timely determine the increase or decrease of devices on the bus, and cannot automatically update the address number of the device according to the increase or decrease of the device; the above problem is solved by using switches K1, K2, MCU and voltage acquisition circuit to cooperate with the voltage difference of acquisition lines A and B.

[0005] The present application first provides an RS485 interface supporting hot plug detection, including: an MCU, a switch K1, a switch K2, a voltage collection circuit, an RS485 transceiver and an RS485 port; the RS485 transceiver is connected to the RS485 port through a bus A and a bus B, the bus A is connected to a power supply VCC through a resistor Rp, the bus B is grounded through a resistor Rd, the bus A and the bus B are connected in series with a switch K1 and a switch K2 respectively, the back ends of the switch K1 and the switch K2 are connected in parallel with a resistor Rs, both ends of the resistor Rs are connected to a voltage collection circuit, the voltage collection circuit is connected to the MCU, and the MCU is connected to the control ends of the switch K1 and the switch K2.

[0006] By adopting the above technical scheme, switches K1, K2, MCU and voltage acquisition circuit are set on the basis of the existing RS485 interface. The voltage difference between lines A and B is collected by switches K1, K2, MCU and voltage acquisition circuit, so that changes in equipment on the line can be detected through the voltage difference; and the addition or deletion of equipment on the line will not affect the detection work of the RS485 interface, and hot plug detection can be realized without power failure; in addition, after detecting changes in equipment on the line, the device address number can be automatically updated in conjunction with the program algorithm to improve the detection efficiency.

[0007] In a possible implementation, the voltage acquisition circuit uses a differential amplifier.

[0008] In a possible implementation manner, the switch K1 and the switch K2 are normally closed switches.

[0009] In a possible implementation, the switch K1 and the switch K2 are MOS tubes or analog switch chips.

[0010] The present application also provides a detection circuit supporting hot plug detection, including: a master control device and multiple slave devices, the master control device includes an RS485 interface supporting hot plug detection as described above, and the slave devices include a traditional RS485 interface or an RS485 interface supporting hot plug detection as described above; the RS485 interface of the master control device is connected to bus A and bus B; and multiple slave devices are connected to bus A and bus B via the RS485 interface.

[0011] The present application also provides a detection method supporting hot-swap detection, including: S1, the MCU of the master control device controls the switch K1 and the switch K2 to be disconnected at intervals, and the voltage difference Vo between the current bus A and the bus B is collected through the voltage collection circuit, and after the collection is completed, the switch K1 and the switch K2 are controlled to be closed; S2, the increase or decrease of the devices on the bus is analyzed by the change of the voltage difference Vo;

[0012] S3. Update the device address number according to the increase or decrease of devices on the bus; S4. Save the current voltage difference Vo and the address numbers of all current devices.

[0013] In a possible implementation, S2 includes: if the current voltage difference Vo is greater than the voltage difference Vo_old at the previous moment, it indicates that a device has been added; if the current voltage difference Vo is less than the voltage difference Vo_old at the previous moment, it indicates that a device has been reduced.

[0014] In a possible implementation, S2 includes: if the current voltage difference Vo is greater than or equal to the voltage difference Vo_old at the previous moment plus the error value, it indicates that a device has been added; if the current voltage difference Vo is less than or equal to the voltage difference Vo_old at the previous moment minus the error value, it indicates that a device has been reduced.

[0015] In a possible implementation, S3 includes: when a new device is added, the master device assigns an address number to the new device in an incremental manner based on the current address numbers; when a device is deleted, the master device traverses the current address numbers and clears the unresponsive address numbers.

[0016] In a possible implementation, when a device is deleted, the master control device sends a signal to the device corresponding to each address number according to the currently existing address numbers, and clears the address numbers that have no response.

[0017] Compared with the prior art, the present application has the following beneficial effects: it can support hot-swapping of devices and automatic encoding of devices on the RS-485 bus, and the addition or deletion of devices on the bus will not affect the normal progress of the detection, thereby improving the reliability, rapid maintainability, redundancy and timely recovery capabilities of the detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:

[0019] Figure 1 It is the circuit schematic diagram of the existing RS485 interface;

[0020] Figure 2 A circuit schematic diagram of an RS485 interface supporting hot plug detection provided in an embodiment of the present application;

[0021] Figure 3 A circuit schematic diagram of a detection circuit supporting hot plug detection provided in an embodiment of the present application;

[0022] Figure 4 A flow chart of a detection method supporting hot plug detection provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] Hereinafter, the term "include" or "may include" used in various embodiments of the present application indicates the presence of the function, operation or element applied for, and does not limit the increase of one or more functions, operations or elements. In addition, as used in various embodiments of the present application, the terms "include", "have" and their cognates are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the presence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or the possibility of increasing one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items.

[0024] In various embodiments of the present application, the expression "or" or "at least one of B or / and C" includes any combination or all combinations of the words listed at the same time. For example, the expression "B or C" or "at least one of B or / and C" may include B, may include C, or may include both B and C.

[0025] The expressions (such as "first", "second", etc.) used in the various embodiments of the present application may modify the various constituent elements in the various embodiments, but may not limit the corresponding constituent elements. For example, the above expressions do not limit the order and / or importance of the elements. The above expressions are only used for the purpose of distinguishing one element from other elements. For example, the first user device and the second user device indicate different user devices, although both are user devices. For example, without departing from the scope of the various embodiments of the present application, the first element may be referred to as the second element, and similarly, the second element may also be referred to as the first element.

[0026] It should be noted that if it is described that one component element is “connected” to another component element or is “connected to” another component element, the first component element may be directly connected to the second component element, and a third component element may be “connected” between the first component element and the second component element. Conversely, when one component element is “directly connected” to another component element or is “directly connected to” another component element, it can be understood that there is no third component element between the first component element and the second component element.

[0027] The terms used in the various embodiments of the application are only used to describe the purpose of specific embodiments and are not intended to limit the various embodiments of the application. As used herein, the singular form is intended to also include the plural form, unless the context clearly indicates otherwise. Unless otherwise limited, all terms used here (including technical terms and scientific terms) have the same meaning as the meanings commonly understood by ordinary technicians in the field of the various embodiments of the application. Terms (such as terms defined in generally used dictionaries) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having idealized meanings or too formal meanings, unless clearly defined in the various embodiments of the application.

[0028] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with examples and drawings. The illustrative implementation scheme of the present application and its description are only used to explain the present application and are not intended to limit the present application.

[0029] First, the prior art improved by the present application is explained in conjunction with the accompanying drawings so that those skilled in the art can understand the improved content of the present application.

[0030] See also Figure 1 As shown, Figure 1The circuit schematic diagram of the existing RS485 interface includes: an RS485 transceiver and an RS485 port, wherein the RS485 transceiver is connected to the RS485 port via bus A and bus B, bus A is connected to a power supply VCC via a resistor Rp, bus B is grounded via a resistor Rd, and a resistor Rs is connected between bus A and bus B.

[0031] When using the existing RS485 interface for communication, the RS485 interface of the control host is connected to the RS485 interface of the slave device through bus A and bus B. The traditional RS485 interface cannot promptly determine the increase or decrease of devices on the bus, and cannot automatically update the address number of the device according to the increase or decrease of the device.

[0032] Therefore, the present application provides an RS485 interface, a detection circuit, and a detection method that support hot plug detection to solve the above problems.

[0033] See also Figure 2 As shown, Figure 2 A circuit schematic diagram of an RS485 interface supporting hot plug detection provided by an embodiment of the present application. The RS485 interface supporting hot plug detection includes: an MCU, a switch K1, a switch K2, a voltage acquisition circuit, an RS485 transceiver, and an RS485 port; the RS485 transceiver is connected to the RS485 port through a bus A and a bus B, bus A is connected to a power supply VCC through a resistor Rp, bus B is grounded through a resistor Rd, bus A and bus B are connected in series with switches K1 and K2 respectively, and resistors Rs are connected in parallel at the back ends of switches K1 and K2, and voltage acquisition circuits are connected at both ends of resistor Rs, and the voltage acquisition circuits are connected to the MCU, and the MCU is connected to the control ends of switches K1 and K2.

[0034] Specifically, in the figure, the MCU sends a control signal SW_ctrl at a set frequency at intervals of time T. The control signal SW_ctrl can control the switch K1 and the switch K2 to be opened or closed at the same time. The voltage acquisition circuit U1 acquires the voltage difference between the bus A and the bus B through the resistor Rs and amplifies it to obtain the voltage difference Vo. The RS485 transceiver is connected to the RS485 port through the bus A and the bus B (twisted pair), and the RS485 port can be connected to other RS485 devices through the bus A and the bus B.

[0035] The RS485 interface supporting hot plug detection provided in the present application has the following principle for detecting changes in equipment on the line: when a new device is connected to the line, the resistor Rp in the RS485 interface of the new device is connected in parallel with the resistor Rp in the original line, and the resistor Rd in the RS485 interface of the new device is connected in parallel with the resistor Rd in the original line. After the parallel connection, the resistance value becomes smaller, resulting in a larger voltage difference Vo across the resistor Rs, that is, between lines A and B. By the same token, the situation is the opposite when a device exits the line. Therefore, the voltage difference Vo between lines A and B can be collected by the MCU, and the increase or decrease of equipment on the line can be determined based on the change in the voltage difference Vo.

[0036] The RS485 interface supporting hot-swap detection provided by the present application is improved in that: switches K1, K2, MCU and voltage acquisition circuit are set on the basis of the existing RS485 interface, and the voltage difference between lines A and B is acquired by switches K1, K2, MCU and voltage acquisition circuit, so that changes in equipment on the line can be detected through the voltage difference; and the addition or deletion of equipment on the line does not affect the detection work of the RS485 interface, and hot-swap detection can be achieved without power failure; in addition, after detecting changes in equipment on the line, the device address number can be automatically updated in cooperation with the program algorithm to improve the detection work efficiency.

[0037] In a possible implementation, the voltage acquisition circuit uses a differential amplifier.

[0038] Specifically, the voltage acquisition circuit acquires the voltage difference between line A and line B through resistor Rs. The voltages of line A and line B are differentially amplified to Vo by the voltage acquisition circuit. Vo=K*(Va-Vb), where K is the amplification factor of the voltage acquisition circuit, and Va and Vb are the voltage values ​​of lines A and B.

[0039] In a possible implementation manner, the switch K1 and the switch K2 are normally closed switches.

[0040] Specifically, switches K1 and K2 are in the on state by default, which does not affect RS485 communication. When the MCU sends the control signal SW_ctrl, switches K1 and K2 are disconnected at the same time, and the voltage across the resistor Rs is collected at this time; after the collection is completed, the MCU stops sending the control signal SW_ctrl, and switches K1 and K2 are restored to the default off state at the same time.

[0041] In a possible implementation, the switch K1 and the switch K2 are MOS tubes or analog switch chips.

[0042] Specifically, the switch K1 and the switch K2 are analog switches that can be controlled by electrical signals, and therefore, MOS tubes, analog switch chips, etc. can be preferably used.

[0043] It can be understood that the RS485 interface supporting hot plug detection provided by the present application is an improvement based on the existing RS485 interface. By adding switches K1, K2, MCU and voltage acquisition circuit that cooperate with each other, the detection of increase or decrease of equipment on the line can be realized; and the increase or decrease of equipment on the line does not affect the detection, supporting hot plug detection; the MCU can then execute a program algorithm to automatically update the address number of the device according to the increase or decrease of the device.

[0044] See also Figure 3 As shown, Figure 3 A circuit schematic diagram of a detection circuit supporting hot plug detection provided in an embodiment of the present application. The detection circuit includes: a master device and multiple slave devices, the master device includes an RS485 interface supporting hot plug detection as described above, and the slave device includes a traditional RS485 interface or an RS485 interface supporting hot plug detection as described above; the RS485 interface of the master device connects bus A and bus B; and multiple slave devices are connected to bus A and bus B via the RS485 interface.

[0045] Specifically, the main control device adopts Figure 2 The RS485 interface shown supports hot plug detection. The slave device can directly use Figure 1 The traditional RS485 interface shown (RS485 interface supporting hot plug detection may also be used). The RS485 interface of the master device leads to buses A and B, and the slave devices are connected to buses A and B.

[0046] The detection circuit supporting hot-plug detection provided by the present application has the principle of detecting changes in devices on the line as follows: after devices are mounted on buses A and B, the voltage difference between buses A and B is Vo = Vcc / (Rp / N+Rd / N+Rs / 2)*Rs / 2, where N is the number of connected devices, and Vo increases when N increases, and decreases when N decreases. Therefore, the change in the device on the bus can be determined by detecting the change in the current voltage difference between buses A and B compared to the voltage difference at the previous moment.

[0047] It can be understood that the detection circuit provided in the present application can detect changes in devices on the bus, and the detection is not affected by the increase or decrease of devices.

[0048] See also Figure 4 As shown, Figure 4A flow chart of a detection method supporting hot-plug detection provided in an embodiment of the present application. Based on the above detection circuit, the method includes: S1, the MCU of the master control device controls the switch K1 and the switch K2 to be disconnected at intervals, and the voltage difference Vo between the current bus A and the bus B is collected through the voltage collection circuit, and the switch K1 and the switch K2 are controlled to be closed after the collection is completed; S2, the increase or decrease of the devices on the bus is analyzed by the change of the voltage difference Vo; S3, according to the increase or decrease of the devices on the bus, the address number of the device is updated; S4, the current voltage difference Vo and the address numbers of all current devices are saved.

[0049] Specifically, the MCU of the master control device controls switches K1 and K2 to be disconnected at intervals of T, and then reads the current Vo value. After the Vo value is read successfully, K1 and K2 are closed and turned on; if the currently read Vo value is changed compared with the value Vo_old read last time, it means that there are devices added or removed on the bus; when there are devices added or removed on the bus, the master control device updates the current address number, increases the address number for the new device, and clears the address number for the deleted device; after automatically updating the code, the master control device saves the current address code and Vo value.

[0050] In a possible implementation, S2 includes: if the current voltage difference Vo is greater than the voltage difference Vo_old at the previous moment, it indicates that a device has been added; if the current voltage difference Vo is less than the voltage difference Vo_old at the previous moment, it indicates that a device has been reduced.

[0051] Specifically, the voltage difference Vo between buses A and B is Vcc / (Rp / N+Rd / N+Rs / 2)*Rs / 2, where N is the number of connected devices. Therefore, when the number of devices on the line increases, the voltage difference Vo will increase, and when the number of devices on the line decreases, the voltage difference Vo will decrease.

[0052] In another possible implementation, S2 includes: if the current voltage difference Vo is greater than or equal to the voltage difference Vo_old at the previous moment plus the error value, it indicates that a device has been added; if the current voltage difference Vo is less than or equal to the voltage difference Vo_old at the previous moment minus the error value, it indicates that a device has been reduced.

[0053] Specifically, considering the voltage rationality error δV caused by power supply noise, sampling accuracy and the like, when Vo ≥ Vo_old + δV, it indicates that there are more devices, and when Vo ≤ Vo_old – δV, it indicates that there are fewer devices.

[0054] In a possible implementation, S3 includes: when a new device is added, the master device assigns an address number to the new device in an incremental manner based on the current address numbers; when a device is deleted, the master device traverses the current address numbers and clears the unresponsive address numbers.

[0055] Furthermore, when a device is deleted, the master control device sends a signal to the device corresponding to each address number according to the currently existing address numbers, and clears the address numbers that have no response.

[0056] It can be understood that the detection method provided by the present application can support hot-swapping of devices and automatic encoding of devices on the RS-485 bus. The addition or deletion of devices on the bus will not affect the normal progress of the detection, thereby improving the reliability, rapid maintainability, redundancy and timely recovery capabilities of the detection.

[0057] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. RS485 interface supporting hot-swap detection, characterized in that: include: MCU, switch K1, switch K2, voltage acquisition circuit, RS485 transceiver and RS485 port; The RS485 transceiver is connected to the RS485 port via bus A and bus B, bus A is connected to power supply VCC via resistor Rp, bus B is grounded via resistor Rd, bus A and bus B are connected in series with switch K1 and switch K2 respectively, resistor Rs is connected in parallel at the back ends of switch K1 and switch K2, both ends of resistor Rs are connected to the voltage acquisition circuit, the voltage acquisition circuit is connected to the MCU, and the MCU is connected to the control ends of switch K1 and switch K2.

2. The RS485 interface supporting hot plug detection according to claim 1, characterized in that: The voltage acquisition circuit adopts a differential amplifier.

3. The RS485 interface supporting hot plug detection according to claim 1, characterized in that: The switch K1 and the switch K2 are normally closed switches.

4. The RS485 interface supporting hot plug detection according to claim 1, characterized in that: The switch K1 and the switch K2 are MOS tubes or analog switch chips.

5. A detection circuit supporting hot plug detection, characterized in that: include: A master control device and a plurality of slave devices, wherein the master control device comprises an RS485 interface supporting hot plug detection as described in any one of claims 1 to 4, and the slave devices comprise a traditional RS485 interface or an RS485 interface supporting hot plug detection as described in any one of claims 1 to 4; The RS485 interface of the main control device connects bus A and bus B; A plurality of slave devices are connected to the bus A and the bus B via RS485 interfaces.

6. A detection method supporting hot plug detection, characterized in that: Based on the detection circuit supporting hot plug detection as claimed in claim 5, it includes: S1, the MCU of the master control device controls the switch K1 and the switch K2 to be disconnected at intervals, and collects the voltage difference Vo between the current bus A and the bus B through the voltage collection circuit. After the collection is completed, the switch K1 and the switch K2 are controlled to be closed; S2. Analyze the increase or decrease of devices on the bus through the change of voltage difference Vo; S3, according to the increase or decrease of the device on the bus, update the address number of the device; S4. Save the current voltage difference Vo and the address numbers of all current devices.

7. The detection method supporting hot plug detection according to claim 6, characterized in that: S2 includes: if the current voltage difference Vo is greater than the voltage difference Vo_old at the previous moment, it means that a device has been added; if the current voltage difference Vo is less than the voltage difference Vo_old at the previous moment, it means that a device has been reduced.

8. The detection method supporting hot plug detection according to claim 6, characterized in that: S2 includes: if the current voltage difference Vo is greater than or equal to the voltage difference Vo_old at the previous moment plus the error value, it means that a device has been added; if the current voltage difference Vo is less than or equal to the voltage difference Vo_old at the previous moment minus the error value, it means that a device has been reduced.

9. The detection method supporting hot plug detection according to claim 6, characterized in that: S3 includes: when a new device is added, the master device assigns an address number to the new device in an incremental manner based on the current address number; when a device is deleted, the master device traverses the current address number and clears the unresponsive address number.

10. The detection method supporting hot plug detection according to claim 9, characterized in that: When a device is deleted, the master device sends a signal to the device corresponding to each address number according to the current address number, and clears the address number that has no response.