PLC control code automatic generation method based on SysML model
Through the automatic conversion of SysML models to PLC codes, combined with a variety of model conversion technologies, the problems of low efficiency and poor reliability of traditional manual writing of codes are solved, efficient and accurate PLC control code generation is achieved, and system development efficiency and quality are improved.
Patent Information
- Application Number
- CN202410769361.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-11
AI Technical Summary
Traditional hand-written PLC control codes are prone to errors when dealing with complex software systems. Modifying and updating the source code requires a lot of time and energy, and it is difficult to meet the flexibility and rapidly changing needs of complex systems.
Adopt the method of automatically generating PLC control code based on SysML, through automatic conversion of SysML model to PLC code, combined with PLC configuration file, ladder diagram expansion and state diagram to structured text expansion, to achieve automatic generation and optimization of PLC control logic to ensure the generation of The running efficiency, stability and accuracy of the code.
It improves system development efficiency and the correctness of control logic, reduces the workload of manual coding, significantly reduces system development costs, shortens the development cycle, and improves system quality and performance.
Smart Images

Figure CN118760042A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for automatically generating PLC control codes based on System Modeling Language (SysML). The method can automatically integrate, optimize and generate PLC control programs in the process of system design and modeling. Background Art
[0002] With the rapid development of industrial automation and the widespread application of embedded systems in the field of industrial control, the complexity of software systems is increasing, and the diversity and variability of customer needs are also increasing. In order to meet the rapid changes in software development of complex systems and consumer needs, manufacturing systems need to have a high degree of flexibility and reconfigurability. However, the traditional method of manually writing source code becomes difficult and error-prone when dealing with large-scale and complex software systems, and modifying and updating source code usually requires a lot of time and effort. To solve these problems, model-driven methods came into being. Developers use formalized abstract models to describe various aspects of the software system, providing system-level design and analysis capabilities in the early stages of model development. Modifications and updates to the software system can be made at the model level and can be reflected in the generated code. The entire development process is driven by the conversion between different models. As a powerful system modeling language, SysML provides an ideal foundation and tool for automatically generating PLC control code. Summary of the invention
[0003] The present invention provides a method for automatically generating PLC control code based on a SysML model, which realizes automatic conversion from a SysML model to actual PLC code by extending SysML, and comprises the following steps:
[0004] Step 1: Based on the various model elements provided in the SysML model, select the System Component Model and System Process Model in the SysML model to express the structure and manufacturing process of the manufacturing system.
[0005] Step 2: Analyze the essential correspondence between the SysML model and the PLC system, introduce PLC system programming elements and associations, establish a mapping relationship between SysML model elements and PLC system programming elements, create a PLC configuration file, and perform ladder diagram expansion and state diagram to structured text expansion.
[0006] Step 3: Automatically convert the SysML model to the actual PLC code.
[0007] Step 4: Taking operation efficiency, stability and accuracy as optimization indicators, optimize the PLC control logic generated by integrating PLC configuration files, ladder diagram extensions and state diagrams into structured text extensions.
[0008] Preferably, the step 1 comprises the following steps:
[0009] Step 1: Generate use cases from requirements and represent and illustrate the use cases through blocks in the system process model, ensuring that the use case names are concise and clear, the descriptions are complete and accurate, and the steps are arranged in a logical order.
[0010] Step 2: By analyzing the system process model, identifying various functions and operations, using Python programming technology, finding the various components of the manufacturing system and defining the functions and interfaces of each component based on the corresponding functions identified by the system process model, thereby constructing a system component model; wherein the components include physical components, software components, and logical components, and the interfaces include input modules, output modules, and method modules. Determine the component boundaries, divide the manufacturing system into independent components, and define the relationships between components to ensure the flexibility and maintainability of the manufacturing system.
[0011] Step 3: Assign operations in the system process model to these components. In this process, other types of models are generated to record temporary design results or provide auxiliary information. The system component model is a model used to describe the components of the manufacturing system and the relationships between them. Compared with the system component model that captures the static structure of the manufacturing system, the system process model captures the dynamic behavior of the manufacturing system and transmits signals between the operations of these components through control flows to build the execution sequence of operations.
[0012] Step 4: Taking operational efficiency, stability and accuracy as optimization indicators, adjust the functions and interfaces of each component and optimize the system component model.
[0013] Preferably, the step 2 comprises the following steps:
[0014] Step 1: Analyze the specific structure of the SysML model and the PLC system, identify the model elements related to the PLC control program from the SysML model, including input, output, state machine, activity and control logic, and determine the mapping relationship between the model elements of the SysML model and the programming elements of the PLC system.
[0015] Step 2: Create a custom PLC configuration file, introduce the model elements and constraints of the SysML model related to the PLC control program, use the model elements related to the PLC control program in the SysML model to describe the PLC control logic, and use the operation accuracy as the optimization indicator to adjust the mapping relationship and optimize the PLC control logic.
[0016] Step 3: Through ladder diagram expansion, the SysML model describing the behavior and control logic of the manufacturing system is converted into a ladder diagram to realize programming of the control logic into the PLC system.
[0017] Step 4: Taking operation efficiency, stability and accuracy as optimization indicators, adjust the mapping relationship, PLC configuration and ladder diagram, and optimize the PLC control logic generated by ladder diagram expansion.
[0018] Step 5: Use the Statechart to Structured Text extension to convert the statechart in the SysML model into a structured text representation in the PLC system, so that the state transitions and behaviors defined in the SysML model can be directly converted into PLC control logic.
[0019] Preferably, the step three comprises the following steps:
[0020] Step 1: Integrate the PLC configuration file, ladder diagram extension, and state diagram into the PLC control logic generated by structured text extension to ensure logical consistency and normal interaction between them.
[0021] Step 2: Load the automatically generated PLC control program after integration into the actual PLC device.
[0022] More preferably, the PLC control program automatically generated after integration is first loaded into the PLC virtual simulator through TIA Portal for testing, and then loaded into the actual PLC device when the test satisfies the control logic.
[0023] Compared with the prior art, the present invention has the following advantages:
[0024] The present invention combines the advantages of system modeling and automated control, and can improve the efficiency of system development and the correctness of control logic; by defining conversion rules, determining the mode and priority of generating control logic, and selecting conversion strategies, it ensures that the generated PLC code meets the specifications and performance requirements, and improves the reusability of low-level components. The present invention adopts a comprehensive model conversion method, combining multiple model conversion technologies, including PLC configuration files, ladder diagram expansion, and state diagram to structured text expansion. This comprehensive method can improve the efficiency and accuracy of conversion, effectively convert SysML models into PLC control codes, and the conversion process from SysML models to PLC control programs is highly automated. Developers only need to perform preliminary model analysis and configuration, and then the system automatically generates PLC control codes, which greatly reduces the workload of manual code writing. The present invention provides system-level design and analysis capabilities in the early stage of model development (i.e., taking operating efficiency, stability and accuracy as optimization indicators, adjusting the functions and interfaces of each component, and optimizing the system component model), which can help developers fully understand and evaluate the behavior and performance of the system in the system design stage, so as to discover and solve potential problems in advance, significantly reduce system development costs, shorten development cycles, and improve system quality and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is the technical route principle diagram of the present invention;
[0026] Figure 2 It is the model analysis and mapping diagram of the present invention;
[0027] Figure 3 It is a PLC configuration file conversion flow chart of the present invention;
[0028] Figure 4 It is a ladder diagram expansion conversion flow chart of the present invention;
[0029] Figure 5 Convert the PLC control program flow chart into the SysML model of the present invention;
[0030] Figure 6 A system structure diagram of a system component model of a manipulator system of the present invention;
[0031] Figure 7 A control component diagram of a system component model of a manipulator system of the present invention;
[0032] Figure 8 is a distribution diagram between the manipulator system and the control component of the present invention;
[0033] Fig. 9 This is a synchronous conversion framework diagram for the application of the handling robot system model of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0035] The present invention proposes a method for automatically generating PLC control codes based on SysML models, aiming to realize automatic conversion from SysML models to actual PLC codes, thereby realizing automatic generation, integration and optimization of control programs in the manufacturing system design and modeling process. First, the manufacturing system design and control logic are represented by SysML models, and the formal specifications of the structure and process of the manufacturing system are defined: the SysML model is deeply analyzed to identify various functions and operations of the system process model in the SysML model, and Python programming technology is used to find out the various components of the manufacturing system and define the functions and interfaces of each component according to the corresponding functions identified by the system process model. The components include physical components, software components and logical components, and the interfaces include input modules, output modules and method modules; the component boundaries are determined, and the manufacturing system is divided into independent components, and the relationship between the components is defined to ensure the flexibility and maintainability of the manufacturing system. Secondly, by analyzing the essential correspondence between SysML model and control logic, the control logic is automatically derived: the control logic of the manufacturing system can be automatically derived from the activities in the activity diagram, the interactions in the sequence diagram, and the state machine in the state diagram in the SysML model. The simple logic and operations in the manufacturing system can be extracted from the activities and interactions. By introducing the ladder diagram extension, the logical structure and sequence of the PLC program can be graphically represented; the state machine is very useful for mapping the states and state transitions of complex logic into structured text code, and the state machine can be used to convert high-level logic into executable code. In this process, by establishing the mapping relationship between SysML model elements and PLC system programming elements, the PLC configuration file is customized to define the relationship between SysML model elements and PLC system programming elements, such as association, inheritance, and dependency, to clearly represent the connection and dependency between them. Thirdly, by combining the PLC configuration file, ladder diagram extension, and state diagram to structured text extension, the SysML model is automatically converted into PLC code, ensuring the logical consistency and normal interaction between them, automatically generating the corresponding PLC control code, and performing the deployment, testing, and debugging of the PLC code. This method analyzes the system model, integrates PLC configuration files, ladder diagrams, state diagrams and structured text for corresponding expansion, covers multiple programming and modeling paradigms, and realizes the integration of SysML tools and PLC programming tools. For complex systems, this method disassembles the system model into different parts and converts them appropriately to meet specific requirements. This method emphasizes ensuring the logical consistency and normal interaction of the PLC control program. In actual industrial automation systems, the correctness and reliability of the control program are crucial. This comprehensive method aims to make full use of the advantages of different tools and technologies to meet the needs of different systems. By combining system engineering with control programming, it improves efficiency and reduces risks, and is expected to play a greater role in the future automation field.
[0036] Specifically, the present invention provides a method for automatically generating PLC control code based on SysML model, which analyzes the system model, integrates PLC configuration files, ladder diagrams, state diagrams and structured texts for corresponding expansion, covers multiple programming and modeling paradigms, and realizes the integration of SysML tools and PLC programming tools, such as Figure 1 As shown, the specific implementation steps are as follows:
[0037] Step 1: Use SysML models to represent the manufacturing system design and control logic, and define the formal specifications of the structure and process of the manufacturing system;
[0038] Step 2: Build the mapping relationship between SysML model elements and PLC programming elements. By creating a custom PLC configuration file and introducing graphical extensions, model information is assigned to the PLC configuration file, ladder diagram, and state diagram to support the overall synchronous conversion of the SysML model starting from the logical architecture stage.
[0039] Step 3: Convert the SysML model into a PLC control program by combining PLC configuration files, ladder diagram extension, and state diagram to structured text extension.
[0040] In step 1 of the present invention, the steps of analyzing the SysML structure are as follows:
[0041] The characteristics of the system process model in the SysML model include structural characteristics and behavioral characteristics, where structural characteristics are called attributes, such as value attributes and component attributes; while behavioral characteristics include activities, interactions, and state machines. The CPU is the core part of the PLC, responsible for executing programs and processing various logical operations. The input module is used to receive external signals, such as sensor signals and button states. These input signals will be passed to the CPU for processing to trigger corresponding control actions. The output module is used to send signals to external devices. According to the judgment of the CPU, the output module transmits the corresponding signal to the external device to realize the control action. In the SysML system design model, the input module and the output module play an important role in the system design. Although the SysML model does not directly represent the physical entities of the input module and the output module, the input and output of the SysML model can be effectively described by using the port, signal flow, and control flow chart model elements, and their interactive relationship and role with other parts can be clearly shown.
[0042] In step 2 of the present invention, there is specifically step 201, which performs model element comparison, identifies elements related to the PLC control program from the SysML model, including the system's input, output, state machine, activities, and control logic, and determines the mapping relationship between the SysML model elements and the PLC programming elements. These mapping relationships should be able to ensure that the functions and behaviors in the SysML model can be correctly mapped to the PLC control program to implement the corresponding control logic and behavior. On the basis of determining the mapping relationship, formulate corresponding mapping rules and methods to ensure the accuracy and consistency of the mapping. These rules may include how to map input and output signals to the input and output modules of the PLC, and how to map the states in the state machine to the state variables of the PLC. Figure 2 The figure shows the specific relationship between model element alignment and mapping.
[0043] In step 2 of the present invention, specifically step 202, the SysML model is analyzed to understand various aspects of the system model, including motors, buttons, and state transitions, extract information from the model, and assign the model information to the PLC configuration file, ladder diagram, and state diagram.
[0044] Specifically, by creating a custom PLC configuration file, model elements and constraints related to the PLC program are introduced, so that the PLC control logic can be accurately described by using elements related to PLC programming in the SysML model. More specifically, the elements and constraints related to PLC programming are identified, including input modules, output modules, data types, and control instructions; based on the identified PLC programming elements, a custom PLC configuration file is created; this PLC configuration file contains the hardware configuration information of the PLC, the definition of the input module, the definition of the output module, the declaration of the data type, and the description of the control instructions; the custom PLC configuration file is introduced in the SysML model and associated with the model elements; this can be achieved by adding custom extensions or tags in the SysML model to indicate the PLC configuration information corresponding to each model element.
[0045] The PLC configuration file is crucial in the PLC hardware configuration and communication settings during model conversion. First, export the XML file from the SysML model, use Python to process and extract the control logic and functional requirements to guide the development of the PLC program, define the information related to the PLC hardware in the model to match the actual PLC hardware device, and then use I / O port mapping to define the addresses and mapping relationships of the input and output devices in the PLC configuration file, and map the logical signals defined in the SysML model to the actual PLC input and output signals. Then assign the tasks and programs in the SysML model to the tasks and programs of the PLC, define the task priority and scheduling strategy information, and ensure that each function in the system is executed, such as Figure 3 shown.
[0046] Specifically, the ladder diagram extension graphically represents the logical structure and sequence of the PLC program.
[0047] The role of ladder diagram extension is to convert various elements in SysML model, such as buttons and motors, into ladder diagram logic elements, thereby generating a ladder diagram representation corresponding to the SysML model. Through ladder diagram extension, SysML model can be used to describe the behavior and control logic of the system, and the control logic can be programmed into PLC by converting SysML model into ladder diagram. As shown in Table 1, the correspondence between some common SysML activity diagram elements and LAD codes is shown:
[0048] Table 1 Mapping relationship between activity diagram modules and elements in SysML and PLC ladder diagram
[0049]
[0050]
[0051] In the process of converting SysML model to PLC control program, ladder diagram extension is used to convert activities, control flow and branch logic in activity diagram into logical elements in ladder diagram. Firstly, control logic and functional requirements are extracted from XML file exported from SysML model using Python script, and mapping rules from model elements to ladder diagram elements are defined. By defining grammatical rules of ladder diagram extension, semantics are extended to ensure that the converted PLC program can correctly execute the expected behavior in the model. Then, the elements of SysML model are traversed, elements to be converted are identified according to mapping rules, and corresponding ladder diagram extension code is generated using grammatical rules of ladder diagram extension. Activity diagram in the model is converted into logical structure of ladder diagram, and the generated code is further optimized by judging whether the control logic is satisfied (accuracy, and operation efficiency and stability can also be further considered).
[0052] The steps for ladder diagram expansion are as follows:
[0053] Step 1: Activity Mapping
[0054] 1. Activity identification: First, determine the characteristics of the activity diagram elements, including the name of the activity, input parameters, output parameters, execution order, and control flow. Then, formulate rules and templates to define these characteristics to ensure that different elements in the activity diagram can be accurately identified and matched. For each activity, define the specific operation process it represents to determine its function and semantics. Finally, write scripts or programs to match and identify activities in the activity diagram to automate this process.
[0055] 2. Activity mapping: Design a corresponding ladder logic block for each activity, associate each activity with the corresponding ladder logic block, and realize the automatic conversion from activity diagram to ladder logic block. When designing a corresponding ladder logic block for each activity, select the appropriate ladder elements according to the nature and function of the activity.
[0056] Specifically, the following are some common activity properties and corresponding ladder diagram elements:
[0057] Start / End Activity: corresponds to the start node and end node in the activity diagram. It is represented by the start / stop button element in the ladder diagram.
[0058] Basic operation activities: represent basic operations or actions, such as sensor reading and performing a task. They are represented by solenoid valves, relays, and timer elements in ladder diagrams.
[0059] Judgment / conditional activities: Activities that contain conditional judgments and execute different logical branches based on the conditions. Comparison elements (such as comparison instructions) and branch instruction elements (such as branch jump and conditional jump instructions) are used in ladder diagrams to implement conditional judgments and branches.
[0060] Loop activity: An activity that contains a loop structure, which repeatedly performs a task until a condition is met. In ladder diagrams, loop instruction elements (such as loop jump and count loop instructions) can be used to represent loop structures.
[0061] Parallel activities: Activities that perform multiple operations simultaneously. Use parallel instruction elements or parallel controller elements to represent the logic of parallel execution.
[0062] Exception handling activities: Activities that handle exceptional situations or errors, using exception handling instruction elements and interrupt instruction elements to implement exception handling logic.
[0063] State transition activity: An activity that performs state transition according to the system state. State transition logic instruction elements are used to represent state switching and transition conditions.
[0064] Step 2: Control Flow Mapping
[0065] 1. Sequential control: According to the control flow in the activity diagram, the sequential activities are mapped to the sequential execution in the ladder diagram by connecting the logic blocks.
[0066] 2. Branches and merges: Map the branches (decision points) and merges in the activity diagram to conditional judgments and connections in the ladder diagram, and use relays and contacts in the PLC programming software to implement different paths.
[0067] Step 3: Control logic mapping
[0068] 1. Branch logic mapping: Map the branch logic in the activity diagram, such as IF-ELSE conditions, to the conditional blocks in the ladder diagram, and use relays and contacts to implement conditional judgment.
[0069] 2. Loop logic mapping: If the activity diagram contains loops, map them to loop blocks in the ladder diagram and use the timers and counters in the PLC programming software to implement different types of loops.
[0070] Step 4: Input-output mapping
[0071] 1. Input mapping: Map the inputs in the activity diagram to input signals in the ladder diagram, such as buttons and sensors.
[0072] 2. Output mapping: Map the outputs in the activity diagram to the output signals in the ladder diagram, such as motors and displays.
[0073] Step 5: Generate ladder diagram
[0074] Based on the above mapping and rules, a ladder diagram is gradually generated, which contains the activities, control logic and input-output mapping extracted from the activity diagram. The ladder diagram can be implemented using the logic elements (such as relays, contacts, timers) provided in the PLC programming software, such as Figure 4 shown.
[0075] Specifically, the state diagram in SysML is converted into a structured text representation in the PLC programming language, so that the state transitions and behaviors defined in SysML can be directly converted into PLC control logic. The text label of each state node is extracted through a custom script, and the text information of each state is integrated into a text block that records the name, description, and possible triggering events of the structured state using a predefined text template.
[0076] Steps to expand state diagram to structured text:
[0077] Step 1: State transition condition mapping
[0078] 1. State mapping: Determine the structured text block corresponding to each state in the state diagram.
[0079] 2. State transition mapping: For each state transition, map it to the corresponding conditional judgment and control flow statements according to the conditions defined in the state diagram. For example, if a state transition requires a certain condition to be met, the condition can be mapped to an if statement or a similar conditional structure.
[0080] 3. Determine the trigger conditions: Determine the trigger conditions that need to be met when the state transition occurs. These conditions include external input signals, system internal states, and time conditions.
[0081] 4. Define control logic: Based on the conditions and trigger conditions of state transition, determine the operations or actions that need to be performed when the state transition occurs. These operations include updating state variables, sending output signals, and executing specific functions.
[0082] 5. Write structured text code: According to the above mapping and rules, write structured text code to convert states, state transition conditions and control logic into actual code form.
[0083] Step 2: State-Action Mapping
[0084] 1. State entry action mapping: Map the states with entry actions in the state diagram to the operations in the structured text when the state is entered. Determine the entry action of each state, that is, the operation that needs to be performed when the state is entered. These operations are associated with the initialization or preparation of the state, including initializing variables, setting state flags, and sending signals.
[0085] 2. State exit action mapping: Map the states with exit actions in the state machine diagram to the operations when the state exits in the structured text. Determine the exit action of each state, that is, the operations or cleanup tasks that need to be performed when the state exits. These operations are associated with the end or switch of the state, including saving state information, cleaning up resources, and sending end signals.
[0086] 3. Write structured text code: According to the mapping rules of state entry and exit actions, write structured text code to convert the state entry and exit actions into actual code form. When writing code, ensure that the execution order and conditions of the actions meet the system requirements and specifications.
[0087] Step 3: Generate structured text
[0088] The structured text code (ST code) generated step by step based on the above mapping and rules is integrated to obtain a structured text, which contains the mapping of states, state transitions, control logic and button operations extracted from the SysML state diagram. When generating the ST code, the syntax and operators provided by the PLC programming software are used.
[0089] In step 3 of the present invention, the input and output signals are allocated by integrating the PLC configuration file, ladder diagram expansion, state diagram into the control logic generated by structured text to ensure the logical consistency and normal interaction between them. The PLC control program automatically converted after integration is loaded into the actual PLC device. Optimization is performed based on the test results to ensure the reliability and performance of the system, such as Figure 5 shown.
[0090] The present invention combines the advantages of system modeling and automated control, and can improve the efficiency of system development and the correctness of control logic. By defining state transition rules, event trigger conditions and action execution strategies, determining the mode and priority of generating control logic, and selecting conversion strategies, it is ensured that the generated PLC code meets the specifications and performance requirements, and improves the reusability of low-level components. Model conversion can first analyze the previously generated code and appropriately merge the newly added code. Its goal is to promote modular object-oriented programming of PLC software by improving the type relationship between structure diagrams and behavior diagrams and by reducing the abstraction level in the structure model.
[0091] Example 1:
[0092] Take a handling robot as a verification example. The main responsibility of the robot is to grab the processed workpiece from the conveyor belt and transport it to the designated location for subsequent assembly. The robot control system consists of multiple components, including the robot support, upper arm, lower arm, motor, mechanical claw and control buttons, such as Figure 6 As shown in Figure 1. In order to realize the various functions of the robot, the entire system is managed by a controller called "gripper control application". The controller includes five sub-controllers, namely the mechanical claw controller, the upper arm controller, the lower arm controller, the motor controller and the button controller. These software components are modeled using function blocks to realize various control tasks of the system, such as Figure 7 These components are instantiated and integrated into the entire system, including the extension and retraction functions of the upper and lower arms, the grasping and releasing functions of the mechanical claws, the motor used to drive the mechanical arm to rotate, and the start, pause and stop operation functions of the entire system, as shown in Figure 8 As shown in the figure, the workpiece is transported from the completed processing station to the unfinished installation station. The operation process of the robot system is highly coordinated, ensuring the smooth operation of the production line.
[0093] Converting the SysML model of the handling robot into a PLC (Programmable Logic Controller) control program requires a series of steps. The overall framework for automatically generating a control program includes a custom model conversion system. By developing a custom model conversion system, the XML file generated by the SysML modeling tool is imported and parsed to extract model information. The SysML model elements of the handling robot are automatically assigned to the PLC configuration file, ladder diagram extension, and state diagram to structured text extension according to predetermined rules, where the relevant elements are assigned to the PLC configuration file based on the type and attributes of the elements in the model. For example, sensors are mapped to inputs, and motors and mechanical claws are mapped to outputs. Create a ladder diagram extension based on the element relationship in the model. If a sensor state change triggers the operation of the motor, then create logic in the ladder diagram accordingly. Based on the states defined in the model and the transition relationships between states, the code for the state diagram and structured text extension is automatically generated, including the definition of states, conditional transitions between states, and event triggering. See the flowchart for converting the SysML model of the handling robot into a PLC control program. Fig. 9 , Fig. 9 First, the actual use case of the handling robot is generated (through the SysML model in Cameo Systems Modeler Demo), and the use case is exported as an XML file type. The generated use case file information is organically integrated into the PLC programming environment, and the appropriate control logic is generated accordingly. The generated PLC program can be loaded into the PLC virtual simulator (PLC virtual simulation software) through TIA Portal for testing.
[0094] The above description is only part of the specific implementation of the present invention, and the present invention is not limited thereto. The protection scope of the present invention should cover any changes or substitutions that can be easily thought of by anyone familiar with the art, as long as these changes or substitutions fall within the technical scope disclosed by the present invention, they should be regarded as within the protection scope of the present invention.
Claims
1. A method for automatically generating PLC control code based on SysML model, characterized in that: The following steps are involved: Step 1: Based on the various model elements provided in the SysML model, select the system component model and system process model in the SysML model to express the structure and manufacturing process of the manufacturing system; Step 2: Analyze the essential correspondence between the SysML model and the PLC system, introduce PLC system programming elements and associations, establish the mapping relationship between SysML model elements and PLC system programming elements, create a PLC configuration file, and perform ladder diagram expansion and state diagram to structured text expansion; Step 3: Automatically convert the SysML model to the actual PLC code; Step 4: Taking operation efficiency, stability and accuracy as optimization indicators, optimize the PLC control logic generated by integrating PLC configuration files, ladder diagram extensions and state diagrams into structured text extensions.
2. The method for automatically generating PLC control code based on SysML model according to claim 1, characterized in that: The step 1 comprises the following steps: Step 1: Generate use cases from requirements and represent and describe use cases through blocks in the system process model; Step 2: Analyze the system process model, identify various functions and operations, use Python programming technology to find out the components of the manufacturing system, and define the functions and interfaces of each component according to the corresponding functions identified by the system process model, so as to construct a system component model; wherein the components include physical components, software components and logical components, and the interfaces include input modules, output modules and method modules; determine the component boundaries, divide the manufacturing system into independent components, and define the relationships between the components; Step 3: Assign operations in the system process model to each component; the system process model captures the dynamic behavior of the manufacturing system and transmits signals between the operations of each component through control flow to build an execution sequence of operations; Step 4: Taking operational efficiency, stability and accuracy as optimization indicators, adjust the functions and interfaces of each component and optimize the system component model.
3. The method for automatically generating PLC control code based on SysML model according to claim 1, characterized in that: The step 2 comprises the following steps: Step 1: Analyze the specific structure of the SysML model and the PLC system, identify the model elements related to the PLC control program from the SysML model, including input, output, state machine, activity, and control logic, and determine the mapping relationship between the model elements of the SysML model and the programming elements of the PLC system; Step 2: Create a custom PLC configuration file, introduce the model elements and constraints of the SysML model related to the PLC control program, use the model elements related to the PLC control program in the SysML model to describe the PLC control logic, and use the operation accuracy as the optimization index to adjust the mapping relationship and optimize the PLC control logic; Step 3: Through ladder diagram expansion, the SysML model describing the behavior and control logic of the manufacturing system is converted into a ladder diagram to realize programming of the control logic into the PLC system; Step 4: Taking operation efficiency, stability and accuracy as optimization indicators, adjust the mapping relationship, PLC configuration and ladder diagram, and optimize the PLC control logic generated by ladder diagram expansion; Step 5: Use the Statechart to Structured Text extension to convert the statechart in the SysML model into a structured text representation in the PLC system, so that the state transitions and behaviors defined in the SysML model are directly converted into PLC control logic.
4. The method for automatically generating PLC control code based on SysML model according to claim 1, characterized in that: The step three comprises the following steps: Step 1: Integrate PLC configuration files, ladder diagram extensions, and state diagrams into the PLC control logic generated by structured text extensions to ensure logical consistency and normal interaction between PLC control logics; Step 2: Load the automatically generated PLC control program after integration into the actual PLC device.
5. The method for automatically generating PLC control code based on SysML model according to claim 4, characterized in that: The automatically generated PLC control program after integration is first loaded into the PLC virtual simulator through TIA Portal for testing, and then loaded into the actual PLC device when the test meets the control logic.
Citation Information
Cited By
Sequence control chart configuration editing and layout method and device, medium and equipment
CN119847060A
Multi-target conflict coordination method for model mapping configuration optimization
CN121072725A
