Method for automatically distributing device ID on bus
By automatically assigning device IDs on the RS485 communication bus through the master station equipment, the problem of time-consuming and laborious manual ID setting is solved, enabling flexible access and removal of devices, simplifying operations and reducing costs.
Patent Information
- Application Number
- CN202511839620.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-02-27
AI Technical Summary
In RS485 communication bus networking, the allocation of device IDs requires manual setting, which is time-consuming, labor-intensive, and prone to errors. Furthermore, when devices are replaced or added, they need to be set again, which can easily lead to ID conflicts and communication failures.
The master station automatically assigns IDs to slave devices. Using the ID assignment line and RS485 bus connection, it enables device power-on reset, broadcast commands, and heartbeat interaction. It automatically assigns and manages the IDs of slave devices and supports the dynamic addition, replacement, and removal of devices.
It simplifies the workload of on-site staff, reduces the complexity of manual setup, supports flexible access and removal of equipment, reduces cable costs, and simplifies development and testing due to the consistency of equipment hardware and software.
Smart Images

Figure CN121585494A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication control, and more particularly to a method for automatically assigning device IDs on a bus. Background Technology
[0002] Currently, RS485 communication bus networking requires manual ID assignment for each device on the bus. Furthermore, when replacing or adding devices, new IDs must be assigned to the new devices, while avoiding ID duplication. This process is time-consuming, labor-intensive, and prone to errors. ID assignment conflicts can paralyze bus communication. If there are many devices on the bus, troubleshooting becomes extremely difficult and time-consuming. Summary of the Invention
[0003] In view of this, the present invention aims to propose a method for automatically assigning device IDs on a bus, which can automatically assign IDs to multiple slave devices through a master station device without manual intervention, is simple to operate, convenient to use, and has stable performance.
[0004] To achieve the above objectives, the technical solution of the present invention is implemented as follows: a method for automatically assigning device IDs on a bus, comprising the following steps: The bus connects one master station device and multiple slave station devices. The master station device is networked with all slave station devices via an RS485 bus. The master station device is connected to the input ID allocation line of the first slave station device via an ID allocation line. The output ID allocation line of the first slave station device is connected to the input ID allocation line of the second slave station device. The output ID allocation line of the second slave station device is connected to the input ID allocation line of the third slave station device. Subsequent slave station devices are connected in this manner. The output ID allocation line of the last slave station device is left floating. Step 1: In the initial power-on state, reset all slave device IDs to their default values, and set the digital output level of the output ID allocation line controlled by each slave device to a low level; when all slave devices detect that the digital input signal of the input ID allocation line connected to their own device by the previous device is low, they do not respond to any broadcast commands received on the RS485 bus. Step 2: The master station device pulls the input ID assignment line of the first slave device connected to it high and broadcasts a command to the RS485 bus to set the ID of the default ID device to 1. The first slave device connected to the master station device responds to the command to set the ID to 1, and the ID of the first slave device is assigned to 1. The IDs of the remaining slave devices remain the default IDs. Step 3: After assigning ID 1 to the first slave device, the master device sends a command to the first slave device with ID 1, instructing it to set its output ID assignment line to high level. Step 4: The master station device broadcasts a command to the RS485 bus to set the ID of the default ID device to 2. The second slave device connected to the first slave device responds to the command to set its ID to 2. The ID of the second slave device is assigned to 2, and the IDs of the remaining slave devices remain the default IDs. Step 5: Repeat steps 3 and 4 to sequentially assign IDs to all slave devices connected in sequence on the bus until no slave device responds to the repeated sending of the command to assign a default ID device to a certain ID. Step 6: After completing the ID allocation, the master station device checks the bus at regular intervals to see if there are any removed, replaced, or newly added slave devices. If an ID needs to be reassigned, the master station device reassigns IDs to all online slave devices on the bus.
[0005] Furthermore, in step 1, during the initial power-on state, the master station device sends a device ID reset command to the device IDs of all slave devices sequentially via the RS485 communication bus, resetting all slave device IDs to their default values. Simultaneously, when the device IDs are restored to their default IDs, all slave devices set the digital output level of their controlled output ID allocation lines to a low level.
[0006] Furthermore, in step 2, when the master station device pulls the ID allocation line high, the input ID allocation line of the first slave station device is at a high level, and the input ID allocation lines of the remaining slave station devices other than the first slave station device are at a low level; at this time, the IDs of all slave station devices are in the default ID state.
[0007] Furthermore, in step 4, when the master station device broadcasts a command to the RS485 bus to set the ID of the default ID device to 2, the IDs of the remaining slave devices other than the first slave device are all default IDs, and the input ID allocation line of the second slave device is high, while the input ID allocation lines of the other default ID devices other than the second slave device are all low.
[0008] Furthermore, the master station is located at the first position in the entire system, and the order in which all slave devices are connected to the system can be arbitrarily changed. The master station controls the ID allocation process of all slave devices. The structure and software program of the RS485 communication part of all slave devices are exactly the same. New slave devices can be connected to the bus, and one or more slave devices can be removed.
[0009] Furthermore, when a new slave device needs to be added to the bus, first connect the new slave device to the bus, and then connect the input ID assignment line of the new slave device to the output ID assignment line of the current end slave device.
[0010] Furthermore, in step 6, the master station device broadcasts a command to the RS485 bus at regular intervals, asking if a device with a default ID exists. When a new slave device joins, the input ID allocation line of the newly joined slave device is high and the ID of the newly joined device is the default ID. The newly joined slave device responds to this command. After receiving the response from the newly joined slave device, the master station device determines that a new slave device has joined the communication bus. Then, the master station device sends an ID reset command to reset the IDs of all slave devices. Then, the master station device repeats steps 1 to 5 to reassign IDs to all slave devices on the bus.
[0011] Furthermore, in step 6, after the ID allocation is completed, the master device and the slave device periodically exchange heartbeat messages to confirm whether the slave device is online normally. That is, the master device sends a heartbeat command to each slave device at regular intervals, and the corresponding slave device responds to the heartbeat command. If a slave device is removed from the bus network, the master device will not be able to receive the heartbeat response of the removed slave device. The master device determines that the slave device has been removed. At this time, the master device will broadcast a command to the RS485 bus at regular intervals to inquire whether the ID of the removed slave device exists. If a slave device that was removed from the network reconnects to the communication network, the reconnected slave device will respond to the master device's query for the existence of the ID. After receiving the response from the reconnected slave device, the master device determines that the removed slave device has been reconnected to the communication network. Then, the master device will repeat steps 1 to 5 to reassign IDs to all slave devices on the bus.
[0012] Furthermore, in step 6, once the master station device determines that a slave device has been removed, the master station device will periodically broadcast a command to the RS485 bus asking whether the ID of the removed slave device exists. If the removed slave device does not reconnect to the communication network, after the master device sends a command to inquire whether the ID of the removed slave device exists, the master device will not receive a response from the removed slave device within the specified time for receiving the slave device's response command. The master device will mark this slave device as offline, and the master device will continue to communicate and interact normally with other slave devices.
[0013] Furthermore, in step 6, if a slave device is removed from the bus network and replaced with a new slave device, the ID of the newly replaced slave device is the default ID, and its input ID assignment line is high. The master device will broadcast a command to the RS485 bus at intervals to inquire whether a device with the default ID exists. The newly replaced slave device responds to this command. After receiving the response from the newly replaced slave device, the master device determines that a new slave device has joined the communication bus. Then, the master device sends an ID reset command to reset the IDs of all slave devices. Then, the master device repeats the operations of steps 1 to 5 to reassign IDs to all slave devices on the bus.
[0014] Compared with existing technologies, the method for automatically assigning device IDs on a bus described in this invention has the following advantages: (1) With the method described in this invention, RS485 communication bus networking does not require manual setting of device IDs. After the networking wiring is completed, the master station device will automatically assign IDs to other slave station devices, which effectively simplifies the workload of on-site staff. (2) Supports adding one or more new slave devices to the RS485 bus, removing one or more slave devices, or replacing slave devices. The master device automatically reassigns the IDs of all slave devices without the need to manually set the device IDs. (3) The wiring method is simple. Each device only needs to be connected to an RS485 bus, an input ID distribution line, and an output ID distribution line to complete the automatic networking, saving the cost of wiring and the complexity of implementation; (4) The hardware of the RS485 communication part of the slave device and the software of the RS485 networking communication part are completely identical. When developing slave devices with different functions, this part of the hardware and software design can be directly reused, and the development and testing workload is small. Attached Figure Description
[0015] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 A schematic diagram showing the connection between the master station equipment and the slave station equipment.
[0016] Explanation of reference numerals in the attached figures: 1. Master station equipment; 2. First slave station equipment; 3. Second slave station equipment; 4. End slave station equipment; 5. Bus; 6. First ID allocation line; 7. Second ID allocation line. Detailed Implementation
[0017] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0018] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0019] like Figure 1 As shown, this invention provides a method for automatically assigning device IDs on a communication bus. The method involves sequentially assigning communication IDs to multiple slave devices on a communication bus, which is an RS485 bus. The bus 5 contains a master communication device 1 and several slave communication devices. The master device 1 is located at one end of the communication bus 5. The master assigns IDs to all slave devices sequentially via ID assignment lines cascaded with the slave devices and the RS485 communication bus 5. Upon detecting a new slave device joining, the master device 1 sends an ID reset command to reset the IDs of all slave devices and reassigns all slave device IDs, enabling dynamic addition of slave devices. This mechanism allows for flexible ID assignment to slave devices on the RS485 bus 5, requiring only one internal communication port of the MCU, without occupying additional communication ports in each device, and without using electronic switches to switch the internal circuitry. Furthermore, the method supports dynamic addition, replacement, or removal of slave devices without reconfiguration of the slave devices. Specifically, the method includes the following steps: Bus 5 connects a master station device 1 and multiple slave station devices. The master station device 1 and the slave station devices are connected via RS485 bus 5 and ID allocation lines. The slave station devices are connected sequentially via ID allocation lines. Specifically, the master station device 1 is networked with each slave station device via RS485 bus 5. The master station device 1 is connected to the input ID allocation line of the first slave station device (first slave station device 2) via ID allocation lines. The output ID allocation line of the first slave station device (first slave station device 2) is connected to the input ID allocation line of the second slave station device (second slave station device 3). The output ID allocation line of the second slave station device (second slave station device 3) is connected to the input ID allocation line of the third slave station device. Subsequent slave station devices are connected sequentially in this manner. The output ID allocation line of the last slave station device (end slave station device 4) is left floating. Master station device 1 is responsible for detecting whether there are slave devices without assigned IDs via RS485 bus 5, controlling the ID reset of each slave device, and assigning an ID to each slave device. The ID assignment line is responsible for notifying whether the slave device accepts the ID assignment command.
[0020] All slave devices have identical RS485 communication sections, allowing for flexible reordering of connection. Only one master device (1) can exist on a single communication bus (5), but multiple slave devices can be cascaded sequentially within the bus. Master device 1 and the first slave device 2 are connected via the first ID distribution line (6). Master device 1 uses the I / O port connected to the first ID distribution line (6) for digital output, while the first slave device 2 uses its I / O port for digital input. The first slave device 2 and the second slave device 3 are connected via the second ID distribution line (7). The first slave device 2 uses its I / O port connected to the second ID distribution line (7) for digital output, while the second slave device 3 uses its I / O port for digital input, and so on for subsequent slave devices. Step 1: Connect the master station device 1 and several slave devices to the RS485 bus 5 and the ID allocation line of each device according to the connection method described above. Upon initial power-up, the master station device 1 sequentially sends a device ID reset command to the device IDs of all slave devices via the RS485 communication bus 5, resetting all slave device IDs to their default values. Simultaneously, each slave device sets its controlled output ID allocation line to a low level when its device ID is restored to its default ID. When any slave device detects that the input signal connected to its input ID allocation line from the previous device is low, it does not respond to any broadcast commands received on the RS485 bus 5. Step 2: Master device 1 pulls the first ID allocation line 6 connected to it high and broadcasts a command to the RS485 bus 5 to set the ID of the default ID device to 1. At this time, the IDs of all slave devices are the default IDs. After master device 1 pulls the first ID allocation line 6 connected to it high, the input ID allocation line of the first slave device 2 is at a high level, and the input ID allocation lines of the remaining slave devices are at a low level. Therefore, only the first slave device 2 responds to the command to set the ID to 1, and the ID of the first slave device 2 is assigned to 1. The IDs of the remaining slave devices remain the default IDs. Step 3: After master station device 1 assigns ID 1 to the first slave station device 2, it sends a command to the first slave station device 2 with ID 1 to set the output ID assignment line of the first slave station device 2 to a high level. Step 4: Master device 1 broadcasts a command to RS485 bus 5 to set the ID of the default ID device to 2. At this time, the IDs of the remaining slave devices other than the first slave device 2 are all default IDs, and the input ID allocation line of the second slave device 3 is high. The input ID allocation lines of the other default ID devices other than the second slave device 3 are all low. Therefore, only the second slave device 3 connected to the first slave device 2 responds to the command to set the ID to 2. The ID of the second slave device 3 is assigned to 2, and the IDs of the remaining slave devices remain default IDs. Step 5: Repeat steps 3 and 4, sequentially assigning IDs to all slave devices connected in sequence on bus 5 until no slave device responds to repeated commands to assign a default ID. At this point, master device 1 determines that all slave devices in the completed bus 5 network connection have been assigned a specific ID, thus completing the automatic ID assignment for all slave devices on bus 5. In the description of this invention, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, features defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0021] Step 6: After completing the ID allocation, the master station device checks the bus at regular intervals to see if there are any removed, replaced, or newly added slave devices. If an ID needs to be reassigned, the master station device reassigns IDs to all online slave devices on the bus.
[0022] In practical applications, the master station device 1 is located at the first position in the entire system. The order in which all slave devices are connected to the system can be arbitrarily changed. The master station device 1 controls the ID allocation process of all slave devices. The structure and software program of the RS485 communication part of all slave devices are exactly the same. New slave devices can be connected to the bus 5, and one or more slave devices can also be removed.
[0023] When a new slave device needs to be added to bus 5, proceed to step 7.
[0024] Step 7: First, connect the newly added slave device to bus 5. Then, connect the input ID allocation line of the newly added slave device to the output ID allocation line of the current end slave device 4. The master device 1 broadcasts a command to the RS485 bus 5 at regular intervals, asking if a default ID device exists. When a new slave device is added, the input ID allocation line of the newly added slave device is high and the ID of the newly added device is the default ID. The newly added slave device responds to this command. After receiving the response from the newly added slave device, the master device 1 confirms that a new slave device has joined the communication bus 5. Then, the master device 1 sends an ID reset command to reset the IDs of all slave devices. Then, the master device 1 repeats steps 1 to 5 to reassign IDs to all slave devices on the bus 5. The newly added slave device will also be assigned an ID.
[0025] After the IDs are assigned, master device 1 and slave devices periodically exchange heartbeat messages to confirm whether the slave devices are online. That is, master device 1 sends a heartbeat command to each slave device at regular intervals, and the corresponding slave devices respond to the heartbeat command. If a slave device is removed from the bus 5 network, master device 1 will not receive the heartbeat response from the removed slave device. Master device 1 determines that the slave device has been removed. At this time, master device 1 will broadcast a command to RS485 bus 5 at regular intervals to inquire whether the ID of the removed slave device exists, so as to confirm whether the removed slave device has been restored. It should be noted that the ID number of the removed slave device at this time is the ID number assigned by master device 1, not the default ID number. Therefore, it will respond to the command from master device 1 inquiring whether the slave device with this ID exists.
[0026] When one of the slave devices on bus 5 goes offline abnormally, and communication with the slave device is restored after a period of time, step 8 is executed.
[0027] Step 8: If the removed slave device reconnects to the communication network, the reconnected slave device will respond to the command sent by the master device 1 asking if the ID exists. After receiving the response from the reconnected slave device, the master device 1 determines that the removed slave device has been reconnected to the communication network. Then, the master device 1 will repeat the operations from steps 1 to 5 to reassign IDs to all slave devices on bus 5.
[0028] Taking the removal of the second slave device 3 as an example. When the second slave device 3 is removed, the master device 1 cannot receive the heartbeat command response from the second slave device 3. At this time, the master device 1 will broadcast a command to the bus 5 at regular intervals to inquire whether the ID 2 of the second slave device 3 exists and whether it is back online. If the connection of the second slave device 3 is restored, the master device 1 will repeat steps 1 to 5 to reassign IDs to all devices on the bus 5.
[0029] If one of the slave devices on bus 5 goes offline abnormally, and communication with that slave device does not resume after a period of time, then step 9 is executed.
[0030] Step 9: When a slave device is removed from the bus 5 network, the master device 1 will broadcast a command to the bus 5 at regular intervals to ask if the ID of the removed slave device exists. If no reply is received from the slave device after a period of time, the master device 1 will mark the slave device as offline, and the master device 1 will continue to communicate and interact normally with other slave devices.
[0031] When one of the slave devices on bus 5 goes offline abnormally, and the slave device is replaced with a new slave device, and the new slave device is connected to the communication network, then step 10 is executed.
[0032] Step 10: When a slave device is removed from the bus 5 network and replaced with a new slave device, the new slave device's ID is the default ID, and the input ID allocation line is high. Master device 1 will periodically broadcast a command to bus 5 asking if a device with the default ID exists. The new slave device responds to this command. After receiving the response, master device 1 confirms that a new slave device has joined the communication bus. Then, master device 1 sends an ID reset command to reset the IDs of all slave devices. Master device 1 then repeats steps 1 to 5, reassigning IDs to all slave devices on bus 5. Since the new slave device has the default ID after replacement, it will reply to master device 1's command asking if a device with the default ID exists.
[0033] In summary, master station device 1 is located at the beginning of the entire system. All other slave devices can freely change their access order. Furthermore, it supports the removal, replacement, or addition of new slave devices during operation. Master station device 1 can reassign IDs to all slave devices in the system. The hardware and software of the RS485 automatic ID assignment function for slave devices are completely identical, greatly simplifying the development and deployment of slave devices.
[0034] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for automatically assigning device IDs on a bus, characterized in that, Includes the following steps: The bus connects one master station device and multiple slave station devices. The master station device is networked with all slave station devices via an RS485 bus. The master station device is connected to the input ID allocation line of the first slave station device via an ID allocation line. The output ID allocation line of the first slave station device is connected to the input ID allocation line of the second slave station device. The output ID allocation line of the second slave station device is connected to the input ID allocation line of the third slave station device. Subsequent slave station devices are connected in this manner. The output ID allocation line of the last slave station device is left floating. Step 1: In the initial power-on state, reset all slave device IDs to their default values, and set the digital output level of the output ID allocation line controlled by each slave device to a low level; when all slave devices detect that the digital input signal of the input ID allocation line connected to their own device by the previous device is low, they do not respond to any broadcast commands received on the RS485 bus. Step 2: The master station device pulls the input ID assignment line of the first slave device connected to it high and broadcasts a command to the RS485 bus to set the ID of the default ID device to 1. The first slave device connected to the master station device responds to the command to set the ID to 1, and the ID of the first slave device is assigned to 1. The IDs of the remaining slave devices remain the default IDs. Step 3: After assigning ID 1 to the first slave device, the master device sends a command to the first slave device with ID 1, instructing it to set its output ID assignment line to high level. Step 4: The master station device broadcasts a command to the RS485 bus to set the ID of the default ID device to 2. The second slave device connected to the first slave device responds to the command to set its ID to 2. The ID of the second slave device is assigned to 2, and the IDs of the remaining slave devices remain the default IDs. Step 5: Repeat steps 3 and 4 to sequentially assign IDs to all slave devices connected in sequence on the bus until no slave device responds to the repeated sending of the command to assign a default ID device to a certain ID. Step 6: After completing the ID allocation, the master station device checks the bus at regular intervals to see if there are any removed, replaced, or newly added slave devices. If an ID needs to be reassigned, the master station device reassigns IDs to all online slave devices on the bus.
2. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 1, during the initial power-on state, the master station device sends a device ID reset command to the device IDs of all slave devices sequentially via the RS485 communication bus, resetting all slave device IDs to their default values. When the device IDs are restored to their default IDs, all slave devices will set the digital output level of their controlled output ID allocation lines to a low level.
3. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 2, when the master station device pulls the ID allocation line high, the input ID allocation line of the first slave station device is at a high level, and the input ID allocation lines of the remaining slave station devices other than the first slave station device are at a low level; at this time, the IDs of all slave station devices are in the default ID state.
4. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 4, when the master device broadcasts a command to the RS485 bus to set the ID of the default ID device to 2, the IDs of the remaining slave devices other than the first slave device are all default IDs, and the input ID allocation line of the second slave device is high, while the input ID allocation lines of the other default ID devices other than the second slave device are all low.
5. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: The master station is located at the first position in the entire system. The order in which all slave devices are connected to the system can be arbitrarily changed. The master station controls the ID allocation process of all slave devices. The structure and software program of the RS485 communication part of all slave devices are exactly the same. New slave devices can be connected to the bus, and one or more slave devices can be removed.
6. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 6, when a new slave device needs to be added to the bus, first connect the newly added slave device to the bus, and then connect the input ID assignment line of the newly added slave device to the output ID assignment line of the current end slave device.
7. The method for automatically assigning device IDs on a bus according to claim 6, characterized in that: In step 6, the master device broadcasts a command to the RS485 bus at regular intervals, asking if a device with a default ID exists. When a new slave device joins, the input ID assignment line of the newly joined slave device is high and the ID of the newly joined device is the default ID. The newly joined slave device responds to this command. After receiving the response from the newly joined slave device, the master device confirms that a new slave device has joined the communication bus. Then, the master device sends an ID reset command to reset the IDs of all slave devices. Then, the master device repeats steps 1 to 5 to reassign IDs to all slave devices on the bus.
8. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 6, after the ID allocation is completed, the master station device and the slave station device periodically exchange heartbeat messages to confirm whether the slave station device is online normally. That is, the master station device sends a heartbeat command to each slave station device at regular intervals, and the corresponding slave station device responds to the heartbeat command. If a slave device is removed from the bus network, the master device will not be able to receive the heartbeat response from the removed slave device. The master device will determine that the slave device has been removed and will broadcast a command to the RS485 bus at regular intervals to ask if the ID of the removed slave device exists. If a slave device that was removed from the network reconnects to the communication network, the reconnected slave device will respond to the master device's query for the existence of the ID. After receiving the response from the reconnected slave device, the master device determines that the removed slave device has been reconnected to the communication network. Then, the master device will repeat steps 1 to 5 to reassign IDs to all slave devices on the bus.
9. The method for automatically assigning device IDs on a bus according to claim 8, characterized in that: In step 6, once the master station device determines that a slave device has been removed, the master station device will broadcast a command to the RS485 bus at regular intervals to inquire whether the ID of the removed slave device exists. If the removed slave device does not reconnect to the communication network, after the master device sends a command to inquire whether the ID of the removed slave device exists, the master device will not receive a response from the removed slave device within the specified time for receiving the slave device's response command. The master device will mark this slave device as offline, and the master device will continue to communicate and interact normally with other slave devices.
10. The method for automatically assigning device IDs on a bus according to claim 1, characterized in that: In step 6, if a slave device is removed from the bus network and replaced with a new slave device, the ID of the newly replaced slave device is the default ID, and its input ID assignment line is high. The master device will broadcast a command to the RS485 bus at intervals to ask if a device with the default ID exists. The newly replaced slave device responds to this command. After receiving the response from the newly replaced slave device, the master device determines that a new slave device has joined the communication bus. Then, the master device sends an ID reset command to reset the IDs of all slave devices. Then, the master device repeats the operations of steps 1 to 5 to reassign IDs to all slave devices on the bus.