Communication method, device and equipment for PLC control system and monitoring software, and medium
By configuring the logic and variable points of the PLC control system in the configuration software, and generating variable tables to import the monitoring software, the problem of poor communication compatibility between the PLC control system and the third-party monitoring software is solved, and efficient and easy-to-use system communication is achieved.
Patent Information
- Application Number
- CN202510028291.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, poor communication compatibility between the PLC control system and third-party monitoring software leads to reduced ease of use and compatibility of the system, and the existing solutions are complex and costly.
By configuring the logic and variable points of the PLC control system in the configuration software, determine the variable points that communicate with the monitoring software, and set their properties to public, generate a variable table and import it into the monitoring software, real-time read and write operations between the PLC control system and the monitoring software.
Reduces communication complexity, improves interoperability, improves system ease of use and compatibility, and is suitable for communication between PLCs and monitoring software of different brands.
Smart Images

Figure CN119937444A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial communication technology, and in particular to a communication method, device, equipment and medium between a PLC control system and monitoring software. Background Art
[0002] PLC (Programmable Logic Controller) control systems are widely used in the field of industrial automation. They monitor and control field equipment by forming monitoring software with touch screens, independent PCs and other devices. In traditional applications, PLC control systems are usually used in conjunction with monitoring software of the same brand, and the communication protocols are mostly private protocols, which ensures stable data transmission and efficient implementation of control functions. However, the applicability of this solution is limited. It is only compatible with monitoring software provided by specific manufacturers and lacks flexibility and scalability.
[0003] As market demand changes, more and more PLC system users tend to choose third-party monitoring software in order to optimize their choices based on their own usage habits, compatibility with existing on-site environments, and comprehensive costs. However, third-party monitoring software usually uses a communication protocol that is different from the proprietary protocol provided by the manufacturer, which brings about communication compatibility issues between the PLC control system and the third-party monitoring software.
[0004] Existing solutions often involve complex custom protocols or require a lot of manual configuration, which increases the user's learning and usage costs. Even systems that provide universal standard protocols usually still face problems such as high protocol complexity and cumbersome configuration in actual applications, making it difficult for users to quickly and efficiently achieve smooth communication between PLCs of different brands and monitoring software. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a communication method, device, equipment and medium between a PLC control system and monitoring software to solve the problems of complex communication and poor interoperability in the prior art, which lead to reduced usability and compatibility of the system.
[0006] In a first aspect of an embodiment of the present application, a communication method between a PLC control system and monitoring software is provided, comprising: configuring the logic and variable points of the PLC control system in the configuration software, determining the variable points for communicating with the monitoring software, setting the attributes of the variable points to public, and obtaining public variables; generating a variable table according to the public variables, importing the variable table into the monitoring software, extracting variable information from the variable table, creating corresponding variables in the monitoring software according to the variable information and pre-configuring them; initiating a connection request to the PLC controller by using the monitoring software, and after the connection is successful, initiating a server status query request to the PLC controller to determine whether the PLC controller is in an available state; after determining that the PLC controller is available, initiating a server variable table query request to the PLC controller to obtain the public variable information in the PLC controller; according to the public variable information, initiating a read variable request or a write variable request to the PLC controller by using the monitoring software, so as to perform real-time reading and writing operations of variable values between the monitoring software and the PLC controller.
[0007] According to a second aspect of an embodiment of the present application, there is provided a communication device between a PLC control system and monitoring software, comprising: a configuration module configured to configure the logic and variable points of the PLC control system in the configuration software, and determine the variable points for communicating with the monitoring software, and set the attributes of the variable points to be public to obtain public variables; a creation module configured to generate a variable table according to the public variables, import the variable table into the monitoring software, and extract variable information from the variable table, and create corresponding variables in the monitoring software according to the variable information and pre-configure them; a request module configured to initiate a connection request to the PLC controller using the monitoring software, and after the connection is successful, initiate a server status query request to the PLC controller to determine whether the PLC controller is in an available state; an acquisition module configured to initiate a server variable table query request to the PLC controller after determining that the PLC controller is available, so as to obtain the public variable information in the PLC controller; a read-write module configured to initiate a read variable request or a write variable request to the PLC controller using the monitoring software according to the public variable information, so as to perform real-time reading and writing operations of variable values between the monitoring software and the PLC controller.
[0008] According to a third aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the above method are implemented when the processor executes the computer program.
[0009] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0010] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0011] By configuring the logic and variable points of the PLC control system in the configuration software, and determining the variable points for communicating with the monitoring software, setting the attributes of the variable points to public, and obtaining public variables; generating a variable table according to the public variables, importing the variable table into the monitoring software, and extracting variable information from the variable table, creating corresponding variables in the monitoring software according to the variable information and pre-configuring them; using the monitoring software to initiate a connection request to the PLC controller, and after the connection is successful, initiating a server status query request to the PLC controller to determine whether the PLC controller is in an available state; after determining that the PLC controller is available, initiating a server variable table query request to the PLC controller to obtain the public variable information in the PLC controller; according to the public variable information, using the monitoring software to initiate a read variable request or a write variable request to the PLC controller, so that the monitoring software and the PLC controller can perform real-time reading and writing operations of variable values. This application can reduce the complexity of communication, improve interoperability, and enhance the ease of use and compatibility of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 It is a schematic diagram of the communication system architecture of the PLC control system and monitoring software provided in the embodiment of the present application;
[0014] Figure 2 It is a flow chart of a communication method between a PLC control system and monitoring software provided in an embodiment of the present application;
[0015] Figure 3 It is a schematic diagram of the data format of a variable table derived from configuration software provided in an embodiment of the present application;
[0016] Figure 4 It is a schematic diagram of the real-time interaction process between the monitoring software and the PLC controller provided in the embodiment of the present application;
[0017] Figure 5 It is a schematic diagram of the format of the request data header and the response data header commonly used in the variable disclosure protocol message provided in the embodiment of the present application;
[0018] Figure 6It is a schematic diagram of the data format of various types of messages in the variable disclosure protocol provided in the embodiment of the present application;
[0019] Figure 7 It is a structural schematic diagram of a communication device between a PLC control system and monitoring software provided in an embodiment of the present application;
[0020] Figure 8 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0022] PLC control systems are widely used in the field of industrial automation to control and monitor various equipment in the production process. Usually, PLC control systems are equipped with touch screens, independent PCs and other devices. The monitoring software running on these devices is used to display equipment status, operation control, alarm information, etc. These monitoring software interact with the PLC control system through communication protocols to obtain control system data or send control instructions.
[0023] In actual applications, PLC control system suppliers usually provide dedicated monitoring software for their systems. This monitoring software generally uses a manufacturer-specific private communication protocol to ensure compatibility and effectiveness with the PLC system. This solution has its advantages because all components are provided by the same manufacturer, which can ensure the stability and consistency of the system.
[0024] However, in actual industrial applications, end users of PLC control systems often have different needs and preferences. When choosing monitoring software, many users are not limited to the software provided by PLC system suppliers, but will choose other third-party monitoring software on the market according to actual needs. These software may support different hardware platforms and different operating systems, and their functions and interface designs may also be more in line with user needs.
[0025] However, when choosing third-party monitoring software, you will encounter a core problem, that is, the compatibility of communication protocols. Monitoring software from different manufacturers may use different communication protocols, some of which may be private protocols, and some may be open protocols. The complexity and implementation methods of the protocols also vary. Therefore, when users choose third-party software, how to achieve reliable and simple communication between the PLC control system and these monitoring software from different manufacturers becomes a challenge.
[0026] Existing solutions mainly rely on complex protocol conversion or middleware to solve this problem, but these methods often have high technical barriers, increase the complexity of the system, and may also bring high development and maintenance costs. Moreover, due to the diversity of protocols, users may also face debugging difficulties and system incompatibility problems during use. Therefore, existing technologies have certain limitations in terms of ease of use and protocol simplification.
[0027] In view of the problems existing in the prior art, the purpose of this application is to provide a solution that can realize communication between a PLC control system and monitoring software including a third party, and this solution has the advantages of ease of use and simplicity of implementation to solve the problems existing in the prior art. Therefore, to achieve the above purpose, this application provides a PLC variable disclosure solution for monitoring software, including a communication protocol mechanism with the monitoring software, a variable export mechanism of the PLC system, and a communication server implementation mechanism within the PLC system.
[0028] This application solution can make the variables configured in the PLC system available to monitoring software including third parties in a relatively easy-to-use way. This solution solves two common problems between PLC systems and monitoring software on the market: 1) Traditional protocols such as ModbusTCP require two definitions of communication variables in the monitoring software and PLC configuration software, and require complex point-to-point operations for communication variables in advance; 2) Newer protocols such as OPC UA have high introduction costs, and the protocol consumes more resources when running on the PLC controller; This solution has been successfully applied to existing products on the premise of solving the above problems, and through cooperation, mainstream monitoring software manufacturers on the market have also adapted it.
[0029] Before describing the embodiments of the present application in detail, the overall architecture of the communication system between the PLC control system and the monitoring software involved in the technical solution of the present application in actual scenarios is first described in conjunction with the drawings and embodiments. Figure 1 Schematic diagram of the communication system architecture of the PLC control system and monitoring software provided in the embodiment of the present application. Figure 1 As shown, the communication system between the PLC control system and the monitoring software may include the following:
[0030] The communication system between the PLC control system and the monitoring software of the present application involves the following three communication objects: configuration software, PLC controller and monitoring software.
[0031] Among them, normal logic and variable point configuration is performed in the configuration software, and the variable point that needs to communicate with the monitoring software is selected, and its attribute is set to "public". Finally, the public variables are manually exported in the configuration software to obtain an XML format variable table. For the description of each variable and variable type in the variable table, please refer to the following embodiment. At the same time, the configuration software downloads the same logic and variable point information to the PLC controller through the private protocol in the PLC system.
[0032] The PLC controller receives the logic and variable point information sent by the configuration software, and implements the server of the variable disclosure protocol through the built-in firmware inside. The monitoring software, as the client of the variable disclosure protocol, accesses the variables from the server.
[0033] The monitoring software first imports the public variable table exported from the configuration software. The name and type information of all communication variable points can be obtained from the public variable table. The monitoring software uses this information to create the same communication variables inside. This operation avoids the manual secondary definition process of the communication variable points on the monitoring software side, which greatly satisfies the ease of use of the monitoring software communication variable configuration on site. After parsing the public variable table information, the monitoring software enables its pre-built-in variable disclosure protocol client program to interact with the controller in real time.
[0034] The contents of the technical solution of the present application are described in detail below with reference to the accompanying drawings and specific embodiments.
[0035] Figure 2 1 is a flow chart of the communication method between the PLC control system and the monitoring software provided in the embodiment of the present application. Figure 2 As shown, the communication method between the PLC control system and the monitoring software may specifically include:
[0036] S201, configuring the logic and variable points of the PLC control system in the configuration software, determining the variable points for communicating with the monitoring software, setting the attributes of the variable points to public, and obtaining public variables;
[0037] S202, generating a variable table according to the public variables, importing the variable table into the monitoring software, extracting variable information from the variable table, creating corresponding variables in the monitoring software according to the variable information and pre-configuring them;
[0038] S203, using the monitoring software to initiate a connection request to the PLC controller, and after the connection is successful, initiate a server status query request to the PLC controller to determine whether the PLC controller is in an available state;
[0039] S204, after determining that the PLC controller is available, initiating a server variable table query request to the PLC controller to obtain public variable information in the PLC controller;
[0040] S205, based on the public variable information, using the monitoring software to initiate a variable read request or a variable write request to the PLC controller, so that the monitoring software and the PLC controller can perform real-time read and write operations on the variable values.
[0041] In some embodiments, the logic and variable points of the PLC control system are configured in the configuration software, and the variable points for communicating with the monitoring software are determined, and the attributes of the variable points are set to be public, including:
[0042] Configure each functional module of the PLC control system in the configuration software, and define the input, output and control logic of each control module during the configuration process;
[0043] Select the variable points that communicate with the monitoring software, set the corresponding communication properties for each variable point in the configuration software, set the properties of the selected variable points to public, and generate the corresponding public variable information.
[0044] Specifically, first in the configuration software, the user configures each functional module in the PLC control system according to the actual control requirements. For example, in an automated production line, the PLC control system may include multiple functional modules, such as input modules (for collecting sensor signals), output modules (for controlling actuators such as motors and valves), control modules (for implementing specific control logic), etc.
[0045] Users can configure the input and output signals of each functional module in the graphical interface of the configuration software. For example, for a temperature control system, users can define the input module to collect data from the temperature sensor and the output module to control the on / off state of the electric heater; define the temperature control logic in the control module, such as setting the temperature range and starting or stopping the heater when the range is exceeded.
[0046] Furthermore, after configuring the functional modules, the user selects a variable point for communication with the monitoring software. A variable point is a parameter in the PLC system that needs to be shared with the monitoring software, such as the reading of a sensor, the status of a control signal, the operating status of a device, etc. For example, the user may select the reading of a temperature sensor as a variable point for communication with the monitoring software.
[0047] In some examples, for each selected variable point, the user sets its communication properties in the configuration software. Specific communication properties include but are not limited to the following:
[0048] Data type: For example, a variable point can be an integer (INT), a floating point number (FLOAT), etc.
[0049] Data precision: For example, the precision of the temperature variable point can be set to retain two decimal places.
[0050] Read and write permissions: Set whether the variable is "read-only" (such as sensor data) or "read and write" (such as control commands).
[0051] Data update cycle: Set the frequency at which the monitoring software requests the variable data, for example, read the temperature value every 500 milliseconds.
[0052] Furthermore, after completing the variable point selection and attribute configuration, the user sets the attribute of each selected variable point to "public" in the configuration software. This setting means that these variable points will be open to external communication, allowing data interaction with the monitoring software. Public variable points can not only provide real-time data, but also receive control commands from the monitoring software.
[0053] For example, in a PLC control system, the variable point of a temperature sensor is set to public, which means that the monitoring software can read the data of the sensor in real time and send instructions to the PLC control system (such as adjusting the temperature threshold) as needed.
[0054] Further, after setting the variable point attribute to public, the configuration software generates corresponding public variable information. In some examples, the public variable information may generally include the following:
[0055] Variable Name: A unique name to identify the variable, such as "TemperatureSensor_1".
[0056] Data type: For example, "FLOAT" indicates that the variable is a floating point number type.
[0057] Unique Identifier: Each variable has a unique identifier that is used to distinguish different variables.
[0058] Read and write permissions: For example, if the variable is of type "read and write", it means that the sensor data can be read and certain control parameters can be modified through the monitoring software.
[0059] Communication address: indicates the address or storage location of the variable in the PLC control system, such as "0x01", which is used to ensure that the monitoring software can access the variable through the correct communication protocol.
[0060] Through the above steps, the configuration software can not only efficiently configure the variable points in the PLC control system, but also ensure smooth communication with the monitoring software. This method greatly simplifies the configuration process between the PLC system and the monitoring software, improves the interoperability and ease of use of the automation system, and is especially suitable for scenarios where third-party monitoring software is required to communicate with the PLC control system.
[0061] In some embodiments, generating a variable table according to public variables includes:
[0062] Exporting public variable information from the configuration software and forming a variable table, wherein the variable table includes the name, type, byte length, unique identifier and read-write attribute information of each variable;
[0063] The variable table is sent to the PLC controller by using the private communication protocol of the PLC control system, so that the PLC controller creates corresponding public variables and communication interfaces according to the public variable information in the variable table.
[0064] Specifically, after completing the public setting of the variable point, the configuration software automatically exports a variable table containing all public variable information. The table is saved in a standard format (such as XML, CSV, etc.), including detailed description information of each public variable. This variable table can be used to subsequently import data into the monitoring software or send it to the PLC controller.
[0065] For example, the user can send the variable table to the PLC controller through the private communication protocol of the PLC control system. The PLC controller will create corresponding public variables according to the information defined in the variable table and configure the corresponding communication interface for each public variable to exchange data with the monitoring software.
[0066] Furthermore, after the public variable information is generated, the configuration software exports the information into a variable table file in a standard format, such as an XML file format. The file format of the variable table provided in the embodiment of the present application is described below in conjunction with the accompanying drawings and embodiments. Figure 3 Schematic diagram of the data format of the variable table derived from the configuration software provided in the embodiment of the present application. Figure 3 As shown, the data format of the variable table may include the following contents:
[0067] 1. The format of a single communication variable is:
[0068] Variable name: Select the public variable point name in the configuration software.
[0069] Variable type: The type of variable point selected for public use in the configuration software can be a common data type (such as Boolean type, integer type, character type, etc.) or a custom complex data type (such as structure, function block, etc.).
[0070] Byte length: The length information in bytes of the variable point selected for public use in the configuration software.
[0071] Unique identifier: A globally unique identifier assigned to the variable point selected for public use in the configuration software. Considering that the variable name may be long, this unique identifier is used as the only indication of the communication variable when accessing the public variable in the variable disclosure protocol.
[0072] Read-write properties: Select the read-write property information of the public variable point in the configuration software and mark it as read-only or read-write.
[0073] 2. When the communication variable is of complex type, it needs to be described in detail in the public variable table to facilitate the configuration software to identify it. The format is:
[0074] 1) The overall description format of a complex type is;
[0075] Complex variable type name: The name of the complex variable type.
[0076] Byte length: The length information of complex variable type in bytes.
[0077] Complex variable type: The type classification of complex variable type in the PLC system, indicating that it is a common structure type, PLC internal function block type, etc.
[0078] 2) A complex type consists of multiple variables, and the format of its internal variable information is:
[0079] Variable name: The name of the internal component variable of the complex type.
[0080] Type: The type of the internal component variable.
[0081] Byte length: The length information of the internal component variable in bytes.
[0082] Byte offset: The offset information of the internal component variable in the entire complex type in bytes.
[0083] Read-write attributes: read-write attribute information of internal component variables.
[0084] It should be noted that complex types support nesting, and the internal component variables of the complex type are still complex types. In this case, the internal complex types need to be formatted in the same way.
[0085] The following takes the XML file format of the variable table in an actual scenario as an example to describe in detail the data format content of the variable table exported by the configuration software in the above embodiment, which may specifically include the following contents:
[0086]
[0087]
[0088]
[0089]
[0090] According to the data format of the XML file of the above variable table, in the data format of the above XML file:
[0091] 1. The first public variable p1 is a common variable type BOOL, with a length of 1 byte, a unique identifier of 37CE5D9E4891C5F, and has read and write properties.
[0092] 2. The second public variable p2 is a common variable type DWORD, with a length of 4 bytes, a unique identifier of 526F0C74175294A8, and has read and write properties.
[0093] 3. The third public variable p3 is a complex variable type COMSEND, with a length of 20 bytes, a unique identifier of 6346ABE964E2813B, and has read and write properties.
[0094] 4. The complex variable type COMSEND has a length of 20 bytes. It is a function block type and consists of 8 variables. The information of the 8 variables will not be repeated here.
[0095] 5. The fourth public variable p4 is of complex variable type DPSLAVESTDDIAGSTRUCTT YPE, with a length of 10 bytes, a unique identifier of 7F02F066DC3679BD, and has read and write properties.
[0096] 6. The complex variable type DPSLAVESTDDIAGSTRUCTTYPE is 10 bytes long. It is a structure type and consists of 10 variables. The information of the 10 variables will not be repeated here.
[0097] 7. The fifth public variable p5 is a common variable type BOOL array with a length of 21 bytes and a unique identifier of BCE9E7DB8F24087D. It has read and write properties.
[0098] Furthermore, the exported variable table is transmitted to the PLC controller via the private communication protocol of the PLC control system. The private protocol between the configuration software and the PLC controller can be based on TCP / IP, serial communication or other specific manufacturer protocols. For example, the configuration software will encapsulate each item of information in the variable table into a communication data packet and send it to the PLC controller one by one according to the protocol format.
[0099] During the sending process, the PLC controller receives and parses the data in the variable table, for example, parsing the variable table in XML format to extract the variable name, type, address, authority and other information.
[0100] Furthermore, after receiving the variable table, the PLC controller creates corresponding public variables in the controller according to the public variable information defined in the variable table. At the same time, the PLC controller configures a communication interface for each public variable, which may include the following functions:
[0101] Address mapping: Assign a communication address to each variable to facilitate subsequent monitoring software to access the variable through the address.
[0102] Permission management: Set the access rights of variables according to the read-write attributes in the variable table. For example, read-only variables can only be read by the monitoring software, but not written.
[0103] Data update: Configure the update cycle of variables to ensure real-time performance.
[0104] Furthermore, after all public variables and their communication interfaces are configured in the PLC controller, data verification is performed between the configuration software and the PLC controller. For example, the configuration software sends a query command to the PLC controller through a private protocol to confirm whether each variable in the variable table has been successfully created and verify whether the communication address and permission configuration of the variable are correct.
[0105] After verification, the PLC controller is ready to communicate with the monitoring software, and the public configuration process of the variable table is completed.
[0106] This embodiment achieves efficient configuration and management of variables by exporting public variable information from the configuration software and sending it to the PLC controller. The PLC controller creates public variables and communication interfaces based on the received variable table, providing a reliable basis for subsequent communication with the monitoring software. This method effectively simplifies the complex manual configuration process and improves the ease of use and deployment efficiency of the system.
[0107] In some embodiments, variable information is extracted from the variable table, and corresponding variables are created and preconfigured in the monitoring software according to the variable information, including:
[0108] Extracting public variable information from the variable table, creating corresponding communication variables according to the public variable information of each variable, and configuring corresponding communication attributes for each communication variable;
[0109] The preset variable disclosure protocol is enabled, and the monitoring software performs two-way data exchange with the PLC controller through the variable disclosure protocol, so that the communication variables are transmitted in real time between the monitoring software and the PLC controller.
[0110] Specifically, the monitoring software receives and imports the variable table generated from the configuration software, which is stored in XML format and contains information about all public variables. The monitoring software parses the variable table and extracts detailed public information about each variable, such as variable name, data type, byte length, read and write permissions, unique identifier, and communication address.
[0111] Based on the extracted variable information, the monitoring software creates corresponding communication variables internally. Each communication variable corresponds one-to-one to a public variable in the variable table. After creating the communication variables, the monitoring software configures the following properties for each communication variable:
[0112] Communication type: Set the format of the communication variable according to the data type extracted from the variable table, such as integer, floating point, Boolean, etc.;
[0113] Update cycle: Set the synchronization frequency between the communication variables and the PLC controller, for example, update the data every 500 milliseconds;
[0114] Read and write permissions: Set the access mode of the variable according to the permission configuration in the variable table, for example, "read-only" is used to collect sensor data, and "read and write" is used to control the actuator;
[0115] Communication address mapping: associate the communication address recorded in the variable table with the communication variable for data access between the monitoring software and the PLC controller.
[0116] Furthermore, after the communication variables are configured, the monitoring software starts the built-in variable disclosure protocol client. The variable disclosure protocol defines the communication rules between the monitoring software and the PLC controller, including data request format, response format, and communication status management. Through this protocol, the monitoring software can initiate read and write requests to the PLC controller to achieve two-way data interaction.
[0117] Furthermore, with the support of the variable disclosure protocol, a stable communication link is established between the monitoring software and the PLC controller, and real-time data exchange, including read and write operations, begins.
[0118] The read operation is when the monitoring software sends a read request to the PLC controller to obtain the current value of the communication variable. For example, the monitoring software periodically reads the real-time temperature data of the temperature sensor and displays it on the user interface.
[0119] The write operation is when the monitoring software sends a write request to the PLC controller to modify the value of the communication variable as needed. For example, the user sets a new temperature threshold in the monitoring software, and the threshold is transmitted to the PLC controller through a write operation, and the controller adjusts the operating status of the device accordingly.
[0120] The variable disclosure protocol supports dynamic update function, allowing the monitoring software to add, delete or adjust the communication variables according to actual needs during the communication process. For example, after adding a variable point of a pressure sensor, the monitoring software will automatically update its communication variable list and start synchronizing the data of the variable.
[0121] If an abnormality occurs during the communication process, such as the PLC controller is disconnected or a variable address is invalid, the monitoring software will retry or alarm according to the error handling mechanism of the variable disclosure protocol.
[0122] Through the steps of the above embodiment, the monitoring software can accurately create communication variables based on the variable table and complete pre-configuration, and use the variable disclosure protocol to achieve efficient data interaction with the PLC controller. This method greatly simplifies the configuration process of communication variables, improves the compatibility and real-time performance of the system, and is particularly suitable for communication scenarios between multi-brand PLC control systems and monitoring software.
[0123] Furthermore, once the monitoring software completes the variable import, the real-time interaction process with the PLC controller can be started. The real-time interaction process between the monitoring software and the PLC controller is described below in conjunction with the accompanying drawings and embodiments. Figure 4 Schematic diagram of the real-time interaction process between the monitoring software and the PLC controller provided in the embodiment of the present application. Figure 4 As shown, the real-time interaction process between the monitoring software and the PLC controller may include the following steps:
[0124] Step 1: The monitoring software initiates a link request to the controller, and proceeds to step 2 after receiving the successful link request from the controller.
[0125] Step 2: The monitoring software initiates a server status query service to the controller to determine whether the current controller is ready. If so, proceed to step 3; if not, it means the controller is busy. It is recommended that the client access the server once in a while to query the server status until the server returns a success.
[0126] Step 3, the monitoring software initiates a server variable table query request to the controller, queries the variable table identification ID and the data communication address of each variable. When the client subsequently sends a read and write request service to the server, the address will be the unique identifier of each variable used for data communication; when this step is completed, step 4 or step 5 can be performed; this step can be executed multiple times during communication according to the needs of the monitoring software to realize the query of multiple variables or newly added variables.
[0127] Step 4: The monitoring software initiates a read variable service request to the controller to read one or more variables from the controller. Not only simple variables but also complex variables such as arrays and structures can be read: This step can be executed multiple times during the communication period according to the needs of the monitoring software.
[0128] Step 5: The monitoring software initiates a variable write service request to the controller to write one or more variables to the controller. Not only simple variables can be read, but also complex variables such as arrays and structures can be read: This step is generally triggered by the manual variable write operation on the monitoring software side during communication and can be executed multiple times.
[0129] Step 6: The monitoring software initiates a read / write parameter service request to the controller to access or rewrite the parameter information on the controller side during normal communication, thereby realizing real-time reading and modification of the communication parameters on the controller side. In the case of normal exit, abnormality, etc., the monitoring software initiates a disconnect request to the controller to close the current link.
[0130] The specific operations of the steps involved in the real-time interaction between the monitoring software and the PLC controller will be described in detail below in conjunction with specific embodiments.
[0131] In some embodiments, initiating a server status query request to a PLC controller to determine whether the PLC controller is in an available state includes:
[0132] Use the monitoring software to initiate a server status query request to the PLC controller and receive the status response result of the PLC controller;
[0133] Determine whether the PLC controller is in an available state based on the status response result of the PLC controller. When the PLC controller responds that it is unavailable, use the monitoring software to periodically re-initiate a server status query request to the PLC controller until the PLC controller returns to an available state.
[0134] Specifically, after the monitoring software establishes a preliminary connection with the PLC controller, the monitoring software starts the server status query process. The monitoring software sends a server status query request to the PLC controller through a preset communication protocol. The request usually contains a protocol identifier, a function code, and necessary query parameters (such as a version number or a client identifier).
[0135] Furthermore, after receiving the server status query request, the PLC controller parses the request and generates a status response result. The response result may generally include the following contents:
[0136] Current server status code: For example, a status code of "0" indicates that the server is available, and other status codes indicate that the server is unavailable or busy.
[0137] Maximum number of connections supported by the server: used to indicate the maximum number of client connections that the current server can support.
[0138] Maximum number of variables supported by the server: indicates the total number of variables that the current server can manage.
[0139] Server cache status: includes the capacity status of the send cache and receive cache.
[0140] Furthermore, the monitoring software determines whether the PLC controller is in an available state according to the "status code" field in the status response result:
[0141] If the status code is "0", it means that the PLC controller is ready and can perform subsequent operations, such as initiating a server variable table query request;
[0142] If the status code is not "0", it means that the PLC controller is temporarily unavailable, possibly because it is busy with too many processing tasks or other reasons.
[0143] Furthermore, when the monitoring software determines that the PLC controller is unavailable, it enters the timed re-query mode. In this mode, the monitoring software re-initiates the server status query request at a certain interval (such as 500 milliseconds or 1 second) until the status response result returns "Server Available". The timed interval can be configured according to the real-time requirements of the system and the performance of the communication protocol.
[0144] Furthermore, when the status response result indicates that the PLC controller is already in an available state, the monitoring software immediately terminates the status query process and proceeds to the next step (such as server variable table query). At this point, the monitoring software can initiate more data interaction requests, such as reading public variable information or writing control commands, to ensure the real-time and accuracy of data transmission.
[0145] This embodiment ensures that the monitoring software can perform the next operation after the PLC controller is fully ready through the server status query process, thereby improving the stability of communication and the reliability of the system. The data interaction failure caused by the busy controller is avoided through the timed re-query mechanism.
[0146] In some embodiments, a server variable table query request is initiated to a PLC controller to obtain public variable information in the PLC controller, including:
[0147] Use the monitoring software to initiate a server variable table query request to the PLC controller to obtain the identification ID and data communication address of the public variables in the PLC controller;
[0148] The data communication address is used as the unique identifier of the public variable for data communication. During the communication period, the server variable table query request is repeatedly executed according to the needs of the monitoring software to dynamically obtain the latest data information of the public variable.
[0149] Specifically, after the monitoring software establishes a communication connection with the PLC controller and confirms that it is available, the monitoring software initiates a server variable table query request to the PLC controller through a variable disclosure protocol.
[0150] The query request contains a specific function code and necessary parameters, such as the current client ID and the query scope, and is intended to obtain all public variable information in the PLC controller.
[0151] After receiving the query request, the PLC controller parses and generates response data, returning information including the variable table identification ID, the communication address of each public variable and related attributes.
[0152] Furthermore, the monitoring software receives and parses the response data returned by the PLC controller and extracts the following information:
[0153] Variable table identification ID: A unique ID that identifies the current variable table version, used to determine whether the variable table has changed in subsequent queries.
[0154] Data communication address: The communication address of a public variable, used as a unique identifier of the variable in read and write operations.
[0155] Variable attribute information: including variable name, data type (such as Boolean, integer, floating point), byte length, and read and write permissions.
[0156] Based on this information, the monitoring software generates a communication variable mapping table that associates the names of public variables with their communication addresses.
[0157] During communication, if the monitoring software detects a new variable or needs to verify the consistency of the variable table, it can repeatedly initiate a server variable table query request.
[0158] By comparing the returned variable table identification ID, it is determined whether the variable table is updated: if the identification ID has not changed, there is no need to reload the variable information; if the identification ID has been updated, the variable table information is re-extracted and loaded to update the communication variable mapping table.
[0159] This dynamic query mechanism allows the monitoring software to flexibly obtain new variables or adjust variable information according to actual needs.
[0160] In some examples, the monitoring software initiates a write variable service request to the controller to write one or more variables to the controller. Not only simple variables can be read, but also complex variables such as arrays and structures can be read: This step is generally triggered by a manual write variable operation on the monitoring software side during communication and can be executed multiple times.
[0161] Based on the communication variable mapping table, the monitoring software initiates a read variable service request to the PLC controller through the variable disclosure protocol to obtain the current value of one or more public variables. The read request supports multiple data types, including simple variables (such as integers and floating-point numbers) and complex variables (such as arrays and structures).
[0162] For example, the monitoring software can request to read the real-time temperature value of the temperature sensor, the current pressure data of the pressure sensor, or read the device operating status in the form of a structure. The PLC controller returns the value of the specified variable according to the request. For example, the value of the temperature sensor may be "26.5℃" and the value of the pressure sensor may be "101.3kPa".
[0163] In some examples, the monitoring software initiates a write variable service request to the controller to write one or more variables to the controller. Not only simple variables can be read, but also complex variables such as arrays and structures can be read: This step is generally triggered by a manual write variable operation on the monitoring software side during communication and can be executed multiple times.
[0164] For example, the monitoring software sends a new variable value to the PLC controller through a write variable service request to control the device or update the system parameters. Write requests support simple and complex variables. For example, to modify the control parameters: write the new target temperature to the temperature controller; for another example, to control the device: write an "open" or "close" command to the valve variable address to adjust the valve state.
[0165] Write operations are usually triggered by the operating interface of the monitoring software or an automated task. Users can enter new values through the interface or set a scheduled task to update the variable value.
[0166] In actual applications, monitoring software can perform read and write operations multiple times according to real-time needs. For example, sensor data can be read periodically to update the monitoring interface display; control parameters can be dynamically adjusted according to the operating status of the equipment, such as automatically reducing the heating power when the temperature exceeds the set threshold. All read and write operations are performed through the variable disclosure protocol to ensure the reliability and accuracy of data transmission.
[0167] If the monitoring software finds that the variable address is invalid or the communication is interrupted during the reading and writing process, it will trigger the error handling mechanism, for example: prompting the user to check the device connection; recording the error log for subsequent analysis; automatically trying to reconnect and re-initiate the query request to restore communication.
[0168] Through the steps of the above embodiment, the monitoring software can efficiently obtain the public variable information in the PLC controller and realize real-time data interaction based on the dynamic update mechanism of the communication variables. This implementation method supports read and write operations of multiple data types, has good adaptability and scalability, and is particularly suitable for efficient management of equipment and data in complex industrial control systems.
[0169] The formats of the common request data header and response data header in the variable disclosure protocol message of the present application are described below in conjunction with the accompanying drawings and embodiments. Figure 5 Schematic diagram of the format of the request data header and the response data header commonly used in the variable disclosure protocol message provided in the embodiment of the present application. Figure 5 As shown, the general request and response data header formats of the variable disclosure protocol are as follows:
[0170] 1. The request data header format sent by the monitoring software to the controller is as follows:
[0171] Protocol Identifier: A fixed identifier assigned by the company to indicate the public protocol for the variable.
[0172] Server function code: used to specify the function code type. The currently supported function codes are shown in the following table.
[0173]
[0174] Packet sequence number: used to request data to be transmitted in packets. The default value is 0.
[0175] Data length: The total length of the request data packet, which includes the sum of the request data header length and the valid data length.
[0176] 2. The format of the response data header that the controller replies to the monitoring software is as follows:
[0177] Protocol Identifier: A fixed identifier assigned by the company to indicate the public protocol for the variable.
[0178] Server function code: used to specify the function code type of the reply message. For the currently supported function code requests, refer to the request data header format.
[0179] Server status code: used to indicate the current status of the controller, including specific exception information. 0 represents success, and other codes represent exceptions.
[0180] Packet sequence number: used to request data to be transmitted in packets. The default value is 0.
[0181] Data length: The total length of the response data packet, which includes the sum of the response data header length and the valid data length.
[0182] Please continue reading Figure 6 , Figure 6 Schematic diagram of the data format of various types of messages in the variable disclosure protocol provided in the embodiment of the present application. Figure 6 As shown, the format of each server function code in the variable disclosure protocol is as follows:
[0183] 1. Server status query service (0x01):
[0184] 1.1、Request data format:
[0185] Request data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0186] Version number: indicates the version information of the request data, which is used to achieve compatibility with different protocol versions;
[0187] Maximum request timeout: The maximum keep-alive time allowed by the client request server. If the client does not send data within this time, the server will close the connection.
[0188] 1.2. Response data format:
[0189] Response data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0190] Version number: indicates the version information of the response data, which is used to achieve compatibility with different protocol versions;
[0191] Maximum reply timeout: The maximum reply timeout of the server. If the client request time is within the server maximum timeout, the client request timeout is used. Otherwise, the default 30-second timeout is used.
[0192] Maximum number of connections supported by the server: the maximum number of client connections that the server can support simultaneously;
[0193] Maximum number of variables supported by the server: the maximum number of variables that the server can support being accessed by the client;
[0194] Server maximum send buffer: the maximum send buffer size supported by the server;
[0195] Server maximum receive buffer: The maximum receive buffer size that the server can support.
[0196] 2. Server variable table query service (0x02):
[0197] 2.1、Request data format:
[0198] Request data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0199] Version number: indicates the version information of the request data, which is used to achieve compatibility with different protocol versions;
[0200] Extended variable data length: used to indicate the content length of the extended data carried;
[0201] Extended data content: used to store the carried extended data;
[0202] Number of variables: used to indicate the total number of variables in this query;
[0203] Variable ID: The ID used to indicate the query variable, which comes from Figure 2 A unique identifier field in ;
[0204] Note: Multiple variable IDs can be carried in the request data.
[0205] 2.2、Response data format:
[0206] Response data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0207] Version number: indicates the version information of the response data, which is used to achieve compatibility with different protocol versions;
[0208] Variable table identification ID: It is used to indicate the unique ID of the current variable table in the server. The client needs to send this ID in the subsequent request message of the read and write variable service. The server will first check this ID when processing the read and write variable service. If the check is passed, it will respond to the read and write service. Otherwise, an error is returned and the client needs to resend the server variable table query service.
[0209] Extended variable data length: used to indicate the content length of the extended data carried;
[0210] Extended data content: used to store the carried extended data;
[0211] Number of variables: used to specify the total number of query variables contained in the response data;
[0212] Variable address: used to indicate the address information of each query variable. When reading and writing variables later, the request data must carry this address as the only indication of the variable.
[0213] Note: Multiple variable addresses can be carried in the response data, which is determined by the variable identification ID data in the request data, and their arrangement order corresponds to the variable identification ID in the request data.
[0214] 3. Read variable service (0x03):
[0215] 3.1、Request data format:
[0216] Request data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0217] Version number: indicates the version information of the request data, which is used to achieve compatibility with different protocol versions;
[0218] Variable table identification ID: used to indicate the variable table identification ID received by the client when querying the server variable table service. The server is used to perform consistency check on this ID during the variable reading process to prevent the server from actively notifying the client to re-query after the variable table is updated.
[0219] Extended variable data length: used to indicate the content length of the extended data carried;
[0220] Extended data content: used to store the carried extended data;
[0221] Number of variables: used to indicate the total number of variables read this time;
[0222] Variable address: used to indicate the variable address received by the client when querying the server variable table service;
[0223] Variable length: used to indicate the length information of the read variable;
[0224] Note: The combination of variable address and variable length represents a variable information that needs to be read. Multiple copies of the variable information can be carried in the request data. The specific number of copies is determined by the number of variables.
[0225] 3.2、Response data format:
[0226] Response data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0227] Version number: indicates the version information of the response data, which is used to achieve compatibility with different protocol versions;
[0228] Variable table identification ID: used to indicate the unique ID of the current variable table in the server. If the client receives this ID and it is inconsistent with the variable table identification ID stored in itself, the client needs to resend the server variable table query service;
[0229] Extended variable data length: used to indicate the content length of the extended data carried;
[0230] Extended data content: used to store the carried extended data;
[0231] Number of variables: used to indicate the total number of read variables for this response;
[0232] Variable value: used to indicate the current real-time value of the variable to be read;
[0233] Note: There will be multiple variable values according to the number of variables, and the response order corresponds to the variable address of the request data.
[0234] 4. Write variable service (0x04):
[0235] 4.1、Request data format:
[0236] Request data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0237] Version number: indicates the version information of the request data, which is used to achieve compatibility with different protocol versions;
[0238] Variable table identification ID: used to indicate the variable table identification ID received by the client when querying the server variable table service. The server is used to perform consistency check on this ID during the variable reading process to prevent the server from actively notifying the client to re-query after the variable table is updated.
[0239] Extended variable data length: used to indicate the content length of the extended data carried;
[0240] Extended data content: used to store the carried extended data;
[0241] Number of variables: used to indicate the total number of variables written this time;
[0242] Variable address: used to indicate the variable address received by the client when querying the server variable table service;
[0243] Variable length: used to indicate the length of the variable to be written;
[0244] Variable value: used to indicate the value of the variable to be written;
[0245] Note: The combination of variable address, variable length and variable value represents a variable information that needs to be written. Multiple copies can be carried in the request data. The specific number of copies is determined by the number of variables.
[0246] 4.2、Response data format:
[0247] Response data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0248] Version number: indicates the version information of the response data, which is used to achieve compatibility with different protocol versions;
[0249] Variable table identification ID: used to indicate the unique ID of the current variable table in the server. If the client receives this ID and it is inconsistent with the variable table identification ID stored in itself, the client needs to resend the server variable table query service.
[0250] In some embodiments, the method further comprises:
[0251] Using the monitoring software to initiate a read / write parameter service request to the PLC controller during the communication process, wherein the read / write parameter service request is used to read or modify the communication parameters in the PLC controller;
[0252] When the communication session ends or an exception occurs, the monitoring software is used to initiate a disconnect request to the PLC controller to close the current communication link.
[0253] Specifically, during the communication process, the monitoring software initiates a read and write parameter service request to the PLC controller based on the variable disclosure protocol. The request is used to obtain or modify the communication parameters in the PLC controller to ensure the stability and real-time performance of the communication.
[0254] The monitoring software sends a read request to the PLC controller to access the current communication parameters. For example, you can read parameters such as the communication protocol version, data packet timeout, and current connection status. A read request usually contains the following:
[0255] Parameter Identifier: Identifies the specific communication parameter that needs to be read.
[0256] Function code: For example, it indicates the operation type of "read service".
[0257] Client ID: Uniquely identifies the monitoring software that initiates the request.
[0258] After the PLC controller interprets the request, it returns the current value of the specified parameter.
[0259] Furthermore, the monitoring software sends a write request to the PLC controller to modify certain communication parameters. For example, the data transmission timeout can be modified or the maximum number of connections can be adjusted to meet the needs of dynamic application scenarios. A write request usually contains the following:
[0260] Parameter identifier: Indicates the communication parameter that needs to be modified.
[0261] New parameter value: Specifies the value to be written, for example, adjusting the timeout period from 30 seconds to 20 seconds.
[0262] Function code: indicates the operation type of "write service".
[0263] After receiving the request, the PLC controller updates the specified parameters and returns a confirmation response.
[0264] Furthermore, during normal communication, the monitoring software can dynamically adjust the communication parameters according to the system operation status. For example, when the monitoring software detects that the communication delay is high, the data packet timeout can be increased to avoid disconnection; when the device load is reduced, the heartbeat detection interval can be reduced to optimize performance.
[0265] These operations are implemented through read and write parameter services, ensuring that the communication settings of the PLC controller can adapt to the current operating environment at any time.
[0266] Furthermore, at the end of the communication session, the monitoring software will actively initiate a disconnect request to the PLC controller to release the current communication link and clean up the occupied system resources.
[0267] When the monitoring software completes all data reading and writing tasks, it sends a disconnection request through the variable disclosure protocol. The request usually includes the client identification and the disconnection reason. After receiving the request, the PLC controller closes the communication link with the client and returns a disconnection confirmation response.
[0268] Furthermore, if an abnormality occurs during the communication process (such as a network interruption or a PLC controller failure), the monitoring software will automatically try to reconnect. If multiple retries are ineffective, the monitoring software will send a disconnect request to terminate the current communication session.
[0269] In this case, the monitoring software will also record error logs and provide prompt information to the user for subsequent troubleshooting.
[0270] Furthermore, after disconnection, the PLC controller releases related resources, such as closing the corresponding communication port, clearing the temporary cache, etc. The monitoring software marks the current communication session as "ended" and resets the communication state to prepare for subsequent connection requests.
[0271] Through the steps of the above embodiment, the embodiment implements the monitoring software to dynamically read and modify the communication parameters of the PLC controller during the communication process, while ensuring that the communication session can be safely closed when it ends or is abnormal. This implementation method improves the stability and flexibility of the system and is suitable for industrial automation scenarios that require real-time adjustment and management of communication parameters.
[0272] In some examples, the data format of the read / write parameter service (0x05) of this embodiment is as follows:
[0273] 1. Request data format:
[0274] Request data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0275] Version number: indicates the version information of the request data, which is used to achieve compatibility with different protocol versions;
[0276] Read / write parameters: used to indicate whether this operation is a read parameter or a write parameter;
[0277] Number of parameters: used to indicate the total number of parameters read / written this time;
[0278] Parameter ID: used to indicate the ID information of a single parameter;
[0279] Parameter data length: used to indicate the data length of a single parameter. This field does not exist when reading parameters.
[0280] Parameter data: used to indicate the data content of a single parameter. This field does not exist when reading parameters.
[0281] Note: The combination of parameter ID, parameter data length and parameter data represents a parameter information that needs to be read / written. Multiple copies can be carried in the request data. The specific number of copies is determined by the number of parameters.
[0282] 2. Response data format:
[0283] Response data header: refer to the introduction of the above embodiment, which will not be repeated here;
[0284] Version number: indicates the version information of the response data, which is used to achieve compatibility with different protocol versions;
[0285] Number of parameters: used to indicate the total number of parameters read this time. There is no such field when writing parameters.
[0286] Parameter data length: used to indicate the data length of a single parameter when reading parameters. There is no such field when writing parameters.
[0287] Parameter data: used to indicate the data content of a single parameter when reading parameters. There is no such field when writing parameters.
[0288] Note: The parameter data length and parameter data combination represent a parameter information that needs to be read. Multiple copies can be carried in the response data. The specific number of copies is determined by the number of parameters.
[0289] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0290] Figure 7 Schematic diagram of the structure of the communication device between the PLC control system and the monitoring software provided in the embodiment of the present application. Figure 7 As shown, the communication device between the PLC control system and the monitoring software includes:
[0291] Configuration module 701 is configured to configure the logic and variable points of the PLC control system in the configuration software, determine the variable points that communicate with the monitoring software, set the attributes of the variable points to public, and obtain public variables;
[0292] The creation module 702 is configured to generate a variable table according to the public variables, import the variable table into the monitoring software, extract variable information from the variable table, create corresponding variables in the monitoring software according to the variable information, and perform pre-configuration;
[0293] The request module 703 is configured to initiate a connection request to the PLC controller using the monitoring software, and after the connection is successful, initiate a server status query request to the PLC controller to determine whether the PLC controller is in an available state;
[0294] The acquisition module 704 is configured to initiate a server variable table query request to the PLC controller after determining that the PLC controller is available, so as to obtain public variable information in the PLC controller;
[0295] The read / write module 705 is configured to initiate a variable read request or a variable write request to the PLC controller using the monitoring software according to the public variable information, so as to perform real-time reading and writing operations of variable values between the monitoring software and the PLC controller.
[0296] In some embodiments, Figure 7 The configuration module 701 configures each functional module of the PLC control system in the configuration software, and defines the input, output and control logic of each control module during the configuration process; selects variable points for communicating with the monitoring software, sets corresponding communication properties for each variable point in the configuration software, sets the properties of the selected variable points to public, and generates corresponding public variable information.
[0297] In some embodiments, Figure 7 The creation module 702 exports the public variable information from the configuration software and forms a variable table, wherein the variable table includes the name, type, byte length, unique identifier and read-write attribute information of each variable; using the private communication protocol of the PLC control system, the variable table is sent to the PLC controller, so that the PLC controller creates corresponding public variables and communication interfaces according to the public variable information in the variable table.
[0298] In some embodiments, Figure 7 The creation module 702 extracts the public variable information from the variable table, creates corresponding communication variables according to the public variable information of each variable, and configures corresponding communication properties for each communication variable; enables the preset variable disclosure protocol, and the monitoring software performs two-way data exchange with the PLC controller through the variable disclosure protocol, so that the communication variables can be transmitted in real time between the monitoring software and the PLC controller.
[0299] In some embodiments, Figure 7 The request module 703 uses the monitoring software to initiate a server status query request to the PLC controller and receives the status response result of the PLC controller; determines whether the PLC controller is in an available state according to the status response result of the PLC controller. When the PLC controller responds that it is unavailable, the monitoring software is used to periodically re-initiate a server status query request to the PLC controller until the PLC controller returns to an available state.
[0300] In some embodiments, Figure 7 The acquisition module 704 uses the monitoring software to initiate a server variable table query request to the PLC controller to obtain the identification ID and data communication address of the public variables in the PLC controller; the data communication address is used as the unique identifier of the public variable for data communication, and the server variable table query request is repeatedly executed according to the needs of the monitoring software during the communication period to dynamically obtain the latest data information of the public variables.
[0301] In some embodiments, Figure 7 The read / write module 705 uses the monitoring software to initiate a read / write parameter service request to the PLC controller during the communication process, wherein the read / write parameter service request is used to read or modify the communication parameters in the PLC controller; when the communication session ends or an abnormality occurs, the monitoring software is used to initiate a disconnection request to the PLC controller to close the current communication link.
[0302] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0303] Figure 8 Schematic diagram of an electronic device 8 provided in an embodiment of the present application. Figure 8 As shown, the electronic device 8 of this embodiment includes: a processor 801, a memory 802, and a computer program 803 stored in the memory 802 and executable on the processor 801. When the processor 801 executes the computer program 803, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 801 executes the computer program 803, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0304] The electronic device 8 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 8 may include, but is not limited to, a processor 801 and a memory 802. Those skilled in the art will appreciate that Figure 8 The electronic device 8 is merely an example and does not limit the electronic device 8 . The electronic device 8 may include more or fewer components than those shown in the figure, or different components.
[0305] The processor 801 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0306] The memory 802 may be an internal storage unit of the electronic device 8, for example, a hard disk or memory of the electronic device 8. The memory 802 may also be an external storage device of the electronic device 8, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 8. The memory 802 may also include both an internal storage unit of the electronic device 8 and an external storage device. The memory 802 is used to store computer programs and other programs and data required by the electronic device.
[0307] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0308] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium (e.g., a computer-readable storage medium). Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable storage media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0309] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A communication method between a PLC control system and monitoring software, characterized in that: include: The logic and variable points of the PLC control system are configured in the configuration software, and the variable points for communicating with the monitoring software are determined, and the attributes of the variable points are set to be public to obtain public variables; Generate a variable table according to the public variables, import the variable table into the monitoring software, extract variable information from the variable table, create corresponding variables in the monitoring software according to the variable information and perform pre-configuration; Initiate a connection request to the PLC controller using the monitoring software, and after the connection is successful, initiate a server status query request to the PLC controller to determine whether the PLC controller is in an available state; After determining that the PLC controller is available, initiating a server variable table query request to the PLC controller to obtain public variable information in the PLC controller; According to the public variable information, the monitoring software is used to initiate a variable read request or a variable write request to the PLC controller, so that the monitoring software and the PLC controller can perform real-time reading and writing operations on variable values.
2. The method according to claim 1, characterized in that The step of configuring the logic and variable points of the PLC control system in the configuration software, determining the variable points for communicating with the monitoring software, and setting the attributes of the variable points to be public includes: The various functional modules of the PLC control system are configured in the configuration software, and the input, output and control logic of each control module are defined during the configuration process; Select variable points that communicate with the monitoring software, set corresponding communication attributes for each variable point in the configuration software, set the attributes of the selected variable points to be public, and generate corresponding public variable information.
3. The method according to claim 1, characterized in that: The step of generating a variable table according to the public variables comprises: Exporting public variable information from the configuration software and forming the variable table, wherein the variable table includes the name, type, byte length, unique identifier and read-write attribute information of each variable; The variable table is sent to the PLC controller by using the private communication protocol of the PLC control system, so that the PLC controller creates corresponding public variables and communication interfaces according to the public variable information in the variable table.
4. The method according to claim 1, characterized in that: The step of extracting variable information from the variable table, creating corresponding variables in the monitoring software according to the variable information, and performing pre-configuration includes: Extracting public variable information from the variable table, creating corresponding communication variables according to the public variable information of each variable, and configuring corresponding communication attributes for each communication variable; A preset variable disclosure protocol is enabled, and the monitoring software performs bidirectional data exchange with the PLC controller through the variable disclosure protocol, so that the communication variables are transmitted in real time between the monitoring software and the PLC controller.
5. The method according to claim 1, characterized in that The initiating a server status query request to the PLC controller to determine whether the PLC controller is in an available state includes: Initiate a server status query request to the PLC controller using the monitoring software, and receive a status response result of the PLC controller; Determine whether the PLC controller is in an available state according to the status response result of the PLC controller. When the PLC controller responds that it is unavailable, use the monitoring software to periodically re-initiate a server status query request to the PLC controller until the PLC controller returns to an available state.
6. The method according to claim 1, characterized in that The initiating a server variable table query request to the PLC controller to obtain public variable information in the PLC controller includes: Initiate a server variable table query request to the PLC controller using the monitoring software to obtain the identification ID and data communication address of the public variables in the PLC controller; The data communication address is used as a unique identifier of the public variable for data communication, and during the communication period, the server variable table query request is repeatedly executed according to the requirements of the monitoring software to dynamically obtain the latest data information of the public variable.
7. The method according to claim 1, characterized in that The method further comprises: Initiate a read / write parameter service request to the PLC controller using the monitoring software during the communication process, wherein the read / write parameter service request is used to read or modify the communication parameters in the PLC controller; When the communication session ends or an abnormality occurs, the monitoring software is used to initiate a disconnection request to the PLC controller to close the current communication link.
8. A communication device between a PLC control system and monitoring software, characterized in that: include: A configuration module is configured to configure the logic and variable points of the PLC control system in the configuration software, determine the variable points that communicate with the monitoring software, set the attributes of the variable points to public, and obtain public variables; A creation module is configured to generate a variable table according to the public variables, import the variable table into the monitoring software, extract variable information from the variable table, create corresponding variables in the monitoring software according to the variable information and perform pre-configuration; A request module is configured to initiate a connection request to the PLC controller using the monitoring software, and after the connection is successful, initiate a server status query request to the PLC controller to determine whether the PLC controller is in an available state; an acquisition module, configured to initiate a server variable table query request to the PLC controller after determining that the PLC controller is available, so as to obtain public variable information in the PLC controller; The read / write module is configured to initiate a variable read request or a variable write request to the PLC controller using the monitoring software according to the public variable information, so as to perform real-time reading and writing operations of variable values between the monitoring software and the PLC controller.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Software architecture for numerical control system, software control method and application
CN120686729A