Modbus slave station address configuration device and configuration method
By designing address configuration modules and message monitoring chips in the modbus communication system, automatically monitoring and adjusting port connections, the problem of slave address configuration in the existing technology cannot be automated, and efficient address configuration and remote debugging are achieved.
Patent Information
- Application Number
- CN202411636289.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the slave address configuration of modbus communication needs to be set separately, and the address of each slave station leads to a large workload and the automation setting cannot be achieved.
A modbus slave address configuration device is designed, including multiple address configuration modules, each module is arranged between the communication path between the modbus master station and the slave station. Through the message monitoring chip, initialization and return packets are monitored, port connections are automatically adjusted to realize automatic configuration of slave addresses.
The automatic configuration of modbus slave address is realized, which reduces the workload of manual configuration and improves work efficiency. It is especially suitable for scenarios with a huge number of multi-functional meters in distribution rooms.
Smart Images

Figure CN119484197A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication, and in particular to a device and method for configuring a slave station address of a modbus. Background Art
[0002] Modbus is a serial communication protocol that is widely used in automation systems in the industrial field. It defines the communication rules between devices, allowing devices from different manufacturers to communicate with each other. When setting up modbus communication, in order for the master station to accurately communicate with a specific slave station, it is necessary to uniquely identify each slave station device and set the address of each slave station.
[0003] In the prior art, the slave station address configuration of modbus communication requires setting the address of each slave station individually, which has the disadvantages of large workload and failure to achieve the effect of automatic setting. Summary of the invention
[0004] The embodiment of the present invention provides a device and method for configuring a slave address of a modbus, which can solve the problem in the prior art that the configuration of the slave address of the modbus cannot be automatically set.
[0005] The embodiment of the present invention provides a Modbus slave station address configuration device, a Modbus master station and multiple slave stations, characterized in that it also includes: multiple address configuration modules, each of which is arranged between the Modbus master station and the communication path of each of the slave stations; each of the address configuration modules includes: a first port, a third port and a fifth port that are interconnected; a second port, a fourth port and a sixth port that are interconnected; the first port and the second port are connected to the Modbus master station or the previous address configuration module; the third port and the fourth port are connected to the slave station corresponding to the address configuration module; the fifth port and the sixth port are connected to the next address configuration module; each of the address configuration modules is used to disconnect the first port and the fifth port, and disconnect the second port and the sixth port when the initialization message of the first port and the second port is detected by the message monitoring chip; after the setting is completed, when the return message of the first port and the second port is detected by the message monitoring chip, the first port and the third port are disconnected, the second port and the fourth port are disconnected, the first port and the fifth port are connected, and the second port and the sixth port are connected.
[0006] Furthermore, each of the address configuration modules adopts dual-channel power supply of DC24V and AC220V.
[0007] Furthermore, the message monitoring chip in the last address configuration module can only monitor the initialization message.
[0008] Furthermore, the modbus master station sends a broadcast request to all the slave stations via address 0.
[0009] Furthermore, the address range of the slave station is 1 to 247.
[0010] The embodiment of the present invention provides a configuration method of a Modbus slave address configuration device, comprising the following steps:
[0011] A corresponding address configuration module is provided between the communication path of the modbus master station and each slave station; when the initialization message of the first port and the second port is detected by the message monitoring chip, the first port and the fifth port are disconnected, and the second port and the sixth port are disconnected; after the setting is completed, when the return message of the first port and the second port is detected by the message monitoring chip, the first port and the third port are disconnected, the second port and the fourth port are disconnected, the first port and the fifth port are connected, and the second port and the sixth port are connected; when the last slave station completes the address configuration, no message is returned, and the configuration of the modbus slave station address is ended.
[0012] Furthermore, a corresponding address configuration module is provided between the communication path between the modbus master station and each slave station, and when the address configuration module is set at the position of the last slave station, the message monitoring chip in the address configuration module detects no return message, and the configuration of the modbus slave station address is ended.
[0013] The embodiment of the present invention provides a device and method for configuring a slave address of a modbus. Compared with the prior art, the beneficial effects thereof are as follows:
[0014] When the modbus master station starts to configure the slave station, the modbus master station sends multiple initialization messages to multiple slave stations. When each address configuration module detects the initialization messages of the first port and the second port through the message monitoring chip, the first port and the fifth port are disconnected, and the second port and the sixth port are disconnected, so that the initialization message accurately configures the corresponding slave station. After the configuration is completed, the corresponding slave station sends a return message. When the message monitoring chip detects the return message of the first port and the second port, the first port and the third port are disconnected, the second port and the fourth port are disconnected, the first port and the fifth port are connected, and the second port and the sixth port are connected, so that the return message of each slave station is unidirectional to the master station, and the configuration of the entire modbus slave station address is automatically completed. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A BL01 device structure diagram of a modbus slave address configuration device provided by an embodiment of the present invention;
[0016] Figure 2 A system diagram of a Modbus slave address configuration device and configuration method provided by an embodiment of the present invention;
[0017] Figure 3 A first slave address configuration diagram of a modbus slave address configuration device and configuration method provided by an embodiment of the present invention;
[0018] Figure 4 A second slave station address configuration diagram of a Modbus slave station address configuration device and configuration method provided by an embodiment of the present invention.
[0019] Reference numerals:
[0020] BL01-address configuration module, a1-first port, b1-second port, a2-third port, b2-fourth port, a3-fifth port, b3-sixth port. DETAILED DESCRIPTION
[0021] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.
[0022] See also Figure 1 to Figure 4 The embodiment of the present invention provides a modbus slave station address configuration device, including: a plurality of address configuration modules BL01, each address configuration module BL01 is arranged between the communication path of the modbus master station and each slave station.
[0023] Each address configuration module BL01 includes: a first port a1, a third port a2 and a fifth port a3 that are interconnected; a second port b1, a fourth port b2 and a sixth port b3 that are interconnected; the first port a1 and the second port b1 are connected to the modbus master station or the previous address configuration module BL01; the third port a2 and the fourth port b2 are connected to the slave station corresponding to the address configuration module BL01; the fifth port a3 and the sixth port b3 are connected to the next address configuration module.
[0024] When the initialization message of the first port a1 and the second port b1 is monitored through the message monitoring chip, the first port a1 and the fifth port a3 are disconnected, and the second port b1 and the sixth port b3 are disconnected; after the setting is completed, when the return message of the first port a1 and the second port b1 is monitored through the message monitoring chip, the first port a1 and the third port a2 are disconnected, the second port b1 and the fourth port b2 are disconnected, the first port a1 and the fifth port a3 are connected, and the second port b1 and the sixth port b3 are connected.
[0025] Among them, the address configuration module BL01 adopts dual-channel power supply of DC24V and AC220V. In the configuration of the entire modbus slave address, the last address configuration module BL01 can only monitor the initialization message from the master station. After completing the address configuration of the last slave station, no message is returned. The last address configuration module BL01 cannot monitor the return message. At this time, it is judged that the configuration of the entire modbus slave address is completed.
[0026] In the Modbus communication protocol, master station and slave station are two basic concepts, which represent two different roles of devices in the Modbus network.
[0027] The master is usually the device that initiates communication. It is responsible for initializing communication, sending requests to slaves, and receiving responses from slaves. The master will request data (such as reading the value of a register) or send commands (such as writing data to a register) from the slave as needed. In a Modbus network, there can be one or more masters, but usually only one master is active and communicating with the slaves.
[0028] The slave is a device that responds to the master's request. It is usually a data acquisition device or a control device. After receiving the master's request, the slave will perform corresponding operations according to the request, such as reading the data of the local register and sending it to the master, or modifying the value of the local register according to the master's command. In a Modbus network, there can be one or more slaves, each of which has a unique address for being identified by the master in communication.
[0029] In a Modbus network, each slave device needs to have a unique address so that the master can specify which slave to interact with during communication. The slave address (also called device address or node address) is an 8-bit value, usually ranging from 0 to 247. Address 0 is a special address used for broadcast communication, that is, the request sent by the master will be received by all slaves on the network, but usually no slave will respond to the broadcast request.
[0030] The beneficial effects of the present invention also include:
[0031] 1. After the on-site automation equipment is installed, the programmer can completely remotely set the address and debug the program, saving the cost of business trips and improving work efficiency.
[0032] 2. It is no longer necessary to manually configure the address of each slave station on site, especially in the distribution room where there are a huge number of multi-function meters, which may be hundreds or thousands of meters. Manual configuration is time-consuming and laborious, and future upgrades and renovations still require reconfiguration. With this device, unmanned automatic configuration and remote debugging can be fully realized.
[0033] The embodiment of the present invention provides a configuration method of a Modbus slave address configuration device, comprising the following steps:
[0034] A corresponding address configuration module is provided between the communication path of the modbus master station and each slave station. When the initialization message of the first port and the second port is detected by the message monitoring chip, the first port is disconnected from the fifth port, and the second port is disconnected from the sixth port; after the setting is completed, when the return message of the first port and the second port is detected by the message monitoring chip, the first port is disconnected from the third port, the second port is disconnected from the fourth port, the first port is connected to the fifth port, and the second port is connected to the sixth port. When the last slave station completes the address configuration, no message is returned, and the configuration of the modbus slave station address is ended.
[0035] A specific embodiment is as follows:
[0036] 1. The product adopts DC24v and AC220v dual-channel power supply.
[0037] 2. A message monitoring chip is configured inside the product. When the initialization message is detected on the a1 port and the b1 port, BL01 enters the configuration slave mode. In this mode, the initial state between the a1 port and the a3 port and between the b1 port and the b3 port remains disconnected. And the a1 port and the a2 port and the b1 port and the b2 port remain connected.
[0038] 3. In this mode, when the message monitoring chip detects the return message of the write operation, the a1 port and the a2 port as well as the b1 port and the b2 port are disconnected, and the a1 port and the a3 port as well as the b1 port and the b3 port are connected. At this time, the host computer will set the second slave station address, and then the third one, and so on.
[0039] 4. When the last one is set, and the write operation still does not return a message, it is determined that the last one has been reached, and the host computer sends a message to end the configuration mode.
[0040] 5. In addition to the configuration mode, there is the normal operating mode (the default state is the normal operating mode). In the normal mode, the a1 port, a2 port and a3 port are interconnected, and the b1 port, b2 port and b3 port are also interconnected.
[0041] A BL01 device is configured at the communication interface of the multi-function meter in the distribution room. The program can be automatically configured with addresses and debugged at any time. Due to the special situation of the distribution room, especially in the new construction stage, not every circuit has electricity. Even on-site workers cannot configure the address of the multi-function meter without electricity. When the multi-function meter is damaged, the address of the newly replaced multi-function meter will be the default state and it is impossible to quickly know the address of the original meter. After configuring the device, the automatic configuration of the address of the usable meter can be quickly realized.
[0042] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A modbus slave address configuration device, comprising: A modbus master station and a plurality of slave stations, characterized in that it further comprises: a plurality of address configuration modules (BL01), each of the address configuration modules (BL01) being arranged between the communication path of the modbus master station and each of the slave stations; Each of the address configuration modules (BL01) comprises: a first port (a1), a third port (a2) and a fifth port (a3) that are interconnected; a second port (b1), a fourth port (b2) and a sixth port (b3) that are interconnected; the first port (a1) and the second port (b1) are connected to the modbus master station or the previous address configuration module (BL01); the third port (a2) and the fourth port (b2) are connected to the slave station corresponding to the address configuration module (BL01); the fifth port (a3) and the sixth port (b3) are connected to the next address configuration module; Each of the address configuration modules (BL01) is used for disconnecting the first port (a1) and the fifth port (a3), and disconnecting the second port (b1) and the sixth port (b3) when the message monitoring chip detects the initialization message of the first port (a1) and the second port (b1) through the message monitoring chip; after the setting is completed, when the message monitoring chip detects the return message of the first port (a1) and the second port (b1), the first port (a1) and the third port (a2) are disconnected, the second port (b1) and the fourth port (b2) are disconnected, the first port (a1) and the fifth port (a3) are connected, and the second port (b1) and the sixth port (b3) are connected.
2. A modbus slave address configuration device as claimed in claim 1, characterized in that: Each of the address configuration modules (BL01) is powered by dual channels of DC24V and AC220V.
3. A modbus slave address configuration device as claimed in claim 1, characterized in that: The message monitoring chip in the last address configuration module (BL01) can only monitor the initialization message.
4. A modbus slave address configuration device as claimed in claim 1, characterized in that: The modbus master sends a broadcast request to all the slaves via address 0.
5. A modbus slave address configuration device as claimed in claim 1, characterized in that: The address range of the slave station is 1 to 247.
6. A configuration method of a modbus slave address configuration device according to any one of claims 1 to 5, characterized in that: The following steps are involved: A corresponding address configuration module is provided between the communication path of the modbus master station and each slave station; When the initialization message of the first port and the second port is detected by the message monitoring chip, the first port and the fifth port are disconnected, and the second port and the sixth port are disconnected; After the setting is completed, when the message monitoring chip detects the return message of the first port and the second port, the first port and the third port are disconnected, the second port and the fourth port are disconnected, the first port and the fifth port are connected, and the second port and the sixth port are connected; When the last slave completes the address configuration, no message is returned, and the configuration of the modbus slave address is ended.
7. A configuration method for a MODBUS slave address configuration device as claimed in claim 6, characterized in that: A corresponding address configuration module is provided between the communication path of the modbus master station and each slave station, and also includes when the address configuration module is set at the position of the last slave station, when the message monitoring chip in the address configuration module cannot detect the return message, the configuration of the modbus slave station address is ended.