Method for quick reconfiguration of PLC (Programmable Logic Controller) function block unit
Through the automatic code generation of Matlab/Simulink software and Simulink PLC Coder module, the problems of automation, accuracy and efficiency in the reconstruction process of PLC function block units are solved, achieving fast and accurate reconstruction and reducing the risk of human error. And ensure that the code complies with standards, providing an efficient solution for industrial control.
Patent Information
- Application Number
- CN202410921842.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-10-11
AI Technical Summary
The reconstruction process of traditional PLC function block units is cumbersome, lacks automation, accuracy and efficiency, and increases the risk of manual compilation errors.
Matlab/Simulink software is used for graphical modeling and simulation verification, and combined with the automatic code generation of the Simulink PLC Coder module, codes that comply with the IEC61131-3 standard are directly generated to achieve rapid reconstruction of function blocks.
It achieves fast and accurate reconstruction of PLC function block units, saves reconstruction time, reduces the risk of human errors, and ensures that the generated code complies with standards, providing an efficient and reliable reconstruction solution for industrial control systems.
Smart Images

Figure CN118760045A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for fast reconfiguration of a PLC function block unit, belonging to the technical field of PLC control. Background Art
[0002] In a PLC (Programmable Logic Controller), a function block represents a specific logic element or code unit that can perform operations such as logical operations, mathematical operations, and control operations.
[0003] The traditional PLC function block unit reconstruction process is cumbersome and requires manual code writing and complex system compatibility simulation testing. Existing technologies lack automation, accuracy and efficiency in the reconstruction process, which makes the reconstruction process complex and time-consuming. Manual code writing also increases the risk of manual compilation errors.
[0004] In view of the defects of the prior art, it is an urgent problem to be solved by those skilled in the art to propose an efficient, accurate and code-compliant functional block reconstruction method. Summary of the invention
[0005] The purpose of the present invention is to overcome the shortcomings of the prior art and propose a new innovative solution. By using Matlab / Simulink software, graphical modeling and simulation verification of modular function blocks can be used to quickly establish and verify dynamic models. In addition, the automatic code generation feature of the Simulink PLC Coder module can be combined to directly generate codes that comply with the IEC61131-3 standard, thereby achieving rapid reconstruction of function blocks.
[0006] The technical solution of the present invention is as follows:
[0007] S1: Use the built-in modules or Matlab Function in Matlab / Simulink to build the dynamic equations and function expressions in the PLC function block function that needs to be reconstructed, and choose to add new control algorithms. After the model is built, use Matlab / Simulink to test the simulation results.
[0008] S2: The Simulink algorithm model with ideal simulation effect is reconstructed into several atomic subsystems according to the requirements and the code generation compatibility test is performed. After the compatibility test is passed, the environment required for Matlab automatic code generation is configured and Simulink PLC Coder is used to realize automatic code generation.
[0009] S3: Integrate the XML file or structured text generated by Matlab / Simulink that complies with the PLC IEC61131-3 standard into the target IDE executor in sequence, and use the operator function block provided by the target executor to rebuild it to achieve the reconstruction of the PLC function block unit.
[0010] To further improve the solution, the specific operation flow of step S1 is as follows:
[0011] S11: The function program contained in the PLC function block is reduced to a dynamic equation, and remodeled using the graphical digital operation block and logic operation block provided by Simulink.
[0012] S12: According to the specific requirements of the reconstruction, add the algorithm to the Simulink model again or reserve the algorithm integration interface according to the PLC function block requirements.
[0013] S13: Discretize the built Simulink model. PLC is a discrete periodic system, and the sampling cycle time is based on the target IDE sampling time.
[0014] S14: Perform simulation test on the discretized Simulink model, and save the Simulink program and parameters that can achieve the expected effect.
[0015] To further improve the solution, the specific operation flow of step S2 is as follows:
[0016] S21: The Simulink model that achieves the expected simulation effect is created as a subsystem, and the subsystem is converted into an atomic subsystem using the SimulinkPLC Coder module. The sampling time is selected as the scheduling type, and the sampling time is the discrete sampling period of the target actuator.
[0017] S22: Verify the compatibility of the atomic subsystem using the Simulink PLC Coder function built into Matlab.
[0018] S23: configure the target executor environment for the verified atomic subsystem, select the solver and step size adapted to the target executor for testing, and after the test is completed, select the target executor version parameters to obtain a structured text or XML file that can be directly run on the PLC.
[0019] In order to further improve the solution, the PLC function block units that need to be reconstructed include splitting a single function block into several function blocks for recalculation; merging several function blocks into a single function block for iterative calculation; adding and integrating new algorithm interfaces for existing function blocks, such as adding a Kalman filter algorithm to solve the optimal value for the soft PLC controller with low existing algorithm accuracy, adding a feedback controller output interface and an encoder to collect the controlled object output interface and an algorithm compensation input interface; and redesigning a new overall or block model of an integrated motion control high-precision algorithm for the controlled object.
[0020] To further improve the solution, if the automatic code generation compatibility test fails, you can modify the error items or reconfigure the Matlab environment according to the Matlab command line prompts.
[0021] To further improve the solution, the goal of the Simulink automatic code generation is to generate executable code that has been verified by Simulink simulation and meets the expected control algorithm requirements and can generate executable code for the target actuator.
[0022] To further improve the solution, the member names and order of the input and output ports of the automatic code generation control algorithm should be consistent with the Simulink input and output ports; the naming rules of the internal structure variables, main functions and main functional functions of the model can be customized by the user and must comply with the code generation specifications; the source mdl model file generated by the automatic code is generated by Simulink PLC Coder to generate XML files and ST language files, which are saved in the plcsrc folder grouped inside the folder where the Simulink source file is located. Users can import them into the target executor for testing and application.
[0023] To further improve the solution, the discretization method of the Simulink model cannot exceed the computing power requirements of the target actuator, and the discrete cycle time should be consistent with the sampling time of the target actuator.
[0024] To further improve the solution, if a single function block is reconstructed into several function blocks for iterative calculation, the input and output wiring of the operator function block of the target actuator should be consistent with the wiring of the Simulink atomic subsystem.
[0025] Compared with the prior art, the present invention has at least the following beneficial effects:
[0026] The present invention uses Matlab / Simulink software as the core to achieve fast and accurate PLC function block unit reconstruction. Through graphical modeling, automatic code generation and system compatibility verification, it saves reconstruction time, reduces the risk of human error, and ensures that the generated code meets the standards, providing an efficient and reliable reconstruction solution for industrial control systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 The present invention is a flowchart of a method for rapid reconfiguration of a PLC function block unit.
[0028] Figure 2 This is a specific operation flow chart of step S1 of the present invention.
[0029] Figure 3 This is a specific operation flow chart of S2 of the present invention.
[0030] Figure 4 It is a functional block unit before reconstruction of the DC torque motor control system in the embodiment of the present invention.
[0031] Figure 5 It is a reconstructed functional block unit of the DC torque motor control system in the embodiment of the present invention. DETAILED DESCRIPTION
[0032] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The described embodiments are only a part of the embodiments of the present invention, but the present invention is not limited to these embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0033] See also Figure 1 , which is a method for fast reconfiguration of PLC function block functions according to the present invention, comprising at least the following steps:
[0034] Step S1: Use the built-in modules or Matlab Function in Matlab / Simulink to build the dynamic equations and function expressions in the PLC function block function that needs to be reconstructed, and choose to add a new control algorithm. After the model is built, use Matlab / Simulink to test the simulation results.
[0035] Step S2: The Simulink algorithm model with ideal simulation effect is reconstructed into several atomic subsystems according to the requirements and a code generation compatibility test is performed. After the compatibility test passes, the environment required for Matlab automatic code generation is configured and Simulink PLC Coder is used to realize automatic code generation.
[0036] Step S3: Integrate the XML file or structured text generated by Matlab / Simulink and compliant with the PLC IEC61131-3 standard into the target IDE executor in sequence, and use the operator function block of the target executor to rebuild it to achieve the reconstruction of the PLC function block unit.
[0037] See also Figure 2 , which is a flowchart of step S1 in an embodiment of the present invention, wherein the specific operation flow of step S1 includes:
[0038] S11: The function program contained in the PLC function block is reduced to a dynamic equation, and remodeled using the graphical digital operation block and logic operation block provided by Simulink.
[0039] S12: According to the specific requirements of the reconstruction, add the algorithm to the Simulink model again or reserve the algorithm integration interface according to the PLC function block requirements.
[0040] S13: Discretize the built Simulink model. PLC is a discrete periodic system, and the sampling cycle time is based on the target IDE sampling time.
[0041] S14: Perform simulation test on the discretized Simulink model, and save the Simulink program and parameters that can achieve the expected effect.
[0042] See also Figure 3 , which is a flowchart of step S1 in an embodiment of the present invention, wherein the specific operation flow of step S1 includes:
[0043] First, the Simulink model that achieves the expected simulation effect is created as a subsystem, and the SimulinkPLC Coder module is used to convert the subsystem into an atomic subsystem. The sampling time is selected as the scheduling type, and the sampling time is the discrete sampling period of the target actuator.
[0044] Then the atomic subsystem is verified for subsystem compatibility using the Simulink PLC Coder function built into Matlab.
[0045] Finally, the target executor environment is configured for the verified atomic subsystem, and the solver and step size adapted to the target executor are selected for testing. After the test is completed, the target executor version parameters are selected to obtain a structured text or XML file that can be directly run on the PLC.
[0046] In this embodiment, the PLC function block unit that needs to be reconstructed includes splitting a single function block into several function blocks for recalculation; including merging several function blocks into a single function block for iterative calculation; including adding and integrating new algorithm interfaces for existing function blocks, such as adding a Kalman filter algorithm to solve the optimal value for a soft PLC controller with low existing algorithm accuracy, and adding a feedback controller output interface and an encoder to collect the controlled object output interface and an algorithm compensation input interface; including redesigning a new overall or block model of an integrated motion control high-precision algorithm for the controlled object.
[0047] It should be noted that if the automatic code generation compatibility test fails, you can modify the error items or reconfigure the Matlab environment according to the Matlab command line prompts.
[0048] The goal of Simulink automatic code generation is to generate executable code for the target actuator that has been verified by Simulink simulation and meets the expected control algorithm requirements.
[0049] In this embodiment, the member names and order of the input and output ports of the automatic code generation control algorithm should be consistent with the Simulink input and output ports; the naming rules of the internal structure variables, main functions and main functional functions of the model can be customized by the user and must comply with the code generation specifications; the source mdl model file generated by the automatic code is generated by Simulink PLC Coder to generate XML files and ST language files, which are saved in the plcsrc folder grouped inside the folder where the Simulink source file is located. Users can import it into the target executor for testing and application.
[0050] In this embodiment, it should be noted that the discretization method of the code Simulink model cannot exceed the computing power requirement of the target executor, and the discrete cycle time should be consistent with the sampling time of the target executor.
[0051] If a single function block is reconstructed into several function blocks for iterative calculation, the input and output wiring of the operator function block of the target executor should be consistent with the wiring of the Simulink atomic subsystem.
[0052] See also Figure 4 , the functional block shown is a DC torque motor model in an embodiment of the present invention, and the model is controlled by an ADRC self-disturbance rejection control algorithm. The overall motor model shown is not conducive to monitoring the internal working state of the motor, so it needs to be reconstructed.
[0053] See also Figure 5 , the functional blocks shown are Figure 4After the functional block is reconstructed, the overall input and output are divided into a plurality of sub-functional blocks by adopting the functional block reconstruction method of the present invention, and the effect of superposition of operations is achieved, which makes it easier to monitor the internal working state of the motor.
[0054] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. The present invention discloses a method for fast reconfiguration of a PLC function block unit. It is characterized in that The following steps are involved: S1. Use the built-in modules or Matlab Function in Matlab / Simulink to build the dynamic equations and function expressions in the PLC function block function that needs to be reconstructed, and choose to add a new control algorithm. After the model is built, use Matlab / Simulink to test the simulation results; S2. The algorithm module to be reconstructed for the Simulink algorithm model with ideal simulation effect is divided into several atomic subsystems according to the requirements and the code generation compatibility test is performed. After the compatibility test is passed, the environment required for automatic code generation in Matlab is configured and automatic code generation is realized using Simulink PLC Coder; S3. Integrate the XML file or structured text generated by Matlab / Simulink that complies with the PLC IEC61131-3 standard into the target IDE executor in sequence, and use the operator function block of the target executor to rebuild and integrate the motion control algorithm to achieve the reconstruction of the PLC function block unit.
2. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that The specific operation process of step S1 is as follows: S11, reducing the function program contained in the PLC function block to a dynamic equation, and remodeling it using the graphical digital operation block and logic operation block provided by Simulink; S12. According to the specific requirements of the reconstruction, add the algorithm to the Simulink model again or reserve the algorithm integration interface according to the requirements of the PLC function block; S13. Discretize the built Simulink model. PLC is a discrete periodic system. The sampling cycle time is based on the target IDE sampling time. S14, performing simulation test on the discretized Simulink model, and saving the Simulink program and parameters that can achieve the expected effect.
3. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that The specific operation process of step S2 is as follows: S21, creating the Simulink model that achieves the expected effect of the simulation as a subsystem, and using the Simulink PLCCoder module to convert the subsystem into an atomic subsystem, selecting the sampling time as the scheduling type, and the sampling time taking the discrete sampling period of the target actuator; S22, verifying the compatibility of the atomic subsystem using the Simulink PLC Coder function built into Matlab; S23. Configure the target executor environment for the verified atomic subsystem, select the solver and step size that are compatible with the target executor for testing, and after the test is completed, select the target executor version parameters to obtain a structured text or XML file that can be directly run on the PLC.
4. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that The PLC function block units that need to be reconstructed include splitting a single function block into several function blocks for recalculation; including merging several function blocks into a single function block for iterative calculation; including adding and integrating new algorithm interfaces for existing function blocks, such as adding a Kalman filter algorithm to solve the optimal value for the soft PLC controller with low existing algorithm accuracy, adding a feedback controller output interface and an encoder acquisition controlled object output interface and an algorithm compensation input interface; It includes redesigning the overall or block model of the new integrated motion control high-precision algorithm for the controlled object.
5. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that If the automatic code generation compatibility test fails, you can modify the error items or reconfigure the Matlab environment according to the Matlab command line prompts.
6. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that The goal of the Simulink automatic code generation is to generate executable code that has been verified by Simulink simulation and meets the expected control algorithm requirements and can generate a target actuator.
7. A method for rapid reconfiguration of a PLC function block unit according to claim 1, It is characterized in that The member names and order of the input and output ports of the automatic code generation control algorithm should be consistent with the Simulink input and output ports; the naming rules of the internal structure variables, main functions and main functional functions of the model can be customized by the user and must comply with the code generation specifications; the source mdl model file generated by the automatic code is generated by Simulink PLC Coder to generate XML files and ST language files, which are saved in the plcsrc folder grouped inside the folder where the Simulink source file is located. Users can import it into the target executor for testing and application.
8. A method for rapid reconfiguration of a PLC function block unit according to claim 2, It is characterized in that The discretization method of the Simulink model cannot exceed the computing power requirement of the target actuator, and the discrete cycle time should be consistent with the sampling time of the target actuator.
9. A method for rapid reconfiguration of a PLC function block unit according to claim 4, It is characterized in that If a single function block is reconstructed into several function blocks for iterative calculation, the input and output wiring of the operator function block of the target executor should be consistent with the wiring of the Simulink atomic subsystem.
Citation Information
Cited By
Robot control reconstruction method and system based on PLC replacement
CN121625172A
Robot control reconstruction method and system based on plc replacement
CN121625172B
