LLM-based industrial control programming ladder diagram generation method
Through a large language model based on LLM, a graphical and componentized PLC programming ladder diagram is generated, which solves the problems of poor readability and difficulty in importing in the existing technology, and realizes efficient and accurate ladder diagram programming, which lowers the technical threshold for engineers.
Patent Information
- Application Number
- CN202510970353.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-08-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult for the existing technology to efficiently generate highly readable graphical component PLC programming ladder diagrams, and engineers need a long time to learn and master the ladder diagram programming method. The existing large-model system can only generate ladder diagrams in text form and cannot be directly imported into the industrial control programming platform.
The large language model based on LLM is used to receive natural language programming requirements, generate ladder diagrams in the form of text diagrams, and generate XML files through pre-training bases, convert them into JSON files, and finally use GOJS graphics components for parsing to generate graphic componentized target programming ladder diagrams.
It improves the generation rate and accuracy of graphical component programming ladder diagrams, reduces the technical threshold for ladder diagram programming, and the generated programming ladder diagrams are highly readable. XML and JSON files can be directly imported into the industrial control programming platform for compilation and debugging.
Smart Images

Figure CN120469680A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an LLM-based industrial control programming ladder diagram generation method, belonging to the technical field of programming. Background Art
[0002] A Programmable Logic Controller (PLC) is a digital computing electronic system designed for automated control in industrial environments. It uses programmable memory to store and execute instructions for logic operations, sequential control, timing, counting, and arithmetic calculations, and controls various types of machinery or production processes through digital or analog input / output interfaces. In industrial control systems (industrial automation control systems), the PLC is the core control unit, responsible for key tasks such as signal processing, logic control, and data exchange, and its role runs throughout the entire industrial production process.
[0003] The industrial control programming platform is the core software hub of industrial automation control systems, responsible for the entire process from program design to system operation and maintenance. Functionally, it supports multiple programming languages compliant with the IEC 61131-3 standard, encompassing both graphical (such as ladder diagrams and function block diagrams) and textual (such as structured text) programming methods to meet the needs of diverse scenarios. It also provides hardware configuration capabilities, enabling parameter settings for PLC I / O modules and communication protocols, and supports offline simulation debugging, verifying program logic through virtual operation.
[0004] Industrial control programming platforms bridge the gap between engineers and PLCs, converting abstract control logic into executable code for the PLC, ultimately enabling automated operation of industrial equipment. The programming languages used in industrial control platforms are core tools for industrial automation control and primarily include the following: Structured Text (ST): A high-level text language based on Pascal syntax, suitable for implementing complex mathematical operations and algorithms, with a clear code structure. Ladder Diagram (LD): A graphical language modeled after relay circuits, using contacts, coils, and wires to represent logical relationships. It is intuitive and easy to understand, making it suitable for logic control scenarios. Function Block Diagram (FBD): A control system is constructed using functional modules (such as adders and timers) and connecting wires, similar to electronic circuit design, facilitating the depiction of data flows. Sequential Function Chart (SFC): A state transition diagram depicts process flows, implementing sequential control through "steps" and "transitions," such as process switching on an automated production line. Instruction List (IL): A low-level text language similar to assembly language, with compact instructions, suitable for optimizing critical code sections.
[0005] Among the five programming languages used in industrial control programming platforms, ladder diagram (LD) is the most classic programming language in the industrial control field. Its syntax and symbology are directly borrowed from relay circuit diagrams in traditional electrical control systems, making it highly intuitive and practical for engineering. Its symbols and structure represent logical relationships using graphical elements such as "contacts" (normally open / normally closed), "coils," and "function blocks." These are connected by horizontal wires to form "runners." Each rung begins on the left, connected to the output elements (such as coils or function blocks) on the right. This ladder-like shape, hence the name, "ladder diagram." Logic is expressed in a top-to-bottom, left-to-right order, implementing logical operations (such as AND, OR, and NOT) through series and parallel combinations of contacts. This makes it suitable for describing on-off control scenarios (such as motor start / stop and valve interlocking).
[0006] When engineers use ladder diagrams for PLC programming, they need to have a good technical foundation. On the one hand, they need to understand the principles of electrical control, such as being familiar with the working principles of electrical components such as relays, contactors, sensors (such as PNP / NPN), and understanding the working logic of relay circuits (such as normally open / normally closed contacts, coil energization / de-energization); on the other hand, they need to have logical thinking ability, be able to read electrical schematics, master the correspondence between basic electrical symbols (such as contactor KM, thermal relay FR) and ladder diagram symbols, and be able to convert them into ladder diagram logic (such as self-locking and interlocking circuits). They must also have technical logic ability, be proficient in using Boolean algebra (AND, OR, NOT) to design control logic, and be able to break down complex control requirements into multiple independent logic modules.
[0007] Furthermore, when control logic includes multiple layers of nested logic (such as complex conditionals or loops), ladder diagrams can become lengthy and difficult to follow. For example, when implementing PID algorithms or matrix operations, ladder diagram wiring can become convoluted and far less clear than structured text (ST). In large projects, excessive ladder diagram branching can make troubleshooting difficult, especially when multiple coils affect the same output. Multiple layers of conditionals or loops can lead to complex wiring and reduced readability.
[0008] Therefore, programming PLCs using ladder diagrams is a relatively complex and challenging task. Engineers generally need to spend a long time learning to master ladder diagram programming methods. The typical large-scale model systems currently on the market also have difficulty directly implementing automatic ladder diagram programming. They can only generate ladder diagrams in the form of text diagrams. This form of ladder diagram is not very readable because the components therein differ greatly in shape from the actual ladder diagram. In addition, this type of ladder diagram cannot be directly imported into the industrial control programming platform and can only serve as a reference for engineers. If the ladder diagram needs to be compiled and debugged on the industrial control programming platform, the engineer needs to refer to the drawing and copy it exactly on the industrial control programming platform. Therefore, using large models to program ladder diagrams does not truly reduce the complex work of engineers. Summary of the Invention
[0009] The technical problem to be solved by the present invention is to provide an industrial control programming ladder diagram generation method based on LLM, which can perform natural language processing with a large language model and efficiently and automatically generate a target programming ladder diagram with graphical components.
[0010] In order to solve the above technical problems, the present invention adopts the following technical solutions: The present invention designs an industrial control programming ladder diagram generation method based on LLM, which receives the target programming requirements of natural language with a large language model for processing, obtains the corresponding target JSON file, and cooperates with the GOJS graphic component to parse the target JSON file to generate a graphic componentized target programming ladder diagram.
[0011] As a preferred technical solution of the present invention, the following steps are included: generating a target programming ladder diagram of graphic components; Step A. Apply the first language model to receive the target programming requirements in natural language input, generate a ladder diagram in the form of a text graph, and proceed to Step B; Step B. Applying a pre-trained base for generating XML files compliant with PLCOpen XML Formats to generate a large language model, receiving the ladder diagram in the form of a text graph for processing, and generating a corresponding target XML file compliant with PLCOpen XML Formats, and then proceeding to Step C; Step C. Based on the RAG of the conversion rules between the preset XML file and the target JSON file, the base generates a large language model to receive the target XML file for conversion and outputs the corresponding target JSON file, and then proceeds to step D; Step D. Based on the target JSON file, update the graphic components in the industrial control programming platform, encapsulate and obtain the GOJS graphic components, parse the target JSON file, and generate a target programming ladder diagram with graphic components.
[0012] As a preferred technical solution of the present invention: if it is necessary to modify the target programming ladder diagram of the graphic componentization, then compare the target programming ladder diagram of the graphic componentization generated in step D, according to step A, apply the large language model, receive the modification suggestions in natural language, generate a ladder diagram in the form of a new text graph, and enter step B; then, according to steps B to step D, in sequence, generate a new target programming ladder diagram of the graphic componentization through the new target XML file and the new target JSON file, thereby realizing the modification of the target programming ladder diagram of the graphic componentization.
[0013] As a preferred technical solution of the present invention: the ladder diagram in the form of a text graph generated in step A includes various text form elements and the connection relationship between various text form elements; the target XML file generated in step B includes various XML elements and the connection structure between various XML elements; The RAG in step C includes component conversion rules and inter-component connection conversion rules between the preset XML file and the target JSON file. The generated target JSON file includes each JSON component and the connection structure between each JSON component. The target programming ladder diagram of the graphic componentization generated in step D includes each graphic componentization element and the connection structure between each graphic componentization element.
[0014] As a preferred technical solution of the present invention: based on the target programming ladder diagram of the graphical component generated in step D, the method further includes compiling and executing the following steps; Step i. Processing the target programming ladder diagram of the graphical component to obtain the corresponding target JSON file, and then based on the preset XML file and the conversion rules between the target JSON file under the target requirements RAG, the base generates a large language model to receive the target JSON file for conversion, and outputs the corresponding target XML file, and then proceeds to step ii; Step ii. Use the compilation and debugging module in the industrial control programming platform to process the target XML file. Obtain the corresponding target programming language project from the corresponding structured ST project text. Finally, use the GNU compiler to compile the target programming language project to obtain the target binary program for running on the PLC. This program is then sent to the PLC device for execution.
[0015] As a preferred technical solution of the present invention: in the step ii, the compilation and debugging module in the industrial control programming platform is used to process the target XML file, and the corresponding C language project is obtained through the corresponding structured ST project text. Finally, the GNU compiler is used to compile the C language project to obtain a binary program for running on the PLC, which constitutes the target binary program.
[0016] As a preferred technical solution of the present invention: based on a preset number of XML files corresponding to text graphical ladder diagrams, the XML files are input into the large language model for training, and the base for generating the XML file that complies with PLCOpen XML Formats in step B is obtained to generate the large language model.
[0017] The LLM-based industrial control programming ladder diagram generation method described in the present invention has the following technical effects compared with the prior art by using the above technical solution: The present invention designs a method for generating industrial control programming ladder diagrams based on LLM. The method is based on the fact that a large language model processes natural language target programming requirements to generate a ladder diagram in the form of a text diagram. A pre-trained base is used to generate a large language model, a corresponding target XML file is generated, and then converted into a corresponding target JSON file. Finally, GOJS graphic components are used for parsing to generate a graphic componentized target programming ladder diagram. Compared with the existing technology, the method greatly improves the generation rate and accuracy of the graphic componentized programming ladder diagram, and uses natural language as input, which reduces the technical threshold and difficulty of ladder diagram programming. Moreover, the generated programming ladder diagram has strong readability, and the corresponding XML file and JSON file can be directly imported into the industrial control programming platform for compilation and debugging. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of the architecture of the present invention under design and implementation; Figure 2 It is a schematic diagram of a ladder diagram for generating graphic componentized target programming under the design and implementation of the present invention. DETAILED DESCRIPTION
[0019] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0020] The present invention designs a method for generating industrial control programming ladder diagrams based on LLM, which receives target programming requirements in natural language with a large language model for processing, obtains the corresponding target JSON file, and parses the target JSON file with the help of GOJS graphic components to generate a target programming ladder diagram with graphic components.
[0021] In view of the above design ideas, in actual application, such as Figure 1 As shown, the specific design executes the following steps A to B to generate a graphical componentized target programming ladder diagram.
[0022] Step A. Apply the first language model to receive the target programming requirements inputted in natural language, generate a ladder diagram in the form of a text graph, and proceed to step B, wherein the ladder diagram in the form of a text graph specifically includes various text-form elements and the connection relationships between the various text-form elements.
[0023] Next, we design and obtain the target XML file corresponding to the text-graphic ladder diagram. The target XML file includes each XML element and the connection structure between each XML element. To do this, we need to input the XML files corresponding to a preset number of text-graphic ladder diagrams into a large language model for training. This will provide the basis for generating XML files that comply with PLCOpen XML Formats.
[0024] In actual application, regarding the target XML file, the structure of the "left power rail" XML element is as follows: <leftpowerrail height="810" width="3" localid="1"> <position y="0" x="30" / > - <connectionpointout formalparameter=""> <relposition y="70" x="0" / > < / connectionpointout> - <connectionpointout formalparameter=""> <relposition y="250" x="0" / > < / connectionpointout> - <connectionpointout formalparameter=""> <relposition y="510" x="0" / > < / connectionpointout> - <connectionpointout formalparameter=""> <relposition y="740" x="0" / > < / connectionpointout> < / leftpowerrail> The structure of the "touchpoint" XML element is as follows: <contact height="20" width="22" localid="3" negated="false"> <position y="60" x="210" / > - <connectionpointin> <relposition y="10" x="0" / > <connection reflocalid="1"> <position y="70" x="210" / > <position y="70" x="192" / > <position y="70" x="121" / > <position y="70" x="121" / > <position y="70" x="51" / > <position y="70" x="33" / > < / connection> < / connectionpointin> - <connectionpointout> <relposition y="10" x="22" / > < / connectionpointout> <variable> start0< / variable> The structure of the "Timer Function Block" XML element is as follows: <block height="60" width="100" localld="4" instancename="TON1" typename="TON"> <position y="40" x="510" / > - <inputvariables> - <variable formalparameter="IN"> - <connectionpointin> <relposition y="30x=" 0" / > - <connection reflocalid="5"> <position y="70" x="510" / > <position y="70" x="492" / > <position y="70" x="426" / > <position y="70" x="426" / > <position y="70" x="360" / > <position y="70" x="342" / > < / connection> < / connectionpointin> < / variable> - <variable formalparameter="PT"> -connectionPointIn> <relposition y="50" x="0" / > - <connection reflocalid="6"> <position y="90" x="510" / > <position y="90" x="492" / > <position y="90" x="480" / > <position y="100" x="480" / > <position y="100" x="468" / > <position y="100" x="450" / > < / connection> < / variable> < / inputvariables> <inoutvariables / > - <outputvariables> <variable formalparameter="Q"> - <connectionpointout> <relposition y="30" x="100" / > < / connectionpointout> < / variable> - <variable formalparameter="ET"> - <connectionpointout> <relposition y="50" x="100" / > < / connectionpointout> < / variable> < / outputvariables> < / block> The structure of the "addition function block" XML element is as follows: <block height="80" width="100" localid="10" typename="ADD"> <position y="180" x="380" / > - <inputvariables> <variable formalparameter="EN"> - <connectionpointin> <relposition y="30" x="0" / > - <connection reflocalid="9"> <position y="210" x="380" / > <position y="210" x="362 / ><position y=" 210"x="301" / > <position y="210" x="301" / > <position y="210" x="240" / > <position y="210" x="222" / > < / connection> < / connectionpointin> < / variable> - <variable formalparameter="IN1"> <connectionpointin> <relposition y="50" x="0" / > - <connection reflocalid="11"> <position y="230" x="380" / > <position y="230" x="362" / > <position y="230" x="362" / > <position y="230" x="368" / > <position y="230" x="368" / > <position y="230" x="350" / > < / connection> < / connectionpointin> < / variable> - <variable formalparameter="IN2"> - <connectionpointin> <relposition y="70" x="0" / > - <connection reflocalid="12"> <position y="250" x="380" / > <position y="250" x="362" / > <position y="250" x="362" / > <position y="250" x="368" / > <position y="250" x="368" / > <position y="250" x="350" / > < / connection> < / connectionpointin> < / variable> < / inputvariables> <inoutvariables / > - <outputvariables> - <variable formalparameter="ENO"> - <connectionpointout> <relposition y="30" x="100 / >< / connectionPointout>< / variable>-<variable formalParameter=" out"> - <connectionpointout> <relposition y="50" x="100" / > < / connectionpointout> < / relposition> < / connectionpointout> < / variable> < / outputvariables> < / block> The structure of the "input variable" XML element is as follows: <coil height="20" vidth="22" localid="7" negated="false"> <position y="60" x="720" / > - <connectionpointin> <relposition y="10" x="0" / > - <connection formalparameter="Q" reflocalld="4"> <position y="70" x="720" / > <position y="70" x="702" / > <position y="70" x="665" / > <position y="70" x="665" / > <position y="70" x="628" / > <position y="70" x="610" / > < / connection> < / connectionpointin> - <connectionpointout> <relposition y="10" x="22 / >< / connectionPointOut><variable>ton0q< / variable> The structure of the "output variable" XML element is as follows:<outVariable height=" 20"width="80" localid="13" negated="false"> <position y="220" x="550" / > - <connectionpointin> <relposition y="10" x="0" / > - <connection formalparameter="OUT" reflocalid="10"> <position y="230" x="550" / > <position y="230" x="532" / > <position y="230" x="515" / > <position y="230" x="515" / > <position y="230" x="498" / > <position y="230" x="480" / > < / connection> < / connectionpointin> <expression> num1< / expression> The structure of the "coil" XML element is as follows: <coil height="20" width="22" localid="7" negated="false"> <position y="60" x="720" / > - <connectionpointin> <relposition y="10" x="0" / > - <connection formalparameter="Q" reflocalld="4"> <position y="70" x="720 / ><position y=" 70"x="702" / > <position y="70" x="665" / > <position y="70" x="665" / > <position y="70" x="628" / > <position y="70" x="610" / > < / connection> < / connectionpointin> - <connectionpointout> <relposition y="10" x="22 / >< / connectionPointOut><variable>ton0q< / variable>< / coil> The structure of the "Right Power Rail" XML element is as follows:<rightPowerRail height=" 810"width="3" localid="35"> <position y="0" x="1297" / > - <connectionpointin> <relposition y="70" x="0" / > + <connection reflocalid="7"> < / connection> < / connectionpointin> - <connectionpointin> <relposition y="250" x="0" / > + <connection reflocalid="7"> < / connection> < / connectionpointin> - <connectionpointin> <relposition y="510" x="0" / > - <connection reflocalid="7"> <position y="70" x="1327" / > <position y="70" x="1309" / > <position y="70" x="1034" / > <position y="70" x="1034" / > <position y="70" x="760" / > <position y="70" x="742" / > < / connection> < / connectionpointin> - <connectionpointin> <relposition y="740" x="0" / > - <connection reflocalid="7"> <position y="70" x="1327" / > <position y="70" x="1309" / > <position y="70" x="1034" / > <position y="70" x="1034" / > <position y="70" x="760" / > <position y="70" x="742" / > < / connection> < / connectionpointin> In actual applications, regarding the target XML file, the connection structure between each XML element is as follows: first, each XML element is defined with an ID, which is the localId. The localId in a ladder diagram is randomly assigned and unique. Second, each XML element is defined with the connection points from the left and the connection points from the right, as well as the element on the left to which it is connected. An example is shown below.
[0025] <contact height="20" width="22" locaid="3" negated="false"> <position y="60" x="210" / > - <connectionpointin> <relposition y="10" x="0" / > - <connection reflocalid="1"> <position y="70" x="210" / > <position y="70" x="192" / > <position y="70" x="121" / > <position y="70" x="121" / > <position y="70" x="51" / > <position y="70" x="33" / > < / connection> < / connectionpointin> - <connectionpointout> <relposition y="10" x="22" / > < / connectionpointout> <variable> start0< / variable> For example, the "contact" XML element has an ID of 3; <connectionpointin>The structure represents the situation of connecting from the left. The position coordinates of the left connection point are <relposition>middle, <connection>The structure represents the connection with the component with ID 1. The connection line is made by <position>The structure is composed of broken lines between several points; <connectionpointout>The structure represents the situation of connecting from the right. The position coordinates of the right connection point are <relposition>In actual applications, in order to avoid duplication, all XML elements only need to clearly describe the situation of connecting from the left, without describing which XML element to connect to on the right.
[0026] The XML file data corresponding to the above-mentioned type of text graphical ladder diagram can be input into the large language model for training, and the base for generating the XML file that complies with PLCOpen XML Formats is obtained to generate the large language model, and then the following step B is performed.
[0027] Step B. The application base generates a large language model, receives the ladder diagram in text form for processing, and generates a corresponding target XML file that complies with PLCOpen XML Formats. Then, the process proceeds to step C, where the target XML file specifically includes each XML element and the connection structure between each XML element.
[0028] Step C. Based on the RAG of conversion rules between the preset XML file and the target JSON file, the base generates a large language model to receive the target XML file for conversion and output the corresponding target JSON file, and then enters step D. Based on the RAG including the component conversion rules and the connection conversion rules between the preset XML file and the target JSON file, the generated target JSON file includes each JSON component and the connection structure between each JSON component.
[0029] In actual applications, each data item in the component conversion rule in RAG consists of three parts: component name, component XML structure content, and component JSON format content. An example of the component "contact" is shown below.
[0030] Component name: contact or contact; The component XML structure content is as shown in the example above; Component JSON format: { "category":"contact", "tagHame":"contact", "name":"contact point", "id":"3", "width":22, "height":20, "negated":false, "editable":true, "position":[210,60], "connectionPointIn":{ "name":"IN","position":[0,10],"type":"BOOL" }, "group":"1", "connectionPointOut":{ "name":"OUT",|"position":[22,10],"type":"BOOL" }, } The following is an example of a "Timer Function Block" component.
[0031] Component name: timer function block or TON block; The component XML structure content is as shown in the example above; Component JSON format: { "category": "block", tagName":"block", "typeName":"TON", "instanceName":"TON1", "editable":false, "description":"Connection delay", "id": "id=TON", width":100, "height":60, "position":[510,40], "inputVariables":[ { "name":"IN", "position":[0,30], "type":"BOOL" }, { "name":"PT", "position":[0,50], "type":"TIME" }, ], "group":"id=wangge1", "outputVariables":[ { "name":"Q", "position":[100,30], "type":"BOOL" }, { "name":"ET", "position":[100,50], "type":"TIME" }, ], }, In actual applications, each data item in the component connection conversion rule in RAG consists of two parts: the connection XML structure content and the connection JSON format content. An example is shown below.
[0032] Connection XML format: <contact height="20" width="22" locaid="3" negated="false"> <position y="60" x="210" / > - <connectionpointin> <relposition y="10" x="0" / > - <connection reflocalid="1"> <position y="70" x="210" / > <position y="70" x="192" / > <position y="70" x="121" / > <position y="70" x="121" / > <position y="70" x="51" / > <position y="70" x="33" / > < / connection> < / connectionpointin> - <connectionpointout> <relposition y="10" x="22" / > < / connectionpointout> <variable> start0< / variable> Connection JSON format: { "fromPort":"OUT", "toPort": "IN", "from":1, "to":"3", "points":[ [210,70],[192,70],[121,70],[121,70],[51,70],[33,70] ] } In the process of converting the target XML file according to RAG by the large language model generated by the base, the target XML file is first parsed one by one from the beginning to the end.
[0033] 1) Extract the structure of each XML component and search for RAG based on the component name; 2) According to the component conversion rules between the XML file in RAG and the JSON file under the target requirements, the extracted XML component structure content is converted into JSON format content; 3) In component XML <connectionpointin>The structure indicates the situation where it is connected from the left, and searches for RAG; 4) According to the inter-component connection conversion rules between the XML file in RAG and the JSON file under the target requirement, the XML file <connectionpointin>The structure content is converted into the JSON content of the component connection; 5) After all the content in the XML file is converted, place all JSON components under the "nodeDataArray" structure and all the connection structures between JSON components under the "linkDataArray" structure to form a JSON file.
[0034] Step D. Update the graphic component in the industrial control programming platform based on the target JSON file and encapsulate it to obtain the GOJS graphic component. The GOJS graphic component is a graphical front-end component that can quickly generate various graphics. It also supports icon replacement and provides a variety of flexible ways to customize icons in nodes.
[0035] GOJS graphic components are used to parse the target JSON file and generate a graphic-componented target programming ladder diagram, that is, a target programming ladder diagram that includes each graphic-componented component and the connection structure between each graphic-componented component. Since the icons come from the industrial control programming platform, the components in the generated target programming ladder diagram are consistent with the industrial control programming platform, which is convenient for engineers to identify and understand.
[0036] Regarding the target programming ladder diagram obtained by the above-mentioned design based on the large language model processing, in actual applications, if the graphic componentized target programming ladder diagram needs to be modified, then the graphic componentized target programming ladder diagram generated in step D is compared, and according to step A, the large language model is applied to receive the modification suggestions in natural language, generate a ladder diagram in the form of a new text graph, and enter step B; then, according to steps B to step D, a new graphic componentized target programming ladder diagram is generated through the new target XML file and the new target JSON file, thereby realizing the modification of the graphic componentized target programming ladder diagram.
[0037] Corresponding to the above-mentioned generation of the target programming ladder diagram, the present invention designs a corresponding compilation and execution method to perform the following steps i to ii.
[0038] Step i. Process the target programming ladder diagram of the graphical componentization to obtain the corresponding target JSON file. Then, based on the RAG of the conversion rules between the preset XML file and the JSON file under the target requirements, the base generates a large language model to receive the target JSON file for conversion and output the corresponding target XML file, and then proceeds to step ii.
[0039] Step ii. Use the compilation and debugging module in the industrial control programming platform to process the target XML file. Obtain the corresponding target programming language project, such as a C language project, from the corresponding structured ST project text. Finally, use the GNU compiler to compile the target programming language project to obtain the target binary program for running on the PLC, such as a binary program, and send it to the PLC device for execution.
[0040] Regarding the above-mentioned LLM-based industrial control programming ladder diagram generation method, in actual application, a universal input and output interface is designed and developed accordingly, and integrated with the base generation large model and GOJS graphic components through the interface, and the design method of the present invention is implemented to realize the automatic generation of ladder diagrams through natural language, such as Figure 2 shown.
[0041] If you need to put the ladder diagram into the industrial control programming platform for compilation and debugging, you can call the output interface of the large model generated by the base, obtain the target XML file in the process of generating the graphic componentized target programming ladder diagram, and import it into the industrial control programming platform.
[0042] The present invention designs a method for generating industrial control programming ladder diagrams based on LLM. The method is based on the fact that a large language model processes natural language target programming requirements to generate a ladder diagram in the form of a text diagram. A pre-trained base is used to generate a large language model, a corresponding target XML file is generated, and then converted into a corresponding target JSON file. Finally, GOJS graphic components are used for parsing to generate a graphic componentized target programming ladder diagram. Compared with the existing technology, the method greatly improves the generation rate and accuracy of the graphic componentized programming ladder diagram, and uses natural language as input, which reduces the technical threshold and difficulty of ladder diagram programming. Moreover, the generated programming ladder diagram has strong readability, and the corresponding XML file and JSON file can be directly imported into the industrial control programming platform for compilation and debugging.
[0043] The embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the scope of knowledge possessed by ordinary technicians in this field without departing from the spirit of the present invention.< / connectionpointin> < / connectionpointin> < / contact> < / relposition> < / connectionpointout> < / position> < / connection> < / relposition> < / connectionpointin> < / contact> < / relposition> < / connectionpointout> < / coil> < / relposition> < / connectionpointout> < / coil> < / contact>
Claims
1. A method for generating an industrial control programming ladder diagram based on LLM, characterized by: The target programming requirements in natural language are received and processed by a large language model to obtain the corresponding target JSON file. The target JSON file is parsed with the GOJS graphic component to generate a graphic componentized target programming ladder diagram.
2. The method for generating an industrial control programming ladder diagram based on LLM according to claim 1, characterized in that: The method includes the following steps: generating a target programming ladder diagram of graphic components; Step A. Apply the first language model to receive the target programming requirements in natural language input, generate a ladder diagram in the form of a text graph, and proceed to Step B; Step B. Applying a pre-trained base for generating XML files compliant with PLCOpen XML Formats to generate a large language model, receiving the ladder diagram in the form of a text graph for processing, and generating a corresponding target XML file compliant with PLCOpen XML Formats, and then proceeding to Step C; Step C. Based on the RAG of the conversion rules between the preset XML file and the target JSON file, the base generates a large language model to receive the target XML file for conversion and outputs the corresponding target JSON file, and then proceeds to step D; Step D. Based on the target JSON file, update the graphic components in the industrial control programming platform, encapsulate and obtain the GOJS graphic components, parse the target JSON file, and generate a target programming ladder diagram with graphic components.
3. The method for generating an industrial control programming ladder diagram based on LLM according to claim 2, characterized in that: If the target programming ladder diagram of the graphic component needs to be modified, then compare the target programming ladder diagram of the graphic component generated in step D, apply the large language model according to step A, receive the modification suggestions in natural language, generate a ladder diagram in the form of a new text diagram, and enter step B; then, according to steps B to step D, generate a new target programming ladder diagram of the graphic component through the new target XML file and the new target JSON file, and realize the modification of the target programming ladder diagram of the graphic component.
4. The method for generating an industrial control programming ladder diagram based on LLM according to claim 2 or 3, characterized in that: The ladder diagram in the form of a text graph generated in step A includes various text form elements and the connection relationship between various text form elements; the target XML file generated in step B includes various XML elements and the connection structure between various XML elements; The RAG in step C includes component conversion rules and inter-component connection conversion rules between the preset XML file and the target JSON file. The generated target JSON file includes each JSON component and the connection structure between each JSON component. The target programming ladder diagram of the graphic componentization generated in step D includes each graphic componentization element and the connection structure between each graphic componentization element.
5. The method for generating an industrial control programming ladder diagram based on LLM according to claim 4, characterized in that: Based on the target programming ladder diagram of the graphical componentization generated in step D, the method further includes compiling and executing the following steps; Step i. Processing the target programming ladder diagram of the graphical component to obtain the corresponding target JSON file, and then based on the preset XML file and the conversion rules between the target JSON file under the target requirements RAG, the base generates a large language model to receive the target JSON file for conversion, and outputs the corresponding target XML file, and then proceeds to step ii; Step ii. Use the compilation and debugging module in the industrial control programming platform to process the target XML file. Obtain the corresponding target programming language project from the corresponding structured ST project text. Finally, use the GNU compiler to compile the target programming language project to obtain the target binary program for running on the PLC. This program is then sent to the PLC device for execution.
6. The method for generating an industrial control programming ladder diagram based on LLM according to claim 5, characterized in that: In step ii, the compilation and debugging module in the industrial control programming platform is used to process the target XML file, and the corresponding C language project is obtained through the corresponding structured ST project text. Finally, the GNU compiler is used to compile the C language project to obtain a binary program for running on the PLC, which constitutes the target binary program.
7. The method for generating an industrial control programming ladder diagram based on LLM according to claim 2, characterized in that: Based on a preset number of XML files corresponding to text graphical ladder diagrams, the XML files are input into the large language model for training, and the base for generating the XML file that complies with PLCOpen XML Formats in step B is obtained to generate the large language model.
Citation Information
Patent Citations
Compiling method of structured text programming language, compiler and electronic equipment
CN116360788A
Method, system and device for converting ladder diagram language into ST language
CN116661806A
Cited By
Target program generation method and system, computer equipment and computer program product
CN121478298A
Method for generating ladder diagram of programmable controller based on large language model
CN122018423A
Ladder diagram generation method for programmable controller based on large language model
CN122018423B
Information processing system, information processing method, and program
JP7855156B1
Information processing system, information processing method, and program
JP7858963B1