Modbus communication method and communication system based on DCS controller
Through the collaborative work of the Modbus slave gateway and the DCS controller, the problem that traditional Modbus communication methods cannot pass DCS process control data is solved, data integrity and efficiency are improved, and system flexibility and scalability are enhanced.
Patent Information
- Application Number
- CN202411178265.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-06
AI Technical Summary
Traditional Modbus communication methods cannot directly transmit analog quantity, switching quantity and user operation variables in DCS process control, affecting the real-time and production efficiency of data transmission.
Through the communication between the Modbus master and the DCS controller, the Modbus slave gateway is used to process data reading and writing instructions. The DCS controller caches instructions when updating the address table to ensure data integrity and not in the address table. Data read and write operations are performed during updates, and point-to-point data transmission is carried out using UDP protocol.
Ensure that the Modbus master can access all data in the DCS process, enhance system flexibility and scalability, and improve data utilization and system operation efficiency.
Smart Images

Figure CN119094272A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data communication, and in particular to a Modbus communication method and a communication system based on a DCS controller. Background Art
[0002] Modbus protocol is a communication protocol used in industrial automation systems. It is mainly used for data transmission between different devices such as sensors, instruments, PLCs, etc., so that they can share data. It supports multiple communication methods, including serial communication such as RS-232, RS-485, Ethernet communication, and multiple transmission modes such as ASCII mode, RTU mode and TCP mode. It is widely used in distributed control systems DCS. Traditional Modbus slaves collect data through Modbus protocol in distributed control systems and store data in memory. After responding to the command of the Modbus master station, they provide data to the Modbus master station. However, this communication method can only transmit limited data, including only the data collected by the Modbus slave station. For the analog and switch data collected during the DCS process control process, as well as the variables or results calculated by the user program, they cannot be directly transmitted to the required Modbus master station, which affects the real-time data transmission and production efficiency. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention provides a Modbus communication method based on a DCS controller, wherein a Modbus master station communicates with the DCS controller via a Modbus slave station gateway, and the Modbus communication method comprises the following steps:
[0004] The Modbus master sends data reading instructions to the DCS controller through the Modbus slave gateway;
[0005] The DCS controller interrupts receiving Modbus communication data after receiving the data reading instruction, and inquires whether the Modbus address table data is currently being updated, wherein the Modbus address table is a slave station data area established in the controller memory by the DCS controller through the Modbus slave station data configuration;
[0006] If the DCS controller is currently updating the Modbus address table data, the data reading instruction is cached until the update is completed and then the data reading instruction is called; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data reading instruction, and after packaging, the data is fed back to the Modbus slave station gateway.
[0007] Preferably, the method further comprises: after receiving the data write instruction from the Modbus master station forwarded by the Modbus slave station gateway, the DCS controller interrupts receiving the Modbus communication data and inquires whether the Modbus address table data is currently being updated; if the DCS controller is currently updating the Modbus address table data, the data write instruction is cached until the update is completed and then the data write instruction is retrieved and parsed; if the DCS controller is not currently updating the Modbus address table data, the data write instruction is directly parsed; the required write data obtained by the parsing is entered into the corresponding Modbus address table data, and the write flag of the Modbus address is configured and the response information is fed back to the Modbus slave station gateway; the DCS controller writes the data back to the actual operation data area of the DCS controller according to the data write flag of the Modbus address table data in the data processing flow.
[0008] Preferably, the method further includes: the DCS controller configures the configuration according to the Modbus slave station data in the periodic scheduling task, and after monitoring the data write flag of the Modbus address, writes the data in the Modbus address table into the bit number data and variable data area of the DCS controller; and simultaneously obtains the corresponding bit number data and variable data and enters them into the Modbus address table to complete the update of the Modbus address table data.
[0009] Preferably, the Modbus slave gateway uses UDP protocol to perform point-to-point data transmission to the DCS controller through the control network.
[0010] Preferably, the Modbus communication data packet for data interaction between the Modbus slave gateway and the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of subsequent data, the function code is used by the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol.
[0011] The present invention also discloses a Modbus communication system, comprising a DCS controller, a Modbus master station and a Modbus slave station gateway, wherein the Modbus master station communicates with the DCS controller through the Modbus slave station gateway, wherein: the Modbus master station is used to send a data reading instruction to the Modbus slave station gateway; the Modbus slave station gateway is used to receive the data reading instruction sent by the Modbus master station and forward it to the DCS controller; the DCS controller is used to interrupt the reception of Modbus communication data after receiving the data reading instruction, and inquire whether Modbus address table data is currently being updated, wherein the Modbus address table is a slave station data area established in the controller memory by the DCS controller through Modbus slave station data configuration; if the DCS controller is currently updating the Modbus address table data, the data reading instruction is cached until the data reading instruction is called after the update is completed; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data reading instruction, and after being packaged, the data is fed back to the Modbus slave station gateway.
[0012] Preferably, the DCS controller is also used for: after receiving a data write instruction from a Modbus master station forwarded by a Modbus slave station gateway, interrupting the reception of Modbus communication data, and querying whether the Modbus address table data is currently being updated; if the Modbus address table data is currently being updated, caching the data write instruction, and then retrieving and parsing the data write instruction after the update is completed; if the Modbus address table data is not currently being updated, directly parsing the data write instruction; entering the required write data obtained by the parsing into the corresponding Modbus address table data, configuring the write flag of the Modbus address and feeding back the response information to the Modbus slave station gateway; and writing the data back to the actual operation data area of the DCS controller according to the data write flag of the Modbus address table data in the data processing flow.
[0013] Preferably, the DCS controller configures the configuration according to the Modbus slave station data in the periodic scheduling task, and after monitoring the data write flag of the Modbus address, writes the data in the Modbus address table into the bit number data and variable data area of the DCS controller; at the same time, obtains the corresponding bit number data and variable data and enters them into the Modbus address table to complete the update of the Modbus address table data.
[0014] Preferably, the Modbus slave gateway uses UDP protocol to perform point-to-point data transmission to the DCS controller through the control network.
[0015] Preferably, the Modbus communication data packet for data interaction between the Modbus slave gateway and the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of subsequent data, the function code is used by the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol.
[0016] The Modbus communication method and communication system based on the DCS controller disclosed in the present invention use the DCS controller as a Modbus slave station, and the Modbus master station communicates with the DCS controller DCS through the Modbus slave station gateway, wherein the DCS controller interrupts receiving Modbus communication data after receiving the data reading instruction forwarded by the Modbus slave station gateway, and inquires whether the Modbus address table data is currently being updated. If the DCS controller is currently updating the Modbus address table data, the data reading instruction is cached until the data reading instruction is called after the update is completed; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data reading instruction, and after being packaged, it is fed back to the Modbus slave station gateway. This prevents the Modbus master station data operation from affecting the data in the DCS process control. The integrity of the Modbus master station read and write data DCS data is ensured. By using the DCS controller as a Modbus slave, the data provided to the outside world includes not only the analog and switch quantities collected by the DCS, but also the variables or results calculated by the user program, so that the data accessible to the Modbus master station is all the data in the DCS process control, enhancing the system flexibility and scalability, and improving data utilization and system operation efficiency.
[0017] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0019] Figure 1 The present invention is a schematic diagram of the steps of a Modbus communication method based on a DCS controller disclosed in one embodiment of the present invention.
[0020] Figure 2A schematic diagram of the structure of a Modbus communication system disclosed in one embodiment of the present invention.
[0021] Figure 3 The present invention is a schematic diagram of specific steps for a DCS controller disclosed in an embodiment of the present invention to execute a Modbus master station write command. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0024] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may include that the first and second features are in direct contact, or may include that the first and second features are not in direct contact but are in contact through another feature between them. Moreover, a first feature being "above", "above" and "above" a second feature includes that the first feature is directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. A first feature being "below", "below" and "below" a second feature includes that the first feature is directly below and obliquely below the second feature, or simply indicates that the first feature is lower in level than the second feature.
[0025] Unless otherwise defined, the technical or scientific terms used herein shall have the common meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "a" do not indicate a quantity limitation, but indicate the existence of at least one.
[0026] Modbus protocol is a communication protocol used in industrial automation systems. It is mainly used for data transmission between different devices such as sensors, instruments, PLCs, etc., so that they can share data. It supports multiple communication methods, including serial communication such as RS-232, RS-485, Ethernet communication, and multiple transmission modes such as ASCII mode, RTU mode and TCP mode. It is widely used in distributed control systems DCS. Traditional Modbus slaves collect data through Modbus protocol in distributed control systems and store data in memory. After responding to the command of the Modbus master station, they provide data to the Modbus master station. However, this communication method can only transmit limited data, including only the data collected by the Modbus slave station. Other data collected during the DCS process and the results of the calculated variables cannot be directly transmitted, which affects the real-time data transmission and production efficiency.
[0027] In this regard, this embodiment discloses a Modbus communication method based on a DCS controller, wherein the Modbus master communicates with the DCS via a Modbus slave gateway, as shown in the attached Figure 1 As shown, the Modbus communication method includes the following steps.
[0028] Step S1, the Modbus master sends a data read instruction to the DCS controller through the Modbus slave gateway.
[0029] Specifically, as attached Figure 2As shown, the Modbus master station 2 may include a Modbus RTU master station and a Modbus TCP master station, and the Modbus slave station gateway 3 may include a Modbus RTU gateway and a Modbus TCP gateway. The Modbus slave station gateway, according to the pre-configured configuration, serves as the corresponding Modbus slave station link interface for the Modbus master station to link and communicate, and after receiving the Modbus master station command sent by the Modbus master station, forwards the master station command to the DCS controller 1 through the switch in a udp point-to-point manner through the control network. The DCS controller 1 receives and parses the communication data sent by the Modbus slave station gateway 3, and the communication data includes a Modbus communication data packet including the master station command and a time stamp. Among them, the time mark includes the UTC time mark and the millisecond time mark to facilitate command distinction and tracing; the Modbus communication data packet for the Modbus slave gateway to exchange data with the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of the subsequent data, the function code is used by the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol. The communication data packet may also include a check code to detect whether an error occurs in the data during transmission, such as a CRC16 check code, and its overall data format is shown in the following table:
[0030] Command sequence Identifier Length value Unit identifier (slave address) Function code Modbus Data CRC16 checksum 2 bytes 2 bytes 2 bytes 1 byte 1 byte n bytes 2 bytes
[0031] Except for CRC16, which is represented in little endian, all other data are represented in big endian. In a specific embodiment, the identifier: the low byte represents the master station index 0-3 in the gateway, and is copied and returned when the controller responds. Length value: the length of the subsequent data, which is filled in by the controller according to the actual response data. Slave station address: copied and returned when the controller responds. Function code: when the controller needs to respond to an error in the Modbus data, for example, the function code can be 0x80, and the normal response function code is copied and returned. Modbus data: processed according to the standard Modbus protocol. CRC16 check: Calculate CRC16 starting from the slave station address, and do not respond when CRC is incorrect.
[0032] After receiving the Modbus master command, the controller parses the master command and responds in time. The DCS controller is connected to the slave gateways of various protocols including the Modbus protocol, receives and stores the data of each slave, and performs custom configuration according to the received slave data to define the data content provided to the outside. The configuration content includes but is not limited to the bit ID configuration, data length configuration, and data type configuration.
[0033] Step S2, after receiving the data reading instruction, the DCS controller interrupts receiving Modbus communication data and queries whether the Modbus address table data is currently being updated. The Modbus address table is a slave data area established in the controller memory by the DCS controller through the Modbus slave data configuration.
[0034] Specifically, the DCS controller generates a Modbus address table in memory according to the data configuration of each slave station, so that the Modbus master station can read and call it when needed. In order to avoid the impact of executing the Modbus master station read command on the DCS process data processing, the DCS controller first determines the current state of the Modbus address table data after receiving the read command; if the controller is updating the Modbus address table data when receiving the Modbus read command, the read command is cached and the Modbus address table data is responded to after the update is completed. In this way, data reading operations are prevented during the update of the Modbus address table data, and the Modbus master station command is interrupted after receiving the data read command forwarded by the Modbus slave station gateway, so as to ensure the integrity of the Modbus master station's reading of the DCS data.
[0035] Step S3: if the DCS controller is currently updating the Modbus address table data, the data read instruction is cached until the update is completed and then the data read instruction is retrieved; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data read instruction, and after packaging, the data is fed back to the Modbus slave station gateway.
[0036] Specifically, the DCS controller parses the Modbus communication data packet in the received communication data, obtains the read command sent by the Modbus master station, and obtains the corresponding slave station data from the Modbus address table of the controller according to the read command for packet assembly. If the controller is updating the Modbus address table data when receiving the Modbus read data instruction, the read command is cached, and after the refresh is completed, the gateway data is responded to, and the acquired slave station data is packaged into a response data packet and sent to the Modbus slave station gateway, and then forwarded to the Modbus master station through it, completing the entire Modbus data reading process. If the Modbus address table data is not being refreshed when the Modbus read data instruction is received, the gateway data is responded to directly. For the command response of the coil and offline input, the controller supports the conversion of bytes and bits, that is, the controller memory is stored in bytes, and in the Modbus command data, it needs to be converted into bits.
[0037] In this embodiment, the response data packet sent by the DCS controller to the Modbus slave gateway is consistent with the data format of the Modbus communication data packet that the Modbus slave gateway exchanges data with the DCS controller through the control network, including command sequence, identifier, length, slave address, function code, data, CRC16 checksum, etc. Among them, the command symbol, identifier, and slave address are obtained by the DCS controller by copying the Modbus communication data packet, and writing them into the response data packet and returning; the length value is the length of the subsequent data, and the controller fills it in according to the actual response situation; the function code returns the corresponding value in the Modbus communication data packet when the controller is in a normal response state, and returns "function code|0x80" in the case of an error response; Modbus data is processed according to the standard Modbus protocol. After receiving the response data packet, the Modbus slave gateway verifies and calculates the CRC16 checksum, and forwards the qualified data to the Modbus master station. The DCS controller realizes providing the Modbus master station with various types of data in the required DCS process by retrieving the data in the Modbus address table data, thereby improving the operating efficiency of the DCS system.
[0038] Furthermore, when the Modbus master sends a write command, as shown in the attached Figure 3 As shown, the communication method also includes the following contents.
[0039] Step S4, after receiving the data write instruction from the Modbus master station forwarded by the Modbus slave station gateway, the DCS controller interrupts the reception of Modbus communication data and inquires whether the Modbus address table data is currently being updated.
[0040] Step S5: if the DCS controller is currently updating the Modbus address table data, the data write instruction is cached until the update is completed and then the data write instruction is retrieved and parsed; if the DCS controller is not currently updating the Modbus address table data, the data write instruction is directly parsed.
[0041] Specifically, similar to receiving the Modbus master station read instruction, the DCS controller also interrupts the reception of Modbus communication data and determines the update status of the Modbus address table data to ensure that no data write operation is performed during the update of the Modbus address table data, thereby preventing the execution of the Modbus master station write instruction from conflicting with the DCS internal data storage and processing process, causing data anomalies, defects, errors, etc.
[0042] Step S6, entering the required write data obtained by parsing into the corresponding Modbus address table data, configuring the write flag of the Modbus address and feeding back the response information to the Modbus slave gateway.
[0043] Step S7, the DCS controller writes the data back to the actual operation data area of the DCS controller according to the data write flag of the Modbus address table data in the data processing flow.
[0044] Specifically, when the controller is not updating the Modbus address table data, it directly writes the data into the Modbus address table and sets the write flag of the Modbus address to respond to the write command; if the Modbus address table is being updated, the write command is cached and the controller waits for the Modbus address table to be updated before writing the data into the Modbus address table and setting the write flag of the Modbus address to respond to the gateway write command. The Modbus master station writes data to each device in the user-defined configuration in the DCS process control by sending a write command, which improves the scalability of the Modbus master station command.
[0045] In a specific embodiment, the DCS controller configures the configuration according to the Modbus slave station data in the periodic scheduling task, and after monitoring the data write flag of the Modbus address, writes the data in the Modbus address table into the bit number data and variable data area of the DCS controller; at the same time, the corresponding bit number data and variable data are obtained and entered into the Modbus address table to complete the update of the Modbus address table data.
[0046] Among them, the DCS controller also has some abnormal response situations. For example, when the CRC16 check code is incorrect, the DCS will not respond; when the data length and the actual data field in the write multiple registers (FC15) / write multiple coils (FC16) command are inconsistent, the DCS controller will also not respond. For example, for the command 01 10 00 00 00 01 04 11 22CA18, the command indicates that the 4 bytes of data provided should be written into 1 register, but 1 register has only 2 bytes and cannot be written. The data length and the actual data field are inconsistent, and the DCS controller will not respond. The specific abnormal format is shown in the following table:
[0047] Slave Address Function code Error Code CRC16 checksum 01 FC|0x80 ERR CRC16
[0048] Among them, the error code ERR includes but is not limited to various error types defined as 0x01, 0x02, 0x03, etc.: 0x01 indicates that the master station sends a function code that the slave station does not support (function codes other than FC01, FC02, FC03, FC04, FC05, FC06, FC15, and FC16).
[0049] 0x02 indicates that the number of data read or written exceeds the address range.
[0050] 0x03 indicates that the quantity value in the read / write command exceeds the requirements of the Modbus protocol, for example, the number of coils to be written: 1 to 1968, the number of registers to be written: 1 to 123, the number of coils to be read: 1 to 2000, and in the command to write multiple coils / registers, the number of coils / registers is inconsistent with the number of subsequent write data bytes.
[0051] The Modbus communication method based on a DCS controller disclosed in the present invention configures Modbus slave data according to slave data received by the DCS controller, customizes the data content and data format provided to the outside, generates Modbus address table data, and updates the Modbus address table data according to the customized configuration. After the Modbus master station sends a read instruction to the DCS controller through the Modbus slave station gateway, the DCS controller is interrupted from receiving the Modbus master station command and judging whether the Modbus address table data is currently being updated to avoid data conflicts. When the Modbus address table is not updated or the update is completed, the Modbus master station read instruction is executed to obtain the corresponding slave station data from the Modbus address table for data packaging, so that the Modbus master station can access the various collected data and process data selected by the user in the DCS control process and can be provided to the Modbus master station, thereby enhancing the system flexibility and scalability, and improving the data utilization rate and system operation efficiency.
[0052] In another embodiment, a Modbus communication system is also disclosed, as shown in the attached Figure 2 As shown, it includes a DCS controller 1, a Modbus master station 2 and a Modbus slave station gateway 3. The Modbus master station communicates with the DCS controller through the Modbus slave station gateway, wherein: the Modbus master station is used to send a data read instruction to the Modbus slave station gateway; the Modbus slave station gateway is used to receive the data read instruction sent by the Modbus master station and forward it to the DCS controller; the DCS controller is used to interrupt the reception of Modbus communication data after receiving the data read instruction, and query whether the Modbus address table data is currently being updated, and the Modbus address table is a slave station data area established in the controller memory by the DCS controller through the Modbus slave station data configuration; if the DCS controller is currently updating the Modbus address table data, the data read instruction is cached until the update is completed and then the data read instruction is called; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data read instruction, and after being packaged, it is fed back to the Modbus slave station gateway.
[0053] In this embodiment, the DCS controller is also used to: after receiving the data write instruction from the Modbus master station forwarded by the Modbus slave station gateway, interrupt the reception of Modbus communication data, and query whether the Modbus address table data is currently being updated; if the Modbus address table data is currently being updated, cache the data write instruction, and then retrieve and parse the data write instruction after the update is completed; if the Modbus address table data is not currently being updated, directly parse the data write instruction; enter the required write data obtained by the analysis into the corresponding Modbus address table data, configure the write flag of the Modbus address and feedback the response information to the Modbus slave station gateway; and write the data back to the actual operation data area of the DCS controller according to the data write flag of the Modbus address table data in the data processing flow.
[0054] In this embodiment, the DCS controller configures the configuration according to the Modbus slave station data in the periodic scheduling task, and after monitoring the data write flag of the Modbus address, writes the data in the Modbus address table into the bit number data and variable data area of the DCS controller; at the same time, the corresponding bit number data and variable data are obtained and entered into the Modbus address table to complete the update of the Modbus address table data.
[0055] In this embodiment, the Modbus slave gateway uses the UDP protocol to perform point-to-point data transmission to the DCS controller through the control network.
[0056] In this embodiment, the Modbus communication data packet for data interaction between the Modbus slave gateway and the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of the subsequent data, and the function code is used by the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol.
[0057] The functions of the above Modbus communication system basically correspond to the steps of the Modbus communication method based on the DCS controller disclosed in the previous embodiments, so they are not described in detail here. For details, please refer to the Modbus communication method based on the DCS controller disclosed in the previous embodiments. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other.
[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
[0059] In conclusion, the above is only a preferred embodiment of the present invention, and all equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the patent of the present invention.
Claims
1. A Modbus communication method based on a DCS controller, characterized in that: The Modbus master station communicates with the DCS controller through the Modbus slave station gateway. The Modbus communication method includes the following steps: The Modbus master sends data reading instructions to the DCS controller through the Modbus slave gateway; The DCS controller interrupts receiving Modbus communication data after receiving the data reading instruction, and inquires whether the Modbus address table data is currently being updated, wherein the Modbus address table is a slave station data area established in the controller memory by the DCS controller through the Modbus slave station data configuration; If the DCS controller is currently updating the Modbus address table data, the data reading instruction is cached until the update is completed and then the data reading instruction is called; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave station data is obtained from the Modbus address table data according to the data reading instruction, and after packaging, the data is fed back to the Modbus slave station gateway.
2. The Modbus communication method based on the DCS controller according to claim 1, characterized in that: Also includes: After receiving the data write instruction from the Modbus master station forwarded by the Modbus slave station gateway, the DCS controller interrupts the reception of Modbus communication data and inquires whether the Modbus address table data is currently being updated; If the DCS controller is currently updating the Modbus address table data, the data write instruction is cached until the update is completed and then the data write instruction is retrieved and parsed; if the DCS controller is not currently updating the Modbus address table data, the data write instruction is directly parsed; Enter the required write data obtained by parsing into the corresponding Modbus address table data, configure the write flag of the Modbus address and feedback the response information to the Modbus slave gateway; In the data processing flow, the DCS controller writes the data back to the actual operation data area of the DCS controller according to the data write flag of the Modbus address table data.
3. The Modbus communication method based on the DCS controller according to claim 2, characterized in that: Also includes: The DCS controller is configured according to the Modbus slave station data in the periodic scheduling task. After monitoring the data write flag of the Modbus address, the data in the Modbus address table is written into the bit number data and variable data area of the DCS controller; at the same time, the corresponding bit number data and variable data are obtained and entered into the Modbus address table to complete the update of the Modbus address table data.
4. The Modbus communication method based on the DCS controller according to claim 3, characterized in that: The Modbus slave gateway uses the UDP protocol to perform point-to-point data transmission to the DCS controller through the control network.
5. The Modbus communication method based on the DCS controller according to claim 4, characterized in that: The Modbus communication data packet for data interaction between the Modbus slave gateway and the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of the subsequent data, the function code is used for the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol.
6. A Modbus communication system, characterized in that: The system comprises a DCS controller, a Modbus master station and a Modbus slave station gateway, wherein the Modbus master station communicates with the DCS controller through the Modbus slave station gateway, wherein: Modbus master, used to send data reading instructions to the Modbus slave gateway; Modbus slave gateway, used to receive data reading instructions sent by the Modbus master and forward them to the DCS controller; The DCS controller is used to interrupt the reception of Modbus communication data after receiving the data reading instruction, and to query whether the Modbus address table data is currently being updated, wherein the Modbus address table is a slave data area established in the controller memory by the DCS controller through the Modbus slave data configuration; if the DCS controller is currently updating the Modbus address table data, the data reading instruction is cached until the update is completed and then the data reading instruction is called; if the DCS controller is not currently updating the Modbus address table data, the corresponding slave data is obtained from the MODBUS address table data according to the data reading instruction, and after being packaged, the data is fed back to the Modbus slave gateway.
7. The Modbus communication system according to claim 6, characterized in that: The DCS controller is also used to: After receiving the data write instruction from the Modbus master station forwarded by the Modbus slave station gateway, the Modbus communication data is interrupted and whether the Modbus address table data is currently being updated is queried; if the Modbus address table data is currently being updated, the data write instruction is cached until the update is completed and then the data write instruction is retrieved and parsed; if the Modbus address table data is not currently being updated, the data write instruction is directly parsed; the required write data obtained by the parsing is entered into the corresponding Modbus address table data, and the write flag of the Modbus address is configured and the response information is fed back to the Modbus slave station gateway; and in the data processing flow, according to the data write flag of the Modbus address table data, the data is written back to the actual operation data area of the DCS controller.
8. The Modbus communication system according to claim 7, characterized in that: The DCS controller configures the configuration according to the Modbus slave station data in the periodic scheduling task, and after monitoring the data write flag of the Modbus address, writes the data in the Modbus address table into the bit number data and variable data area of the DCS controller; at the same time, obtains the corresponding bit number data and variable data and enters them into the Modbus address table to complete the update of the Modbus address table data.
9. The Modbus communication system according to claim 8, characterized in that: The Modbus slave gateway uses the UDP protocol to perform point-to-point data transmission to the DCS controller through the control network.
10. The Modbus communication system according to claim 9, characterized in that: The Modbus communication data packet for data interaction between the Modbus slave gateway and the DCS controller through the control network consists of a command sequence, an identifier, a length value, a slave address, a function code and Modbus data, wherein the command sequence represents the data sequence number, the identifier is used to represent the master station index in the gateway, the length value is the length of the subsequent data, the function code is used for the controller to identify different responses to errors and correctness in the Modbus data, and the Modbus data is data processed and configured according to the standard Modbus protocol.
Citation Information
Cited By
Interaction method and device between master station equipment and slave station equipment, centralized controller, building management system and storage medium
CN120785680A
Interaction method and device between master station device and slave station device, centralized controller, building management system and storage medium
CN120785680B
Edge computing controller for equipment health diagnostics
RU246276U1
