A communication method for slave station to actively inform master station of data reading under Modbus protocol

By actively notifying the master of data changes via the slave, the communication delay problem caused by the master periodically reading slave data under the Modbus protocol is solved, efficient and timely data monitoring is achieved, and the operation process is simplified.

CN116599792BActive Publication Date: 2025-10-10ZHONGYUAN ENGINEERING COLLEGE +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310718381.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-16
Publication Date
2025-10-10
Estimated Expiration
2043-06-16

AI Technical Summary

Technical Problem

Under the Modbus protocol, the master station needs to periodically read multiple sets of slave station data, resulting in communication delays and slow responses, making it difficult to meet the timeliness requirements of industrial data monitoring. Especially when network bandwidth is precious, existing technologies cannot efficiently obtain changes in slave station data.

Method used

The slave station actively notifies the master station of data changes by storing event parameters in designated registers and notifying the master station to read them. The master station only performs a single reading when a change is detected, reducing repetitive data transmission and realizing collaborative communication between the master and slave stations.

Benefits of technology

It improves communication efficiency, reduces bandwidth usage and communication delay, ensures that the master station can obtain slave station data changes in a timely manner, and simplifies the operation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116599792B_ABST
    Figure CN116599792B_ABST
Patent Text Reader

Abstract

The application provides a communication method for slave station active notification of master station data reading under Modbus protocol, and the steps are as follows: the master station sends the Modbus address of the data to be monitored to the specific address of the slave station; after receiving the data to be monitored, the slave station carries out data monitoring, directly records the change result in the specified address segment, and changes the data state bit used for identifying the data change monitored by the slave station; the master station periodically reads the data state bit of the slave station, reads the data in the specified address segment of the slave station when the change is found, and obtains the data with value change of the slave station; the slave station changes the data state bit after feeding back the data in the specified address segment to the master station; and the master station completes the analysis and record of the changed data. In the application, the master station of Modbus communication only needs to periodically scan the identification bit used for indicating the state of the slave station, so that the purpose of the slave station notifying the master station of the event occurrence and reading the parameters can be achieved, and the application has the advantages of scientific design, strong practicability, simple operation and high communication efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial control Modbus communication, and in particular to a communication method in which a slave station actively notifies a master station to read data under the Modbus protocol. The present invention also relates to a communication mechanism in which a slave station actively notifies a master station to read target data under the Modbus protocol. Background Art

[0002] Modbus is a serial communication protocol that was introduced by Modicon (now Schneider Electric) in 1979 for communication with programmable logic controllers (PLCs). Modbus has become the de facto standard for industrial communication protocols and is now a common method for connecting industrial electronic equipment.

[0003] The Modbus protocol uses a master-slave architecture consisting of a master and slaves. One node is the master, while the other nodes communicating using the Modbus protocol are slaves. The master node cyclically queries each slave to obtain data. If a slave contains data with multiple, discrete addresses that the master needs to read, the master must periodically access each address to keep up with changes. In applications where bandwidth may be at a premium, this approach consumes bandwidth and network time.

[0004] As a free, open protocol, the Modbus protocol is widely used in various industrial settings. In industrial applications, master devices need to monitor the operating status of multiple slave devices within the network, obtain data from these devices in a timely manner, and perform information recording, analysis, and control based on the relevant data. Slave devices are responsible for executing specific tasks, involving a large amount of complex data, and their data changes erratically. To obtain timely information about the execution status of slave tasks, the master device needs to monitor multiple internal parameters of the slave devices and periodically read their data. However, slave data changes are unpredictable. To ensure timely master data acquisition, the only solution is to increase the frequency of data communication. Due to network bandwidth constraints, it is impossible to communicate large amounts of data from all slaves at the high frequency required for timely master data monitoring. In a complex and large Modbus network system, the communication cycle between the master and slaves can be as long as ten seconds or even longer. This current method of periodically communicating large amounts of slave data is difficult to meet the requirements of timely industrial data monitoring.

[0005] In order to solve the above problems, people have been seeking an ideal technical solution applied under the Modbus protocol.

[0006] The traditional Modbus communication protocol requires that all data content be read, regardless of whether it changes. If the data is scattered and discontinuous, the host must send multiple read commands to read the data one by one. For example, if the host needs to monitor the data of 20 discontinuous registers on a slave, regardless of whether the slave data changes, the host must repeatedly poll the data at the set communication interval. The master needs to send 20 read commands in succession, and the slave needs to respond and return data 20 times, completing the slave data polling once. When multiple slaves need to communicate data in a Modbus communication network, the master's communication data volume surges, and the communication network becomes very busy. To ensure smooth communication, the host must increase the polling interval between each communication, making it difficult to ensure timely communication. When a slave sends an emergency message or data changes, it is difficult for the host to obtain the slave data changes in a timely manner through the original Modbus communication method. Summary of the Invention

[0007] In order to solve the technical problems of communication delay, slow communication rate and slow response caused by the master station periodically reading multiple groups of data from the slave station in existing communications, the present invention proposes a method in which the slave station actively notifies the master station under the Modbus protocol, and the master station communicates and reads the changed data. The method has a scientific design, strong practicality, simple operation and high detection efficiency, thereby realizing the collaborative communication between the master and the slave stations.

[0008] In order to achieve the above object, the technical solution of the present invention is implemented as follows: a communication method in which a slave station actively notifies a master station to read data under the Modbus protocol, the steps of which are as follows:

[0009] Step 1: The master station sends the Modbus address of the data to be monitored to the specific address of the slave station, telling the slave station that it needs to monitor the data changes in this batch of addresses;

[0010] Step 2: After receiving the data address to be monitored, the slave station monitors it and directly records the change results, and changes the data status position used to identify whether the slave station monitors the data.

[0011] Step 3: The master station periodically reads the monitoring identification position of the slave station. When it finds that it has changed to the specified data, it reads the data in the set area. The changed address and changed data can be read in this area.

[0012] Step 4: After the slave returns the data to the master, it changes the data change flag and waits for the next data change to trigger the data sending request again.

[0013] Preferably, the master station completes the data status monitoring of the slave station through periodic data reading tasks; when the slave station data changes, the master station triggers a single data reading task, and the master station reads the changed data segment of a certain slave station, reads the data address and data, and completes the change monitoring of the slave station data.

[0014] Preferably, during the first communication, the initial data in the slave station data address is obtained to facilitate subsequent comparison and recording with the updated value.

[0015] Preferably, after the slave station receives the Modbus address of the data to be monitored, it establishes an internal monitoring task to monitor the data of the Modbus address within the monitoring task data; when the slave station finds that the data within the monitoring task has changed, it writes the address of the changed data and the changed data in the data segment agreed upon by the slave station, and updates the value of the slave station data identification bit.

[0016] Preferably, the data segment agreed upon by the slave station is agreed upon by the master station and the slave station, or is defined as a certain designated communication address segment.

[0017] Preferably, after the slave completes the master communication request in step three and feeds back the changed address and changed data in the specified address segment, the slave sets the value of the data identification bit to the initial state, indicating that the slave data change has been transmitted.

[0018] Preferably, after the master station reads the data segment content agreed upon by the slave station once, it parses the data according to the data structure; according to the correspondence between the data address and the data value, it writes them one by one into the corresponding address segment in the master station record slave station data table, and the master station continues to periodically read the slave station data identification status.

[0019] The present invention has substantial features and advancements over the prior art, specifically:

[0020] 1) This invention provides a communication mechanism under the Modbus protocol in which a slave actively notifies a master to read data. When a slave detects an event, it stores the event parameter address and data in a designated register and notifies the master to read the register address and data quantity. After obtaining the event parameter address and quantity, the master actively captures the event data. This prevents the master from periodically and repeatedly reading large quantities of unchanging, repetitive data from the slave, which consumes the master's bandwidth and communication time. It reduces the repetitive data transmission work of the slave, thus resolving the problems of long communication delays and slow response to slave data changes caused by monitoring large quantities of slave data.

[0021] 2) The application can solve the problem of multiple data reading operation of the master station caused by the non-continuous data address of the slave station. The slave station can place the changed data address and data content in a specified register according to the defined data structure, and the master station can complete the reading once, and the master station can analyze the transmitted data content according to the data structure, so that the change of the data address to be transmitted by the slave station can be solved.

[0022] 3) The master station only needs to monitor the identification data content of the specified address through a single communication instruction, so as to complete the monitoring of the state of the slave station. For a slave station, only one data reading operation is needed in a cycle. When the identification data of the slave station changes, the master station triggers a single reading of the data address content according to the protocol, so as to realize the reading of the changed data of the slave station by the master station. The whole monitoring process of the data change of the master station only triggers a single data communication reading operation, so as to complete the monitoring of all slave station events, avoid the delay caused by periodic large reading of data, and the master station only needs to read the corresponding event parameters when the event is triggered. The application has the advantages of simple operation, convenient use and high communication efficiency.

[0023] In summary, the application has the advantages of scientific design, strong practicability, simple operation and high communication efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only some embodiments of the application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of these drawings.

[0025] Figure 1 It is a system architecture diagram of the Modbus network.

[0026] Figure 2 It is a work flow chart of a communication task of a slave station of the application.

[0027] Figure 3 It is a flow chart of embodiment 2 in the specific example of the application.

[0028] Figure 4 It is a schematic diagram of the data structure of the data identification bit in embodiment 2 of the application.

[0029] Figure 5 It is a data segment structure of the slave station data address 6000 segment in embodiment 2 of the application. DETAILED DESCRIPTION

[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.

[0031] Example 1

[0032] like Figure 2 As shown in FIG, a communication method in which a slave station actively notifies a master station to read data under the Modbus protocol, the steps are as follows:

[0033] Step 1: The master sends the Modbus address of the data to be monitored to the specific address of the (target) slave, telling the slave to monitor the data changes in this batch of Modbus addresses.

[0034] like Figure 1 As shown in the figure, Modbus masters and slaves can perform single or periodic data read tasks. The master monitors the slave's data status through periodic tasks. When slave data changes, a single data read task is triggered. The master reads the changed data segment of a slave, including the address and data. This allows monitoring of slave data changes with only a small amount of periodic communication. During the initial communication, the initial data within the slave's data address is obtained. This initial data is used as the initial value for the slave data, facilitating subsequent comparison and recording with updated values.

[0035] Step 2: After the slave receives the Modbus address of the data to be monitored, it monitors the data according to the data in the specific address, records the change results directly in the specified address segment, and changes the data status bit used to identify the change of the slave monitoring data.

[0036] After receiving the Modbus address of the data to be monitored, the target slave establishes an internal monitoring task to monitor the data at the Modbus address within the monitoring task data. Since this monitoring process is performed within the slave, data can be compared and acquired periodically (e.g., every 1ms), without affecting communication transmission. When the slave detects a change in the data within the monitoring task, it writes the address and the changed data to the slave's agreed-upon data segment and updates the value of the slave's data identification bit. This slave address segment is determined by the master and slave and can also be defined as a specific communication address segment.

[0037] Step 3: The master station periodically reads the data status bit of the slave station in step 2. When it finds that its identification bit has changed to the specified data, the master station reads the data in the address segment agreed by the slave station. The data can obtain the data address of the slave station's value change and its changed data value. Its data structure is as follows Figure 5 shown.

[0038] If the status of the slave station data identification position does not change, the master station continues to periodically read the slave station data identification status.

[0039] Step 4: After the slave station feeds back the agreed data segment in step 2 to the master station, it changes the data status bit in step 2 and waits for the next data change to trigger the data sending request again.

[0040] After the slave completes the master communication request in step 3 and feeds back the agreed segment data (including the changed address and changed data), the slave sets the value of the data identification bit to the initial state, indicating that the slave data change has been transmitted.

[0041] Step 5: The master station completes the analysis of the changed data and records it. After the master station reads the data segment content agreed by the slave station once, Figure 5 The data structure shown is used for data parsing. According to the correspondence between data address and data value, each data value is written into the corresponding address segment in the master station record slave station data table. The master station continues to periodically read the slave station data identification status.

[0042] Example 2

[0043] like Figure 3 As shown in the figure, a communication method in which the slave station actively notifies the master station to read data under the Modbus protocol is now introduced as an example of the communication task of one of the slave stations. The method includes the following steps: For example, the master station needs to obtain the data address in the slave station. Figure 3 The middle shows the data changes within 1000, 2000, 3000, etc.

[0044] Step 1: The master sends the monitoring target addresses 1000, 2000, and 3000 to the data segment starting at the target slave data address 5000, and reads the initial data values ​​1, 10, and 100 of the target slave data addresses 1000, 2000, and 3000.

[0045] Step 2: The target slave station establishes a data monitoring task based on the data target address sent by the master station, that is, based on the data in the data address segment 5000, to monitor the data changes in data addresses 1000, 2000, and 3000.

[0046] Step 3: The data value in the slave data address 100 is represented as the change identification bit of the slave monitoring data, referred to as the data identification bit. Its data structure is defined as follows: Figure 4As shown, data address 15 is a data identification bit, data addresses 14-10 are undefined, and data addresses 9-0 are the number of address data to be read. When the slave station monitors and finds that the data in data address 1000 has changed, for example, from 1 to 5, the slave station changes the value of the data identification bit, changes the data in the data identification bit to binary data 1000000000000001, and writes the changed data address and data into a data segment whose starting position is data address 6000 in the slave station, i.e., data address 6000 is written with 1000 and data address 6001 is written with 5. As shown, Figure 5 The data segment structure in data address 6000 in the slave station is sequentially an address and data corresponding to the address.

[0047] Step 4: The master station periodically reads the data identification bit of the slave station, reads the value binary data 1000000000000001 therein, and can determine that the value in one data address of the slave station has changed. The master station sends a read instruction at a time, reads the data in data address 6000 in the slave station, and the data length is 2, which respectively represent the changed data address and data value.

[0048] Step 5: The slave station updates the data identification bit to the initial value 0 after feeding back the data segment content according to the data read instruction sent by the master station.

[0049] Step 6: The master station analyzes the meaning of the received data value according to the data segment structure definition, and changes the data in the address 1000 in the record of the slave station to 5 according to the data address. Thus, the active communication mechanism for one data change of the slave station is completed.

[0050] The other steps are the same as those in Embodiment 1.

[0051] According to the present application, the slave station can notify the master station of an event and read parameters, time waste and communication rate waste caused by the master station needing to read repetitive data of the slave station multiple times to obtain data change of the slave station are avoided, and the problem that the master station cannot obtain data of the slave station in time under the Modbus protocol is conveniently solved.

[0052] The above only describes preferred embodiments of the present application and should not be used to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims

1. A communication method in which a slave station actively notifies a master station of data reading under the Modbus protocol, characterized in that: The steps are as follows: Step 1: The master station sends the Modbus address of the data to be monitored to the specific address of the slave station, telling the slave station that it needs to monitor the data changes in this batch of Modbus addresses; Step 2: After the slave receives the Modbus address of the data to be monitored, it monitors the data according to the specific address, records the change results directly in the specified address segment, and changes the data status bit used to identify the change of the slave monitoring data; Step 3: The master station periodically reads the data status bit of the slave station in step 2. When it finds that the identification bit of the data status bit has changed to the specified data, the master station reads the data in the address segment specified by the slave station and obtains the data address of the slave station whose value has changed and its changed data value; Step 4: After the slave feeds back the data in the address segment specified in step 2 to the master, it changes the data status bit in step 2 and waits for the next data change to trigger the data sending request again; Step 5: The master station completes the analysis of the changed data and records it; The master station completes the data status monitoring of the slave station through the periodic data reading task; when the slave station data changes, the master station triggers a single data reading task, and the master station reads the changed data segment of a certain slave station, reads the data address and data, and completes the change monitoring of the slave station data; After receiving the Modbus address of the data to be monitored, the slave station establishes an internal monitoring task to monitor the data of the monitoring task Modbus address; when the slave station finds that the data in the monitoring task has changed, it writes the address of the changed data and the changed data into the address segment agreed by the slave station and updates the value of the slave station data identification bit; After the slave completes the master communication request in step 3 and sends back the changed address and data in the specified address segment, the slave sets the value of the data identification bit to the initial state, indicating that the slave data change has been transmitted; After the master station reads the content of the address segment agreed by the slave station once, it parses the data according to the data structure; according to the correspondence between the data address and the data value, it writes them one by one into the corresponding address segment in the master station record slave station data table, and the master station continues to periodically read the slave station data identification status.

2. The communication method for actively notifying a master station of data reading from a slave station under the Modbus protocol according to claim 1, wherein: During the first communication, the initial data in the slave data address is obtained to facilitate subsequent comparison and recording with the updated value.

3. The communication method for actively notifying a master station of data reading from a slave station under the Modbus protocol according to claim 2, characterized in that: The data segment agreed upon by the slave station is agreed upon by the master station and the slave station, or defined as a specified communication address segment.

Citation Information

Patent Citations

  • Extended communication method based on Modbus communication protocol

    CN103746783A

  • Data transmission control method based on bus network communication

    CN111464419A