Automatic addressing method and system for 485 bus communication equipment
By using CRC check value as an addressing mark and dividing the number segment in the RS-485 bus network, the 485 bus host device automatically querys and determines the address of the functional device, solving the problem of address conflicts and forgetting, improving the efficiency of address search and avoiding bus signal superposition.
Patent Information
- Application Number
- CN202510573106.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2045-05-06
AI Technical Summary
In the RS-485 bus network, device address management has problems such as address conflict, address forgetting and high maintenance costs, resulting in bus signal superposition and communication interruption, and traditional protocols cannot actively detect conflicts.
By calculating the CRC check value of the functional device and configuring it as an addressing identifier, it is divided into multiple number segments on average. The 485 bus host device broadcasts and querys each number segment in turn. The functional device responds to existing instructions. The host device searches the number segment that feedbacks existing instructions. The functional device feedbacks address information within the specified time slot.
Automatic addressing of 485 bus communication equipment is realized, and the range of the address of the functional device is quickly determined, avoiding bus signal superposition, improving address search efficiency, and saving address query time.
Smart Images

Figure CN120091008A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of device communication methods, and particularly to a method and system for automatic addressing of 485 bus communication devices. Background Art
[0002] In an RS-485 bus network, all devices share the communication channel and achieve master-slave or peer-to-peer communication through unique addresses. However, there are problems in device address management such as address conflicts, address forgetting, and high maintenance costs. Specifically, when the devices leave the factory, the default addresses are unified (such as 0x01). If they are connected to the bus without manual modification, multiple devices will respond to the same instruction, resulting in superposition of bus signals (waveform distortion) and communication interruption. When engineers configure addresses on-site through DIP switches or software tools, duplicate addresses are likely to occur (especially in large-scale networks), and traditional protocols cannot actively detect conflicts. In addition, if the device address is forgotten, the current address cannot be obtained through software, and the stored address cannot be read by non-invasive means. Summary of the Invention
[0003] Embodiments of this application provide a method and system for automatic addressing of 485 bus communication devices to address functional devices arranged on the 485 bus.
[0004] Embodiments of this application provide a method for automatic addressing of 485 bus communication devices, including: Calculating the CRC check value of the functional device and configuring the CRC check value as an addressing identifier; Dividing the addressing identifier into multiple segments on average; The 485 bus master device broadcasts and queries each segment in turn. If a functional device exists in the queried segment, the functional device replies with an existence instruction, otherwise it does not respond; The 485 bus master device queries the address of the segment where the functional device feedbacks the existence instruction; After receiving the address query instruction, the functional device feeds back address information to the 485 bus master device within a specified time slot.
[0005] In a feasible implementation, if the 485 bus master does not receive the existence instruction feedback from the functional device, it queries the next segment.
[0006] In a feasible implementation, the addressing identifier is divided into 256 segments on average.
[0007] In a feasible implementation, the time slot is calculated by taking the remainder of 256 according to the addressing identifier.
[0008] In a feasible implementation, a modulo 256 is taken according to the addressing identifier, and the remainder is multiplied by 26 ms to obtain a time slot.
[0009] In a feasible implementation, a CRC check value of the functional device is calculated according to the ID identification of the functional device.
[0010] In a feasible implementation, the address information includes an addressing identifier and a 485 address.
[0011] In a feasible implementation, after the functional device feeds back address information to the 485 bus host device within a specified time slot, the 485 bus host device sends an address modification instruction to the 485 address fed back by the functional device.
[0012] In a second aspect, an embodiment of the present application provides a system using 485 bus communication, including a host device and a functional device, wherein the host device obtains the address of the functional device according to the method for automatic addressing of the 485 bus communication device described in any one of the first aspects.
[0013] The method for automatic addressing of 485 bus communication devices configures the CRC check value of the functional device as the addressing identifier, and evenly divides it into multiple number segments, which can quickly determine the range of the functional device address. Then, the 485 bus host device performs an address query on the number segment of the functional device feedback instruction, and the functional device feeds back the address information to the 485 bus host device within the specified time slot, ensuring that all functional devices in the same number segment respond in time-sharing to avoid bus signal superposition. Compared with the address global polling method in the prior art, the 485 bus device automatic addressing method of this application greatly improves the efficiency of searching for functional device addresses and saves address query time.
[0014] The host device in the system using 485 bus communication obtains the address of the functional device according to the above-mentioned method of automatic addressing of the 485 bus communication device, and thus has all the beneficial effects of the method of automatic addressing of the 485 bus communication device of any of the above-mentioned technical solutions, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings described herein are used to provide further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present application and do not constitute improper limitations on the present invention.
[0016] In the attached picture: Figure 1 This is a flow chart of a method for automatic addressing of 485 bus devices provided in one embodiment of the present application. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the technical solutions in this application, the following will clearly and completely describe the technical solutions in the embodiments of this application in combination with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.
[0018] In the description of the embodiments of this application, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of this application, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0019] In this application, unless otherwise clearly specified and defined, terms such as "installed", "connected", "coupled", "fixed", etc. shall be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or integrated; it may be a mechanical connection; it may be directly connected, or indirectly connected through an intermediate medium, and it may be the internal connection or the interaction relationship between two components, unless otherwise clearly defined. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0020] In this application, unless otherwise clearly specified and defined, the first feature being "on" or "under" the second feature may be that the first and second features are in direct contact, or the first and second features are indirectly in contact through an intermediate medium. Moreover, the first feature being "above", "over" and "on top of" the second feature may be that the first feature is directly above or obliquely above the second feature, or merely indicates that the first feature has a higher horizontal height than the second feature. The first feature being "under", "beneath" and "underneath" the second feature may be that the first feature is directly below or obliquely below the second feature, or merely indicates that the first feature has a lower horizontal height than the second feature.
[0021] In an RS-485 bus network, all devices share a communication channel and achieve master-slave or peer-to-peer communication through unique addresses. However, there are problems in device address management such as address conflicts, address forgetting, and high maintenance costs. Specifically, the default addresses of devices are unified when they leave the factory (such as 0x01). If they are connected to the bus without manual modification, multiple devices will respond to the same instruction, resulting in the superposition of bus signals (waveform distortion) and communication interruption. When engineers configure addresses on-site through DIP switches or software tools, duplicate addresses are likely to occur (especially in large-scale networks), and traditional protocols cannot actively detect conflicts. In addition, if the device address is forgotten, the current address cannot be obtained through software, and the stored address cannot be read by non-invasive means.
[0022] In related technologies, manual polling and troubleshooting methods, broadcast reset methods, and physical signal detection are applied to solve the above problems. However, the manual polling and troubleshooting method powers off and isolates each functional device one by one, and locates conflicts through the elimination method, which takes an extremely long time (N devices require N tests), has a huge workload, and there are complex situations such as non-power-off or non-disconnection on-site. The broadcast reset method needs to send a global reset command to reset all device addresses. This method requires the device to support reset response and may cause secondary conflicts (the addresses are still the same after multiple devices are reset simultaneously). The physical signal detection method judges conflicts by monitoring abnormal bus levels. However, it can only detect the existence of conflicts, cannot locate the conflicting devices, and has a high false alarm rate (electromagnetic interference will also cause abnormal levels).
[0023] To solve the above problems, the embodiments of the present application provide a method and system for automatic addressing of 485 bus communication devices.
[0024] Figure 1 It is a flowchart of a method for automatic addressing of 485 bus devices provided by an embodiment of the present application.
[0025] Refer to Figure 1 As shown, the embodiments of the present application provide a method for automatic addressing of 485 bus communication devices, including: S100: Calculate the CRC check value of the functional device and configure the CRC check value as an addressing identifier.
[0026] Exemplarily, the entire 485 communication bus is provided with a 485 bus host device and functional devices. The 485 bus host device communicates with the functional devices and controls their operations. Each functional device has a unique ID. Exemplarily, the ID can be the ID that comes with the microcontroller in the functional device when it leaves the factory. Calculate the CRC check value according to the ID of each functional device. The range of the CRC check value is 0 - 65535, and this CRC check value is configured as an addressing identifier with a range of 0 - 65535. It should be noted that the method of calculating the CRC check value according to the microcontroller ID is a prior art and will not be elaborated here. It can be understood that the 485 bus host device can be a controller, and the functional device can be a detection component equipped with a microcontroller system.
[0027] S200: Evenly divide the addressing identifier into multiple segments.
[0028] Exemplarily, the addressing identifier can be divided into 256 consecutive segments, with 256 values in each group, such as 0 - 255, 256 - 511,..., 65280 - 65535.
[0029] S300: The 485 bus host device broadcasts and queries each segment in sequence. If a functional device exists in the queried segment, the functional device replies with an existence instruction; otherwise, it does not respond.
[0030] Exemplarily, the 485 bus host device broadcasts and queries each segment in sequence. If the addressing identifier of a functional device is within the queried segment, the functional device replies with an existence instruction to the 485 bus host. If the addressing identifier of the functional device is not within the queried segment, the functional device does not respond. For example, number 00 represents the first segment, including 0 - 255, number 01 represents the second segment, including 256 - 511; and so on for all segments; the addressing identifier of a certain device is 5. When the 485 bus host device broadcasts and queries the segment numbered 00, the device determines that its addressing identifier 5 is within the range of the first segment (0 - 255), and thus responds to the 485 bus host device by replying with an existence instruction. Exemplarily, the existence instruction can be identified by one byte 5A.
[0031] After the 485 bus host device broadcasts and queries a certain segment, it waits for 40 ms to ensure that all functional devices within the segment complete their responses and feedbacks. If the 485 bus host receives the existence instruction sent by the functional device, the 485 bus host device determines that there is a functional device in the queried segment, and then conducts an address query for this segment. After the address query is completed, it broadcasts and queries the next segment. If the 485 bus host does not receive the existence instruction sent by the functional device, it continues to broadcast and query the next segment.
[0032] S400: The 485 bus host device conducts an address query for the segment where the functional device has replied with the existence instruction.
[0033] S500: After receiving the address query instruction, the functional device feeds back address information to the 485 bus host device within a specified time slot. The address information includes an addressing identifier and a 485 address.
[0034] Exemplarily, the time slot corresponding to the functional device can be obtained based on the addressing identifier. Specifically, the addressing identifier is calculated modulo 256 to obtain the remainder, and the remainder is multiplied by 26ms to obtain the time slot. After receiving the address query designation of the instruction number segment from the 485 bus host device, the functional device sends the address information to the 485 bus host device after the calculated time slot time. Exemplarily, the addressing identifier of a functional device is 258, then the functional device feeds back the address information to the 485 bus host device after 2*26=52ms. It can be understood that the functional device feeds back the address information to the 485 bus host device within the specified time slot to ensure that all functional devices in the same number segment respond in time-sharing and avoid bus signal superposition.
[0035] When the 485 bus host device receives a response from a functional device, determines that a functional device exists in a certain number segment and sends an address query command to the number segment, it needs to wait 6700ms before querying the next number segment.
[0036] Take 4800 baud rate as an example to calculate the time. Other baud rates are calculated according to the ratio. At 4800 baud rate, 1 byte takes about 2ms, and 3.5 bytes take about 7ms to judge a frame of data. 26ms is calculated based on the response time and fault tolerance time of the measurement point at 4800 baud rate.
[0037] In some other examples, after the functional device feeds back address information to the 485 bus host device in a specified time slot, the 485 bus host device sends an address modification instruction to the 485 address fed back by the functional device. It can be understood that the unique addressing identifier is used to bind the functional device, and the address is directly modified through the broadcast instruction without physical contact or disassembly operation, which is particularly suitable for explosion-proof and high-risk environments.
[0038] In a second aspect, an embodiment of the present application provides a system using 485 bus communication, including a host device and a functional device, wherein the host device obtains the address of the functional device according to the method for automatic addressing of a 485 bus communication device described in any one of the first aspects. The method for automatic addressing of a 485 bus communication device in any of the technical solutions in the above schemes is included, and thus has all the beneficial effects of the method for automatic addressing of a 485 bus communication device in any of the technical solutions in the above schemes, which will not be repeated here.
[0039] It is easily understandable that those skilled in the art can combine, split, reorganize, etc. the embodiments provided in this application to obtain other embodiments on the basis of several embodiments provided in this application, and these embodiments do not exceed the protection scope of this application.
[0040] The above specific implementation manners further elaborate in detail the purpose, technical solutions, and beneficial effects of the embodiments of this application. It should be understood that the above are only the specific implementation manners of the embodiments of this application, and are not used to limit the protection scope of the embodiments of this application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of this application shall be included within the protection scope of the embodiments of this application.
Claims
1. A method for automatic addressing of 485 bus communication equipment, characterized in that: include: Calculate a CRC check value of a functional device, and configure the CRC check value as an addressing identifier; Dividing the addressing identifier into multiple number segments evenly; The 485 bus host device broadcasts and queries each number segment in turn. If there is a functional device in the queried number segment, the functional device replies with an existence instruction, otherwise it does not respond. The 485 bus host device performs address query on the number segment of the instruction fed back by the functional device; After receiving the address query instruction, the functional device feeds back the address information to the 485 bus host device within a specified time slot.
2. The method for automatic addressing of 485 bus communication equipment according to claim 1, characterized in that: If the 485 bus host does not receive the existence instruction fed back by the functional device, it will query the next number segment.
3. The method for automatic addressing of 485 bus communication equipment according to claim 1, characterized in that: The addressing identifier is evenly divided into 256 number segments.
4. The method for automatic addressing of 485 bus communication equipment according to claim 3, characterized in that: The time slot is calculated by taking modulo 256 according to the addressing identifier.
5. The method for automatic addressing of 485 bus communication equipment according to claim 4, characterized in that: The modulo 256 is calculated according to the addressing identifier, and the remainder is multiplied by 26 ms to obtain a time slot.
6. The method for automatic addressing of 485 bus communication equipment according to claim 1, characterized in that: The CRC check value of the functional device is calculated according to the ID identification of the functional device.
7. The method for automatic addressing of 485 bus communication equipment according to claim 1, characterized in that: The address information includes an addressing identifier and a 485 address.
8. The method for automatic addressing of 485 bus communication equipment according to claim 7, characterized in that: After the functional device feeds back address information to the 485 bus host device within a specified time slot, the 485 bus host device sends an address modification instruction to the 485 address fed back by the functional device.
9. A system using 485 bus communication, characterized in that: It comprises a host device and a functional device, wherein the host device obtains the address of the functional device according to the method for automatic addressing of a 485 bus communication device according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for dissolving an address conflict in the modbus RTU standard protocol
CN111083026A
Method for addressing integrated circuit on bus and corresponding equipment
CN112148629A
Automatic equipment adding method and system
CN113949628A
Equipment physical address quick retrieval method based on universal address bus
CN114448943A
Automatic addressing method and system and storage medium
CN115665091A
Cited By
Self-adaptive node addressing method and system suitable for multi-node intelligent equipment system
CN121547440A