CN116599792A - Communication method for actively notifying master station of data reading by slave station under Modbus protocol - Google Patents
Communication method for actively notifying master station of data reading by slave station under Modbus protocol Download PDFInfo
- Publication number
- CN116599792A CN116599792A CN202310718381.6A CN202310718381A CN116599792A CN 116599792 A CN116599792 A CN 116599792A CN 202310718381 A CN202310718381 A CN 202310718381A CN 116599792 A CN116599792 A CN 116599792A
- Authority
- CN
- China
- Prior art keywords
- data
- slave station
- station
- address
- master station
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000004891 communication Methods 0.000 title claims abstract description 62
- 238000000034 method Methods 0.000 title claims abstract description 18
- 230000008859 change Effects 0.000 claims abstract description 37
- 238000012544 monitoring process Methods 0.000 claims description 24
- 230000005540 biological transmission Effects 0.000 claims description 7
- 230000000737 periodic effect Effects 0.000 claims description 6
- 230000001960 triggered effect Effects 0.000 claims description 5
- 238000007405 data analysis Methods 0.000 claims description 3
- 238000013461 design Methods 0.000 abstract description 3
- 230000007246 mechanism Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/403—Bus networks with centralised control, e.g. polling
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40228—Modbus
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention provides a communication method for actively notifying a master station of data reading by a slave station under a Modbus protocol, which comprises the following steps: the master station transmits the Modbus address of the data to be monitored to a specific address of the slave station; after receiving the need, the slave station monitors the data, directly records the change result in the appointed address field, and changes the data status bit for identifying the slave station to monitor the data change; the master station periodically reads the data state bit of the slave station, and when the change is found, the master station reads the data in the address field appointed by the slave station and acquires the data of the change of the slave station value; after the secondary station feeds back the data in the appointed address field to the primary station, changing the data state bit; the master station analyzes and records the fluctuation data. According to the invention, the Modbus communication master station can realize the purposes of informing the master station of event occurrence and reading parameters by the slave station only by periodically scanning the identification bit for indicating the state of the slave station, and has the advantages of scientific design, strong practicability, simplicity and convenience in operation and high communication efficiency.
Description
Technical Field
The invention relates to the technical field of industrial control Modbus communication, in particular to a communication method for actively informing a master station of data reading by a slave station under a Modbus protocol. Under Modbus protocol, the slave station actively informs the master station of a communication mechanism for reading target data.
Background
Modbus is a serial communication protocol, published by Modicon corporation (now Schneider electric) in 1979 for communication using Programmable Logic Controllers (PLCs). Modbus has become the industry standard for industrial-area communication protocols and is now a common way of connecting industrial electronic devices.
The Modbus protocol is a master-slave architecture protocol, which includes a master station and a slave station. One node is a master station, and other nodes using the Modbus protocol to participate in communication are slave stations. The master node periodically interrogates each slave station to obtain the data of the slave station. When the slave station includes a plurality of data addresses, the master station must periodically access the data of each data address of the slave station in order to obtain the data change condition of the slave station in time. In applications where bandwidth may be at a premium, this approach consumes bandwidth and network time in the application.
The Modbus protocol is widely applied to industrial sites in various occasions as a free open protocol. In industrial application, a master station device needs to monitor the operation conditions of a plurality of slave station devices in a network, acquire the data content of the slave station devices in time, and record, analyze and control information according to the related data content. The secondary station device bears specific task execution, the related data are large and complex, and the data change is irregular. In order for the master station device to acquire the execution of the slave station task in time, the master station device needs to monitor a plurality of parameters in the slave station and periodically read data from the slave station device. However, the data change of the slave station has unpredictability, and the data change can be realized only by improving the data communication frequency in order to meet the timeliness of the data acquisition of the master station. When the influence of network bandwidth load cannot realize high-frequency data communication of a large amount of data of the secondary station, the timeliness of data monitoring of the primary station is realized. For a complex and huge Modbus network system, the communication period of the master station to the slave stations is up to tens of seconds or even longer. The current mode of data communication of a large number of secondary stations is difficult to meet the requirement of industrial data monitoring timeliness.
In order to solve the above problems, an ideal technical solution applied under the Modbus protocol has been sought.
In the conventional Modbus communication protocol, communication and reading are required to be performed on all set data contents, whether the data contents are changed or not, if the communication contents are scattered or discontinuous data, the host computer is required to send a plurality of reading instructions to read the data one by one, for example, if the host computer needs to monitor discontinuous register data at a certain slave computer 20. The master station needs to send 20 reading instructions successively, and the slave station needs to respond one by one for returning data 20 times, so that the data polling of the slave station is realized once. When the data communication demands of a plurality of slaves exist in the Modbus communication network, the communication data volume of the master station is increased, the communication network is quite busy, and in order to ensure the communication smoothness, the communication polling interval of the master station is increased each time, so that the timeliness is difficult to ensure. When a certain emergency of the slave is sent or the data is changed, the master can hardly acquire the data change of the slave in time through the original Modbus communication mode.
Disclosure of Invention
Aiming at the technical problems of communication delay, slow communication speed and slow response caused by the fact that a master station regularly reads multiple groups of data of a slave station in the existing communication, the invention provides a method for actively informing the master station of the slave station under the Modbus protocol, wherein the master station carries out communication reading on changed data, and the method is scientific in design, high in practicability, simple and convenient to operate and high in detection efficiency, so that the cooperation of master station and slave station communication is realized.
In order to achieve the above purpose, the technical scheme of the invention is realized as follows: a communication method for actively informing a master station of data reading by a slave station under a Modbus protocol comprises the following steps:
step one: the master station transmits the Modbus address of the data to be monitored to a specific address of the slave station, and tells the slave station that the data change in the batch of addresses needs to be monitored;
step two: after receiving the data address to be monitored, the slave station monitors, directly records the change result, and changes the data state position for identifying whether the monitored data of the slave station changes;
step three: the master station regularly reads the identification position, reads the data in the set area after finding that the identification position is changed into the designated data, and can read the changed address and the changed data in the area;
step four: after the slave station returns the data to the master station, the data change identification bit is changed, and the data transmission request is triggered again after waiting for the next data change.
Preferably, the master station completes data state monitoring of the slave stations through a periodic data reading task; when the data of the slave station changes, the master station is triggered to read the data task once, and the master station reads the changed data segment of one slave station, reads the data address and the data, and completes the change monitoring of the data of the slave station.
Preferably, initial data in the data address of the secondary station is acquired during the first communication, so that the subsequent comparison and recording with the updated value are facilitated.
Preferably, after receiving the Modbus address of the data to be monitored, the slave station establishes an internal monitoring task and monitors the Modbus address data in the monitoring task data; when the slave station finds that the data in the monitoring task changes, the address of the changed data and the changed data are written in the data segment appointed by the slave station, and the value of the data identification bit of the slave station is updated.
Preferably, the data segments agreed upon by the secondary stations are agreed upon by the primary station and the secondary stations themselves, or are defined as a certain designated communication address segment.
Preferably, after the slave station completes the master station communication request in the third step and feeds back the data including the changed address and the changed data in the designated address field, the slave station sets the value of the data identification bit to an initial state, which indicates that the slave station data change has completed transmission.
Preferably, after the master station reads the content of the data segment appointed by the slave station for a single time, carrying out data analysis according to the data structure; writing the data into corresponding address segments in a data table of the slave station recorded by the master station one by one according to the corresponding relation between the data address and the data value, and continuously and periodically reading the data identification state of the slave station by the master station.
Compared with the prior art, the invention has substantial characteristics and progress, and concretely comprises the following steps:
1) The invention provides a communication mechanism for actively informing a master station of data reading by a slave station under a Modbus protocol, wherein when the slave station discovers that an event occurs, an event parameter address and data are stored in a designated register, the master station is informed of the address and the data quantity of the register to be read, and the master station actively grabs the data of the event after obtaining the event parameter address and the event parameter quantity. Therefore, the method can avoid the periodic and repeated reading of the repeated data without change in batches of the secondary stations by the primary station, occupy the bandwidth and communication time of the primary station, and reduce the repeated data transmission work of the secondary stations, thereby solving the problems of large communication delay and slow data change response of the secondary stations caused by the data monitoring of the secondary stations in batches.
2) The invention can solve the problem of repeated data reading operation of the master station caused by discontinuous data addresses of the slave stations, the slave stations can place the changed data addresses and data contents into a designated section of registers according to a defined data structure, the master stations can read the data at one time, and the master stations analyze the transmitted data contents according to the data structure, so that the change condition of the data addresses to be transmitted by the slave stations can be solved.
3) The master station can monitor the state of the slave station only by periodically monitoring the content of the identification data of the designated address through a single communication instruction. Only one data read operation is required for one slave station in one cycle. When the identification data of the slave station changes, the master station reads the address content of a certain section of data at a time according to the protocol trigger, so that the master station can read the changed data of the slave station. The monitoring process of the data change of the whole master station can be completed by only triggering single data communication reading operation, so that the monitoring of all the slave station events is avoided, and the master station only needs to read corresponding event parameters when the events are triggered due to time delay caused by periodically and massively reading the data. The invention has simple operation and convenient use.
In conclusion, the invention has the advantages of scientific design, strong practicability, simple and convenient operation and high communication efficiency.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a system architecture diagram of a Modbus network.
Fig. 2 is a flow chart of the task of communication at a slave station according to the present invention.
Fig. 3 is a flowchart of embodiment 2 in an embodiment of the present invention.
Fig. 4 is a schematic diagram of a data structure of a data identification bit in embodiment 2 of the present invention.
Fig. 5 is a data segment structure of a slave station data address 6000-segment in embodiment 2 of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without any inventive effort, are intended to be within the scope of the invention.
Example 1
As shown in fig. 2, a communication method for actively notifying a master station to perform data reading by a slave station under a Modbus protocol includes the following steps:
step one: the master station transmits the data Modbus addresses to be monitored to the (target) slave station specific address telling the slave station that the data changes in the batch of Modbus addresses need to be monitored.
As shown in fig. 1, a single read data task or a periodic data read task may be performed between the Modbus master and slave. The master station completes the data state monitoring of the slave station through the periodic tasks; when the data of the slave station changes, the master station is triggered to read the data task once, the master station reads the changed data segment of a certain slave station and reads the data address and the data, so that the change monitoring of the data of the slave station can be completed only by a small amount of periodic communication. And when in first communication, initial data in the data addresses of the secondary stations are acquired and used for initial values of the secondary station data, so that subsequent comparison and recording with updated values are facilitated.
Step two: after receiving the Modbus address of the data to be monitored, the slave station monitors the data according to the data in the specific address, directly records the change result in the designated address field, and changes the data status bit for identifying the slave station to monitor the data change.
After receiving the Modbus address of the data to be monitored, the target slave station establishes an internal monitoring task and monitors the data of the Modbus address in the monitoring task data. Since the monitoring process is completed in the slave station, the data comparison and acquisition can be performed periodically (for example, 1 ms), and the communication transmission is not affected by the detection process. When the slave station finds that the data in the monitoring task changes, the address of the changed data and the changed data are written in the data segment appointed by the slave station, and the value of the data identification bit of the slave station is updated. This address field of the secondary station is agreed by the primary station and the secondary station, and may be defined as a specific communication address field.
Step three: the master station periodically reads the data state bit of the slave station step two, and when the identification bit is found to be changed into the designated data, the master station reads the data in the address field appointed by the slave station, and the data can acquire the data address of the slave station with the changed value and the changed data value. The data structure of which is shown in fig. 5.
If the state of the data identification position of the secondary station is unchanged, the primary station continues to periodically read the data identification state of the secondary station.
Step four: and when the secondary station feeds back the appointed data segment in the second step to the primary station, changing the data state bit of the second step, and triggering the data transmission request again after waiting for the next data change.
After the slave station completes the communication request of the master station in the third step and feeds back the appointed section data (comprising the changed address and the changed data), the slave station sets the value of the data identification bit to be in an initial state, and the data change of the slave station is completed to be transmitted.
Step five: the master station analyzes the fluctuation data and records the fluctuation data. After the master station reads the content of the data segment appointed by the slave station once, the data analysis is performed according to the data structure shown in fig. 5. Writing the data into corresponding address segments in a data table of the slave station recorded by the master station one by one according to the corresponding relation between the data address and the data value, and continuously and periodically reading the data identification state of the slave station by the master station.
Example 2
As shown in fig. 3, a communication method for actively notifying a master station of data reading by a slave station under a Modbus protocol is now described by way of example only for a communication task of one of the slave stations, and includes the following steps: for example, the master station needs to acquire data fluctuation in which the data address in the slave station is 1000, 2000, 3000 or more in fig. 3.
Step 1: the master station transmits the monitor target address 1000, 2000, 3000 into the data segment from which the target slave station data address 5000 starts, and reads the initial data value 1, 10, 100 of the target slave station data address 1000, 2000, 3000.
Step 2: the target slave station establishes a data monitoring task according to the data target address transmitted by the master station, namely according to the data in the data address field 5000, and monitors the data change condition in the data addresses 1000, 2000 and 3000.
Step 3: the data value in the slave station data address 100 is represented as a change identification bit of the slave station monitoring data, which is simply referred to as a data identification bit, and the data structure definition thereof is shown in fig. 4, wherein the data address 15 is a data identification bit, the data address 14-10 is undefined, and the data address 9-0 is the amount of address data to be read. When the slave station monitors that the data in the data address 1000 changes, for example, when 1 changes to 5, the slave station changes the value of the data identification bit, changes the data of the data identification bit to binary data 1000000000000001, writes the changed data address and the data into the data segment with the data address 6000 of the slave station as the starting position, writes the data in the data address 6000 into 1000, and writes the data in the address 6001 into 5. As shown in fig. 5, the data segment structure in the slave station data address 6000 is an address and data corresponding to the address in order.
Step 4: the master station periodically reads the identification bit of the data of the slave station and reads the binary data 1000000000000001 of the identification bit of the data of the slave station, so that the change of the numerical value in the data address of the slave station 1 can be judged. The master station transmits a read command once to read the data in the slave station data address 6000, and the data length bits are 2, which respectively represent the changed data address and data value.
Step 5: and the secondary station feeds back the content of the data segment according to the data reading instruction sent by the primary station, and updates the data identification bit to be an initial value of 0.
Step 6: the master station analyzes the meaning of the received data value according to the data segment structure definition, and changes the address 1000 data in the slave station record into 5 in the data record corresponding to the data update value according to the data address. Thus, the active communication mechanism of primary slave station data change is completed.
The other steps were the same as in example 1.
According to the invention, the purposes that the slave station informs the master station of event occurrence and reads parameters can be realized, and the time waste and the communication rate waste caused by the fact that the master station needs to read the slave station repeatability data for multiple times each time to obtain the slave station data change are avoided, so that the problem that the master station obtains the slave station data in time under the Modbus protocol is solved conveniently.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.
Claims (7)
1. A communication method for actively notifying a slave station of data reading under a Modbus protocol is characterized by comprising the following steps:
step one: the master station transmits the Modbus address of the data to be monitored to a specific address of the slave station, and tells the slave station that the data change in the Modbus address of the batch needs to be monitored;
step two: after receiving the Modbus address of the data to be monitored, the slave station monitors the data according to the data in the specific address, directly records the change result in the appointed address field, and changes the data status bit for identifying the slave station to monitor the data change;
step three: the master station periodically reads the data state bit of the slave station step two, and when the identification bit of the data state bit is found to be changed into the appointed data, the master station reads the data in the address section appointed by the slave station, and acquires the data address of the slave station with the numerical value change and the data value after the change;
step four: after the secondary station feeds back the data in the address field appointed in the second step to the primary station, changing the data state bit of the second step, and triggering the data transmission request again after waiting for the next data change;
step five: the master station analyzes the fluctuation data and records the fluctuation data.
2. The communication method for actively notifying a slave station of data reading under a Modbus protocol according to claim 1, wherein the master station completes data status monitoring of the slave station by a periodic data reading task; when the data of the slave station changes, the master station is triggered to read the data task once, and the master station reads the changed data segment of one slave station, reads the data address and the data, and completes the change monitoring of the data of the slave station.
3. The communication method for actively notifying the slave station of data reading by the master station under the Modbus protocol according to claim 2, wherein the initial data in the data address of the slave station is acquired during the first communication, so that the subsequent comparison and recording with the updated value are facilitated.
4. A communication method for actively notifying a slave station of data reading of a master station under a Modbus protocol according to claim 2 or 3, wherein after receiving a data Modbus address to be monitored, the slave station establishes an internal monitoring task to monitor the data of the Modbus address in the monitoring task data; when the slave station finds that the data in the monitoring task changes, the address of the changed data and the changed data are written in the data segment appointed by the slave station, and the value of the data identification bit of the slave station is updated.
5. The communication method as claimed in claim 4, wherein the slave station actively notifies the master station of data reading under the Modbus protocol, wherein the data segment agreed by the slave station is agreed by the master station and the slave station by itself or defined as a specific communication address segment.
6. The communication method according to claim 1 or 5, wherein the slave station actively notifies the master station of data reading under the Modbus protocol, wherein the slave station completes the master station communication request in step three, and after feeding back the data including the changed address and the changed data in the designated address field, the slave station sets the value of the data identification bit to an initial state, which indicates that the slave station data change has completed transmission.
7. The communication method for actively notifying the master station of data reading by the slave station under the Modbus protocol according to claim 6, wherein the master station performs data analysis according to the data structure after reading the contents of the data segments agreed by the slave station once; writing the data into corresponding address segments in a data table of the slave station recorded by the master station one by one according to the corresponding relation between the data address and the data value, and continuously and periodically reading the data identification state of the slave station by the master station.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310718381.6A CN116599792A (en) | 2023-06-16 | 2023-06-16 | Communication method for actively notifying master station of data reading by slave station under Modbus protocol |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310718381.6A CN116599792A (en) | 2023-06-16 | 2023-06-16 | Communication method for actively notifying master station of data reading by slave station under Modbus protocol |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116599792A true CN116599792A (en) | 2023-08-15 |
Family
ID=87599236
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310718381.6A Pending CN116599792A (en) | 2023-06-16 | 2023-06-16 | Communication method for actively notifying master station of data reading by slave station under Modbus protocol |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116599792A (en) |
-
2023
- 2023-06-16 CN CN202310718381.6A patent/CN116599792A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107590099B (en) | Method for accessing slave machines by multiple hosts, extension device and storage medium | |
KR100603612B1 (en) | Apparatus and Method of RFID Reader Interface and Event Management for Heterogeneous Readers with Multi-Protocol | |
US6675226B1 (en) | Network interface for industrial controller providing application programmer interface | |
JP5459325B2 (en) | Cache device, cache program, and communication device | |
CN110166335B (en) | EtherCAT slave station and slave station synchronous communication method, control system, equipment and storage medium | |
CN111966189B (en) | Flexibly configured multi-computing-node server mainboard structure and program | |
JPH04312160A (en) | Multiprocessor system and its message transmission and reception controller | |
CN109839890B (en) | Control device, control method, and computer-readable storage medium | |
CN115982072B (en) | Information communication method, apparatus, computer device and storage medium | |
JP2018064178A (en) | Slave apparatus | |
CN111654426B (en) | Event sequence recording event information acquisition method based on Modbus protocol and related equipment | |
CN116599792A (en) | Communication method for actively notifying master station of data reading by slave station under Modbus protocol | |
CN115729164B (en) | Industrial communication system management method and device and industrial communication system | |
CN113010336A (en) | Application processor crash field debugging method and application processor | |
CN213852891U (en) | Fire control system | |
CN110659236B (en) | AXI bus transmission device capable of autonomously replying write response | |
JP2920441B2 (en) | Process data processing system and processing method | |
US20210389741A1 (en) | Control system and control device | |
CN105893288A (en) | Dma controller | |
CN112206453A (en) | Fire control system | |
CN117009265B (en) | Data processing device applied to system on chip | |
CN116166585A (en) | BMC access control method and device and BMC system | |
CN113934671B (en) | Interface control chip and network equipment | |
CN112711549B (en) | Interrupt request signal conversion system and method, and computing device | |
CN112181900B (en) | Data processing method and device in server cluster |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |