A network read-write method for PLC data based on a CoDeSys control system
Patent Information
- Application Number
- CN202311152782.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2043-09-07
Smart Images

Figure CN117170739B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial control equipment data security, and relates to a network reading and writing method for PLC data based on the CoDeSys control system. Background Technology
[0002] CoDeSys is a PLC programming software based on the IEC 61131-3 standard, widely used in industrial automation worldwide. CoDeSys supports multiple programming languages, such as ladder diagrams (LD), structured text diagrams (ST), function block diagrams (FB), and sequential function diagrams (SFC), and boasts excellent portability and compatibility. Furthermore, CoDeSys provides a rich set of development tools and libraries for convenient programming and debugging.
[0003] CoDeSys, as an industry-recognized PLC programming software, is widely used in programming various PLC models. Major PLC brands are continuously expanding the models that support CoDeSys programming to meet the needs of different industries. Currently supported models include Siemens PLC, ABB PLC, Beckhoff PLC, Phoenix Contact PLC, WAGO PLC, Delphi PLC, and Schneider PLC, among others.
[0004] Different PLC control manufacturers typically release their own programming software. PLC development engineers need to learn different programming software for different PLC controllers. The code written in different programming software cannot be shared or ported, which increases the development cycle and cost. After using the CoDeSys development system, it is possible to switch between multiple buses, multiple systems, and multiple PLCs.
[0005] However, the problem with the existing technical solutions is that although CoDeSys supports a variety of PLCs, it has a set of common interfaces for communication with different PLCs. However, these interfaces are only provided for CoDeSys DevelopmentSystem to call. Those skilled in the art cannot access different PLCs or read and write PLC data through these interfaces. Summary of the Invention
[0006] This application addresses the technical problems of existing technologies by providing a network read / write method for PLC data based on the CoDeSys control system. This method enables access to different PLCs through these interfaces, achieving the purpose of reading and writing PLC data. The method provided in this application includes the following steps:
[0007] S100: Initialize the system environment, including the following steps:
[0008] S101: Extract the required files from the CODESYS Development System software, including Elau.CoDeSysMinimalProjectInterface.dll, Elau.Netmanage.Core.dll, Elau.Olymp.Communication2.dll, Elau.PDBackUp.Controls.dll, Elau.PDBackUp.Core.dll, Elau.PDBackup.Firmware.dll, Elau.XO.Controls.dll, Elau.XO.Obsolete.Controls.dll, and Elau.XO.Utility.dl;
[0009] S102: Call the CoreEntry class in the Elau.Netmanage.Core.dll file and create a core object;
[0010] S103: Call the StartListening() method of the core object to start listening;
[0011] S104: Call the ControllerCollection class in the Elau.Netmanage.Core.dll file and create a data acquisition controller, saving the ControllersDataArchive interface in the CoreEntry object;
[0012] S105: Determine whether the CoreEntry class and ControllerCollection class were successfully called. If yes, proceed to step S200; otherwise, exit the process.
[0013] S200: Locate the active controller, including the following steps:
[0014] S201: Call the RefreshCommunicationCommand() method in the Elau.Netmanage.Core.dll file to create a refresh controller command object;
[0015] S202: Call the RemoteFunctionCall.WCF.NamedPipeSender.ExecuteNetmanageCommand() method in the Elau.Netmanage.Core.dll file to send a refresh controller command object;
[0016] S203: Call the UpdateControllerData() method of the ControllersDataArchive interface to update the controller content;
[0017] S204: Call the GetAllController() method of the ControllerCollection class to retrieve all controllers;
[0018] S205: Determine whether the ControllerLifeState member value of the controller object is ALIVE. If it is, proceed to step S206; otherwise, end the process.
[0019] S206: Obtain the controller's ID, firmware version, and connection mode;
[0020] S207: Determine if the connection mode is network connection. If yes, proceed to step S208; otherwise, end the process.
[0021] S208: Get the controller's IP address;
[0022] S300: Establishes a connection with the controller;
[0023] S400: Obtain controller information, including firmware version, kernel version, control type, object name, and NETBIOS name;
[0024] S500: Read controller data;
[0025] S600: Writes / uploads data to the controller.
[0026] Preferably, step S300 includes the following steps:
[0027] S301: Call the static member function Instance of the ImageHandler class in the Elau.PDBackUp.Core.dll file to obtain an instance of the ImageHandler class;
[0028] S302: Call the Disconnect() method of the ImageHandler class instance to disconnect, and set the ImageDirectory member value of the ImageHandler class instance to the data storage directory, wherein the member value is the data storage path;
[0029] S303: Call the static member function ComFactory of the APEnvironment class in the Elau.PDBackUp.Core.dll file to obtain an instance of the APEnvironment class;
[0030] S304: Call the RepairCommunication() method of an instance of the APEnvironment class to repair data interaction;
[0031] S305: Call the GetUrlByIpAddress() method to convert the controller's IP address into an accessible URL connection address;
[0032] S306: Call the ConnectByUrl() method of the ImageHandler class instance and establish a connection with the controller.
[0033] Preferably, step S400 includes the following steps: calling the GetController method() of the ControllerCollection class instance to obtain the controller parameter with the specified ID.
[0034] Preferably, step S500 includes the following steps:
[0035] S501: Calls the TransferImageFromControllerToLocal method in Elau.PDBackUp.Core.dll to generate instructions;
[0036] S502: Convert the generated instructions into ICommand objects;
[0037] S503: Call the Execute() method of the ICommand object to read the image data from the controller and save it to the local directory.
[0038] Preferably, step S600 includes the following steps:
[0039] S601: Calls the TransferImageFromLocalToController method in Elau.PDBackUp.Core.dll to generate instructions;
[0040] S602: Convert the generated instructions into ICommand objects;
[0041] S603: Call the Execute() method of the ICommand object to write / upload local data to the controller.
[0042] This invention solves the technical problem in the prior art that it is impossible to access different PLCs through these interfaces, nor can it read or write PLC data. Attached Figure Description
[0043] Figure 1This is a flowchart of the network read / write method for PLC data based on the CoDeSys control system provided by the present invention. Detailed Implementation
[0044] Figure 1 The flowchart illustrates a network read / write method for PLC data based on a CoDeSys control system provided by this invention.
[0045] like Figure 1 As shown, the method includes the following steps:
[0046] S100: Initialize the system environment, including the following steps:
[0047] S101: Extract the required files from the CODESYS Development System software, including Elau.CoDeSysMinimalProjectInterface.dll, Elau.Netmanage.Core.dll, Elau.Olymp.Communication2.dll, Elau.PDBackUp.Controls.dll, Elau.PDBackUp.Core.dll, Elau.PDBackup.Firmware.dll, Elau.XO.Controls.dll, Elau.XO.Obsolete.Controls.dll, and Elau.XO.Utility.dl;
[0048] S102: Call the CoreEntry class in the Elau.Netmanage.Core.dll file and create a core object;
[0049] S103: Call the StartListening() method of the core object to start listening;
[0050] S104: Call the ControllerCollection class in the Elau.Netmanage.Core.dll file and create a data acquisition controller, saving the ControllersDataArchive interface in the CoreEntry object;
[0051] S105: Determine whether the CoreEntry class and ControllerCollection class were successfully called. If yes, proceed to step S200; otherwise, exit the process.
[0052] S200: Locate the active controller, including the following steps:
[0053] S201: Call the RefreshCommunicationCommand() method in the Elau.Netmanage.Core.dll file to create a refresh controller command object;
[0054] S202: Call the RemoteFunctionCall.WCF.NamedPipeSender.ExecuteNetmanageCommand() method in the Elau.Netmanage.Core.dll file to send a refresh controller command object;
[0055] S203: Call the UpdateControllerData() method of the ControllersDataArchive interface to update the controller content;
[0056] S204: Call the GetAllController() method of the ControllerCollection class to retrieve all controllers;
[0057] S205: Determine whether the ControllerLifeState member value of the controller object is ALIVE. If it is, proceed to step S206; otherwise, end the process.
[0058] S206: Obtain the controller's ID, firmware version FW_Version, and connection mode ConnectionMode;
[0059] S207: Determine whether the connection mode is network connection. If yes, proceed to step S208; otherwise, end the process.
[0060] In this embodiment, a ConnectionMode value of 2 indicates a network connection.
[0061] S208: Get the controller's IP address;
[0062] S300: Establish connection with the controller. Step S300 includes the following steps:
[0063] S301: Call the static member function Instance of the ImageHandler class in the Elau.PDBackUp.Core.dll file to obtain an instance of the ImageHandler class;
[0064] S302: Call the Disconnect() method of the ImageHandler class instance to disconnect, and set the ImageDirectory member value of the ImageHandler class instance to the data storage directory, wherein the member value is the data storage path;
[0065] S303: Call the static member function ComFactory of the APEnvironment class in the Elau.PDBackUp.Core.dll file to obtain an instance of the APEnvironment class;
[0066] S304: Call the RepairCommunication() method of an instance of the APEnvironment class to repair data interaction;
[0067] S305: Call the GetUrlByIpAddress() method to convert the controller's IP address into an accessible URL connection address;
[0068] S306: Call the ConnectByUrl() method of the ImageHandler class instance and establish a connection with the controller.
[0069] S400: Obtain controller information, including firmware version Fwversion, kernel version Kernelversion, controller type Controllertype, object name Projectname, and NETBIOS name Netbiosname; Step S400 includes: calling the GetController method() of the ControllerCollection class instance to obtain the controller parameters with the specified ID.
[0070] S500: Read controller data. Step S500 includes the following steps:
[0071] S501: Calls the TransferImageFromControllerToLocal method in Elau.PDBackUp.Core.dll to generate instructions;
[0072] S502: Convert the generated instructions into ICommand objects, that is, format the ICommand objects in the Elau.XO.Utility.dll file using the generated instructions.
[0073] S503: Call the Execute() method of the ICommand object to read the image data from the controller and save it to the local directory.
[0074] S600: Write / upload data to the controller. Step S600 includes the following steps:
[0075] S601: Calls the TransferImageFromLocalToController method in Elau.PDBackUp.Core.dll to generate instructions;
[0076] S602: Convert the generated instructions into ICommand objects; that is, format the ICommand objects in the Elau.XO.Utility.dll file using the generated instructions.
[0077] S603: Call the Execute() method of the ICommand object to write / upload local data to the controller.
[0078] The method provided by this invention solves the technical problem in the prior art that it is impossible to access different PLCs through these interfaces, nor can it read or write PLC data.
[0079] It should be understood that the present invention is not limited to the examples described above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A network read / write method for PLC data based on a CoDeSys control system, characterized in that, Includes the following steps: S100: Initialize the system environment, including the following steps: S101: Extract the required files from the CODESYS Development System software, including Elau.CoDeSysMinimalProjectInterface.dll, Elau.Netmanage.Core.dll, Elau.Olymp.Communication2.dll, Elau.PDBackUp.Controls.dll, Elau.PDBackUp.Core.dll, Elau.PDBackup.Firmware.dll, Elau.XO.Controls.dll, Elau.XO.Obsolete.Controls.dll, and Elau.XO.Utility.dll; S102: Call the CoreEntry class in the Elau.Netmanage.Core.dll file and create a core object; S103: Call the StartListening() method of the core object to start listening; S104: Call the ControllerCollection class in the Elau.Netmanage.Core.dll file and create a data acquisition controller, saving the ControllersDataArchive interface in the CoreEntry object; S105: Determine whether the CoreEntry class and ControllerCollection class were successfully called. If yes, proceed to step S200; otherwise, exit the process. S200: Locate the active controller, including the following steps: S201: Call the RefreshCommunicationCommand() method in the Elau.Netmanage.Core.dll file to create a refresh controller command object; S202: Call the RemoteFunctionCall.WCF.NamedPipeSender.ExecuteNetmanageCommand() method in the Elau.Netmanage.Core.dll file to send a refresh controller command object; S203: Call the UpdateControllerData() method of the ControllersDataArchive interface to update the controller content; S204: Call the GetAllController() method of the ControllerCollection class to retrieve all controllers; S205: Determine whether the ControllerLifeState member value of the controller object is ALIVE. If it is, proceed to step S206; otherwise, end the process. S206: Obtain the controller's ID, firmware version, and connection mode; S207: Determine if the connection mode is network connection. If yes, proceed to step S208; otherwise, end the process. S208: Get the controller's IP address; S300: Establishes a connection with the controller; S400: Obtain controller information, including firmware version, kernel version, control type, object name, and NETBIOS name; S500: Read controller data; S600: Writes / uploads data to the controller.
2. The network read / write method for PLC data based on the CoDeSys control system according to claim 1, characterized in that, Step S300 includes the following steps: S301: Call the static member function Instance of the ImageHandler class in the Elau.PDBackUp.Core.dll file to obtain an instance of the ImageHandler class; S302: Call the Disconnect() method of the ImageHandler class instance to disconnect, and set the ImageDirectory member value of the ImageHandler class instance to the data storage directory, wherein the member value is the data storage path; S303: Call the static member function ComFactory of the APEnvironment class in the Elau.PDBackUp.Core.dll file to obtain an instance of the APEnvironment class; S304: Call the RepairCommunication() method of an instance of the APEnvironment class to repair data interaction; S305: Call the GetUrlByIpAddress() method to convert the controller's IP address into an accessible URL connection address; S306: Call the ConnectByUrl() method of the ImageHandler class instance and establish a connection with the controller.
3. The network read / write method for PLC data based on the CoDeSys control system according to claim 1, characterized in that, Step S400 includes: calling the GetController() method of the ControllerCollection class instance to obtain the controller parameter with the specified ID.
4. The network read / write method for PLC data based on the CoDeSys control system according to claim 1, characterized in that, Step S500 includes the following steps: S501: Calls the TransferImageFromControllerToLocal method in Elau.PDBackUp.Core.dll to generate instructions; S502: Convert the generated instructions into ICommand objects; S503: Call the Execute() method of the ICommand object to read the image data from the controller and save it to the local directory.
5. The network read / write method for PLC data based on the CoDeSys control system according to claim 1, characterized in that, Step S600 includes the following steps: S601: Calls the TransferImageFromLocalToController method in Elau.PDBackUp.Core.dll to generate instructions; S602: Convert the generated instructions into ICommand objects; S603: Call the Execute() method of the ICommand object to write / upload local data to the controller.
Citation Information
Patent Citations
Cross-language platform communication method, system and device based on PLC and medium
CN115794047A
Data sharing system
CN116074397A
