PLC programming using large language models

The integration of LLMs with low-rank adaptation and verification tools automates PLC code generation, addressing the limitations of existing LLMs by ensuring code validity and safety, thereby enhancing efficiency and reliability in PLC programming.

WO2025144435A1PCT designated stage expired Publication Date: 2025-07-03SIEMENS AG +1
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
PCT/US2024/021907
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-28
Filing Date
2024-03-28
Publication Date
2025-07-03

AI Technical Summary

Technical Problem

Existing Large Language Models (LLMs) lack execution guarantees and explainability, and fail to produce valid programs for Industrial Control Systems operated by Programmable Logic Controllers (PLCs), necessitating manual and extensive engineering efforts for code synthesis and verification.

Method used

A method utilizing a large language model (LLM) with low-rank adaptation techniques to generate PLC code, integrated with a structured text compiler and symbolic model verifier, performing syntax and execution checks to ensure code validity and safety, and iteratively updating the LLM based on feedback.

Benefits of technology

Enhances PLC code generation efficiency and reliability by automating the engineering process, reducing manual effort and ensuring code meets safety and functional requirements through iterative verification and correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US2024021907_03072025_PF_FP_ABST
    Figure US2024021907_03072025_PF_FP_ABST
Patent Text Reader

Abstract

Methods for generating programmable logic controller (PLC) code and corresponding systems and computer-readable mediums. A method (400) includes receiving (402) at least one specification (160) by a computer system (100). The method includes generating (404) a model-based design plan (158) based on the at least one specification (160) and a large-language model (LLM) (154) and processing (406) the model-based design plan (158) using low-rank adaption techniques (162) and the LLM (154) to produce PLC code (156). The method includes performing (408) a syntax check on the PLC code (156) and outputting (414) the PLC code (156).
Need to check novelty before this filing date? Find Prior Art

Description

PLC PROGRAMMING USING LARGE LANGUAGE MODELSCROSS-REFERENCE TO OTHER APPLICATION

[0001] This application claims the benefit of the filing date of U.S. Provisional Patent Application 63 / 615,299, filed December 28, 2023, which is hereby incorporated by reference.TECHNICAL FIELD

[0002] The present disclosure is directed, in general, to programming of programmable logic controllers (PLCs) and other devices.BACKGROUND OF THE DISCLOSURE

[0003] Although Large Language Models (LLMs) have established predominance in automated code generation, they are not devoid of shortcomings. The pertinent issues primarily relate to the absence of execution guarantees for generated code, a lack of explainability, and suboptimal support for essential but niche programming languages. State-of-the-art LLMs such as GPT-4 and LLaMa2 fail to produce valid programs for Industrial Control Systems (ICS) operated by PLCs. Improved systems are desirable.SUMMARY OF THE DISCLOSURE

[0004] Various disclosed embodiments include methods for generating programmable logic controller (PLC) code and corresponding systems and computer-readable mediums. These methods can be performed by one or more computer systems. A method includes receiving at least one specification by a computer system. The method includes generating a model-based design plan based on the at least one specification and a large- language model (LLM) and processing the model-based design plan using low-rank adaption techniques and the LLM to produce PLC code. The method includes performing a syntax check on the PLC code and outputting the PLC code.

[0005] Some embodiments include operating an industrial device using the PLC code. Some embodiments include verifying execution of the PLC code. Some embodiments include determining whether the PLC code is correct, and when the PLC code is not correct, then updating the LLM and repeating the processing step.

[0006] In various embodiments, updating the LLM is based on results of the syntax check. In various embodiments, the PLC code includes structured text (ST) code, and performing the syntax check includes using a structured text compiler to identify syntax errors in the PLC code. In various embodiments, the PLC code includes symbolic model verifier (SMV) code.

[0007] Some embodiments include verifying execution of the PLC code using an SMV specification file or a plant specification. In some embodiments, the at least one specification includes a natural-language specification defined via an interaction with a user. In some embodiments, the plant specification outlines behavior, constraints, and requirements for the PLC code, and the SMV specification file specifies formal properties and conditions that the PLC code must satisfy.

[0008] Various embodiments include a computer system comprising a processor and an accessible memory, particularly configured to perform processes as disclosed herein. Various embodiments include a non-transitory computer-readable medium encoded withexecutable instructions that, when executed, cause one or more computer systems to perform processes as disclosed herein.

[0009] The foregoing has outlined rather broadly the features and technical advantages of the present disclosure so that those skilled in the art may better understand the detailed description that follows. Additional features and advantages of the disclosure will be described hereinafter that form the subject of the claims. Those skilled in the art will appreciate that they may readily use the conception and the specific embodiment disclosed as a basis for modifying or designing other structures for carrying out the same purposes of the present disclosure. Those skilled in the art will also realize that such equivalent constructions do not depart from the spirit and scope of the disclosure in its broadest form.

[0010] Before undertaking the DETAILED DESCRIPTION below, it may be advantageous to set forth definitions of certain words or phrases used throughout this patent document: the terms “include” and “comprise,” as well as derivatives thereof, mean inclusion without limitation; the term “or” is inclusive, meaning and / or; the phrases “associated with” and “associated therewith,” as well as derivatives thereof, may mean to include, be included within, interconnect with, contain, be contained within, connect to or with, couple to or with, be communicable with, cooperate with, interleave, juxtapose, be proximate to, be bound to or with, have, have a property of, or the like; and the term “controller” means any device, system or part thereof that controls at least one operation, whether such a device is implemented in hardware, firmware, software or some combination of at least two of the same. It should be noted that the functionality associated with any particular controller may be centralized or distributed, whether locally or remotely. Definitions for certain words and phrases are provided throughout this patent document, and those of ordinary skill in the art will understand that such definitions apply in many, if not most, instances to prior as well as future uses of such defined words and phrases. While some terms may include a wide variety of embodiments, the appended claims may expressly limit these terms to specific embodiments.BRIEF DESCRIPTION OF THE DRAWINGS

[0011] For a more complete understanding of the present disclosure, and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, wherein like numbers designate like objects, and in which:

[0012] FIG. 1 illustrates a block diagram of a computer system in which an embodiment can be implemented;

[0013] FIG. 2 illustrates a Unified Modeling Language representation of an example of an engineering process in accordance with disclosed embodiments;

[0014] FIG. 3 illustrates a block diagram of elements of an automated system for generating PLC code in accordance with disclosed embodiments; and

[0015] FIG. 4 illustrates a flowchart of a process in accordance with disclosed embodiments.DETAILED DESCRIPTION

[0016] FIGS. 1 through 4, discussed below, and the various embodiments used to describe the principles of the present disclosure in this patent document are by way of illustration only and should not be construed in any way to limit the scope of the disclosure. Those skilled in the art will understand that the principles of the present disclosure may be implemented in any suitably arranged device. The numerous innovative teachings of the present application will be described with reference to exemplary non-limiting embodiments.

[0017] PLCs are indispensable in the landscape of Industrial Automation, and these controllers drive essential infrastructure and industry such as oil pipelines, electric grids, manufacturing sites, and nuclear power plants. PLCs are domain-specific real-time computers, integrating an “Input-Compute-Output” execution loop and running specialized programs created with one of five programming paradigms standardized under IEC 61131-3. Out of these five approaches, only Structured Text (ST) resembles conventional programming languages in terms of syntax and structure. This property allows for automated code generation targeting the ST language using state-of-the-art techniques. Moreover, the usage of formal verification schemes for IEC 61131-3 programs enables generated code to meet strict safety, complexity, and timing requirements.

[0018] Software in critical infrastructure and machinery are required to operate within a narrow safety margin and typically necessitate extensive testing and verification. In the typical project lifecycle, engineers and domain experts extensively analyze and design potential solutions before any programming effort is made, followed by dedicated synthesis and verification steps before deployment. Therefore, the governance of PLC control programs by strict guidelines and requirements adds complexity to engineering tasks, resulting in hundreds of extra hours of expert-level effort, often even requiring Reverse Engineering to recover the initial intent of the programmer.

[0019] Although some techniques exist to automate the synthesis of IEC-61131-3 PLC programs given a specification and synthesis paradigm - such as Linear Temporal Logic or novel software-implemented frameworks such as MODI - these approaches have not solved the engineering challenge of combining all parts of the PLC programming process into a single unified model.

[0020] Recent developments in LLMs offer an alternative to legacy automation methods. However, given the irregularities in LLM code generation, naive use of LLMs in the Engineering Workflow, signified by inefficient prompting and blind execution of unverified output code, leads to unsafe operation. Yet, foundational models such as the GPT-4 LLM and LLama 2 LLM are challenging traditional approaches to automation and programming. Especially noteworthy is these models’ instructional (i.e., “chat-instruct”) capabilities, which allow for dynamic prompting based on a conversational input paradigm, which can enable automated feedback mechanisms. Additionally, with the application of Parameter-Efficient Line-Tuning (PEFT), Low-Rank Adaptations have made domain-specific training easier and significantly reduced compute and data requirements for these tasks. Lastly, the LLM research community has pioneered “prompt-engineering,” - a practice of optimizing prompts resulting in more accurate and relevant LLM responses.

[0021] Disclosed embodiments exploit and improve on these advances, in combination with LLM-based code generation techniques for Industrial Control Systems, to produce an innovative, effective, and efficient automation process.

[0022] Disclosed embodiments expedite the engineering effort by offloading a sizeable majority of PLC-related problem-solving tasks to a dedicated LLM- Agent that can automatically generate PLC code. Disclosed embodiments contrast sharply with provide a significant technical advantage over existing automated programming approaches, where the engineer is required to create the model design, synthesize code, and verify their solution manually.

[0023] Automated PLC code generation has previously been explored by methods that do not utilize LLMs, instead relying on such elements as a reference graphical solution or aweb service agent, with incomplete, unusable results without the help of an engineer or programmer. Conversely, LLMs have been used in industrial automation, not for use in PLC code generation, but rather used as an intelligent assistant to assist in tasks such as process execution and troubleshooting.

[0024] FIG. 1 illustrates a block diagram of a computer system in which an embodiment can be implemented, for example as a computer system particularly configured by software or otherwise to perform the processes as described herein, and in particular as each one of a plurality of interconnected and communicating systems as described herein. The computer system depicted includes a processor 102 connected to a level two cache / bridge 104, which is connected in turn to a local system bus 106. Local system bus 106 may be, for example, a peripheral component interconnect (PCI) architecture bus. Also connected to local system bus in the depicted example are a main memory 108 and a graphics adapter 110. The graphics adapter 110 may be connected to display 111.

[0025] Other peripherals, such as local area network (LAN) / Wide Area Network / Wireless (e.g. WiFi) adapter 112, may also be connected to local system bus 106. Expansion bus interface 114 connects local system bus 106 to input / output (I / O) bus 116. I / O bus 116 is connected to keyboard / mouse adapter 118, disk controller 120, and I / O adapter 122. Disk controller 120 can be connected to a storage 126, which can be any suitable machine usable or machine readable storage medium, including but not limited to nonvolatile, hard-coded type mediums such as read only memories (ROMs) or erasable, electrically programmable read only memories (EEPROMs), magnetic tape storage, and user-recordable type mediums such as floppy disks, hard disk drives and compact disk read only memories (CD-ROMs) or digital versatile disks (DVDs), and other known optical, electrical, or magnetic storage devices.

[0026] Storage 126 can store any data necessary or useful for performing any of the processes described herein, including executable code 152, LLMs 154, PLC code 156, model -based design plans 158, specifications 160, low-rank adaptation (LoRA) code 162, application software 164 (which can include syntax checkers and execution verifiers), and any other data 166.

[0027] Also connected to I / O bus 116 in the example shown is audio adapter 124, to which speakers (not shown) may be connected for playing sounds. Keyboard / mouse adapter 118 provides a connection for a pointing device (not shown), such as a mouse, trackball, trackpointer, touchscreen, etc.

[0028] Those of ordinary skill in the art will appreciate that the hardware depicted in FIG. 1 may vary for particular implementations. For example, other peripheral devices, such as an optical disk drive and the like, also may be used in addition or in place of the hardware depicted. The depicted example is provided for the purpose of explanation only and is not meant to imply architectural limitations with respect to the present disclosure.

[0029] A computer system in accordance with an embodiment of the present disclosure includes an operating system employing a graphical user interface. The operating system permits multiple display windows to be presented in the graphical user interface simultaneously, with each display window providing an interface to a different application or to a different instance of the same application. A cursor in the graphical user interface may be manipulated by a user through the pointing device. The position of the cursor may be changed and / or an event, such as clicking a mouse button, generated to actuate a desired response.

[0030] One of various commercial operating systems, such as a version of Microsoft Windows™, a product of Microsoft Corporation located in Redmond, Wash, may be employed if suitably modified. The operating system is modified or created in accordance with the present disclosure as described.

[0031] LAN / WAN / Wireless adapter 112 can be connected to a network 130 (not a part of computer system 100), which can be any public or private computer system network or combination of networks, as known to those of skill in the art, including the Internet. Computer system 100 can communicate over network 130 with server system 140, which is also not part of computer system 100, but can be implemented, for example, as a separate computer system 100.

[0032] Disclosed embodiments include an iterative process that uses LLMs to generate code for Industrial PLCs, overcoming the limitations of the current state-of-the-art. The disclosed process can integrate user feedback loops and incorporate a number of external verification tools, including, for example, grammar checkers and a model verifier, such as the nuXmv symbolic model checker available at time of filing from nuxmv.fbk.eu. The disclosed process can be optimized via such techniques as prompt engineering and model fine-tuning mechanisms utilizing low-rank adaptation (LoRA).

[0033] FIG. 2 illustrates a Unified Modeling Language (UML) representation 200 of an example of an engineering process in accordance with disclosed embodiments. The UML representation example of FIG. 2 illustrates a top-down view of a process particularly useful in industrial settings. As represented in this figure, a computer system (such as one or more computer systems 100) can interact with a user 202 and implement an LLM 202 and a syntax check / logic verifier 206 to develop PLC code. Various embodiments can include such elements as a natural language specification 208 used to specify the PLC code to be developed, model design and feedback 210, automatic syntax feedback 212 that can use symbolic model verifier (SMV) code and / or structured text (ST) code, and automatic logic feedback 214 that can identify, constrain, and correct the ST code to produce a final PCL code solution 216. The ST code can be in the SIEMENS structured control language (SCL) programming language.

[0034] FIG. 3 illustrates a block diagram of elements of an automated system 300 for generating PLC code in accordance with disclosed embodiments. In this figure, an engineer interacts with system 310, which can be implemented using one or more computer systems 100. System 310 implements both an interactive feedback session 320 and an automated feedback loop 330. Engineer (or other user) 302 can interact with the interactive feedback session 320. Various elements and processes of the interactive feedback session 320 and automated feedback loop 330 interact with a large language model 360.

[0035] Interactive feedback session 320 includes natural language specification 322, which can be received as described herein, and in particularly can be received via aninteraction with user 302, using LLM 360 to interpret the natural language specification 322 and to interact with the user 302 to define and refine the natural language specification 322. In addition to a natural-language specification 322 of the objective and constraints of the PLC code to be generated, at this point the system 300 can also receive any other necessary data, such as a plant specification that outlines the behavior, constraints, and requirements of the industrial process the PLC code is intended to control, an SMV specification file that specifies the formal properties and conditions that the PLC code must satisfy, and other required specification information.

[0036] System 310 then uses the natural language specification 322 and LLM 360 to generate a model-based design plan 324. The model-based design plan 326 (MDB) can be implemented in a number of ways. In some cases, it can be represented as a transformation from a Natural Language description of a task into the equivalent realization in industrial engineering. For example, a prompt to generate an MBD for mixing two chemicals might result in annotated image synthesis from the LLM to produce a Process Flow Diagram (PFD), which is graduated to a Plant & Instrumentation Diagram (P&ID) and augmented with SCL code (as described herein) that will actuate the components (pumps, valves, etc.) identified in the P&ID. In various embodiments, the output of the LLM can be implemented as a fully automated MBD. This way, the system can not only isolate the capacity to generate and validate instructions (SCL code) that lead to automation, but can also correctly extract the components that require actuation from (synthesized) engineering artifacts before executing the generation and validation process for SCL code described herein.

[0037] Automated feedback loop 332 of system 310 can process the model-based design plan 324 using trained LoRAs 332 to generate PLC code based on the LLM 360, which can include SMV code 334 and ST code 336.

[0038] Note that structured text code 336, which can be SCL, is one example of an acceptable PLC programming language, but other PLC programming language or form can be used, such as a ladder diagram, function block diagram, sequential function chart, or instruction list.

[0039] Automated feedback loop 332 of system 310 can perform a syntax check 338 on the SMV code 334 and ST code 336, such as by using the open-source MATIEC compiler.

[0040] Disclosed embodiments can include syntax checkers, such as by using the open- source MATIEC compiler at 338. Various embodiments can use any open-source IEC 61131-3 structured text compiler in order to perform syntax checking of LLM-generated code. This exemplary embodiment uses the MATIEC compiler to search for syntax errors in the generated code. If any error is detected, the output of the MATIEC compiler is then used by automated feedback loop 332 to create a “correction prompt” for the LLM in the next iteration of the generation feedback loop.

[0041] In various embodiments, the system uses only one compiler error and its associated generated prompt per cycle. Doing so allows a targeted fix from the LLM for each error, rather than continuously prompting to fix multiple errors at once. Moreover, for each compiler error, subsequent errors can be dependent on the original error. For example, a missing semicolon may directly cause another compiler error on a subsequent line. By feeding only one error and correction prompt at a time, the system minimizes the total number of prompts and generation iterations needed. Note that this would also allow for multiple errors to be fixed in one iteration cycle, for example when one error is wholly caused as a result of a preceding error.

[0042] Automated feedback loop 332 of system 310 can then verify execution 340 of the SMC code 334 and structured text code 336 such as by using the nuXmv Symbolic Model Checker.

[0043] Upon generating compilable PLC code (as SMV code 334 and structured text code 336), various embodiments then perform verification using nuXmv, a symbolic model checker based on the SMV paradigm. This verification process can verify that the produced code adheres not only to syntactical standards but also to functional and safety requirements intrinsic to industrial automation scenarios.

[0044] To conduct this verification, the system can translate the constraints from Natural Language to SMV code within the feedback loop, similarly to the ST code. This system can use any other useful or required information, such as a plant specification or SMV specification file, as part of the verification. For example, the system can use the plant specification and the SMV specification file in conjunction with nuXmv as a means to perform formal verification on the PLC code. This approach ensures that the generated code is not only compilable but also reliable and safe for deployment in a real-world industrial setting. Through this verification mechanism, any discrepancies between the intended and actual behavior of the PLC code can be promptly identified and rectified before deployment, enhancing the robustness of the disclosed process.

[0045] Note that, in various embodiments, syntax checking and execution verification may not both be performed in each iteration of the described processes. For example, there may be multiple iterations that include syntax checking but not execution verification before the system produces PLC code that is syntactically correct, and the system may only then begin to perform iterations that include execution validation.

[0046] Based on the results of the syntax check 338 and execution verification 340, the automated feedback loop 332 of system 310 can return to re-generate SMV code 334 and structured text code 336, or can output the final SMV code 334 and / or structured text code 336 as PLC code 350.

[0047] The disclosed model-based design (MBD), in the context of industrial PLC programming, uses a structured, systematic approach that enhances both the efficiency of the development process and the reliability of the resultant code. By following taskspecific prompt guidelines for planning, the LLMs can sift through given specifications and requirements to create a comprehensive plan for subsequent processing.

[0048] Disclosed embodiments can generate complete function and block declarations and their corresponding signatures for the MBD 324, serving as an executable blueprint that ensures alignment between the development process and the defined natural language specifications. Moreover, disclosed embodiments can highlight any ambiguitiesin user requirements, providing an opportunity for prompt clarification and thereby minimizing the risk of deviations or errors in the subsequent code implementation phase.

[0049] Disclosed embodiments can use Finite State Machines (FSMs), providing a significant technical advantage over other methods. Explicit planning around FSM states not only allows for a clear roadmap but also optimizes the PLC scan cycle. Because PLC logic does not follow the traditional loop-based execution model, using a state variable to track the system state is particularly useful. Each state in the FSM is responsible for a single operation, making the execution predictable and easier to debug.

[0050] In the MBD prompt used alongside the Natural Language Specification, the system can constrain the LLM to follow an FSM design for the design solution.

[0051] FIG. 4 depicts a flowchart of a process 400 in accordance with disclosed embodiments that may be performed, for example, by one or more computer systems as disclosed herein (collectively, the “system”).

[0052] At 402, the system receives at least one specification for PLC code to be generated. “Receiving,” as used herein, can include loading from storage, receiving from another device or process, receiving via an interaction with a user, or otherwise. In preferred embodiments, this includes receiving a natural language specification from a user such as an engineer, which can include a conversational interaction to define and refine the natural language specification. This process can be implemented using an LLM. This can also include receiving other specifications, such as a plant specification that outlines the behavior, constraints, and requirements of the industrial process the PLC code is intended to control or an SMV specification file that specifies the formal properties and conditions that the PLC code must satisfy.

[0053] At 404, the system generates a model-based design plan based on the at least one specification and the LLM.

[0054] At 406, the system processes the model-based design plan using low-rank adaptation (LoRA) techniques and the LLM to generate PLC code. The PLC code can include symbolic model verifier (SMV) code and / or structured text (ST) code.

[0055] At 408, the system performs a syntax check on the PLC code. This can include using a structured text compiler to identify syntax errors in the PLC code. The syntax check can produce results that include a correction prompt to be used to update or modify the LLM.

[0056] At 410, the system can verify execution of the PLC code. This can include verifying the PLC code using an SMV specification file and / or a plant specification. This execution verification can produce results including violations of the SMV specification file and / or plant specification and discrepancies between the intended behavior of the PLC code and the actual behavior of the PLC code.,

[0057] At 412, the system determines, based on the syntax check and / or the execution verification, whether the PLC code is correct.

[0058] If the PLC code is not correct at 410, the system returns to 406. As part of returning to 406, the system can update the LLM at 418 or perform other processes based on results of the syntax check and / or results of the execution verification.

[0059] If the PLC code is correct at 410, the system outputs the generated PLC code at 414. The output can include displaying to a user, saving to a storage, transmitting to another device or process, writing to a PLC, or otherwise.

[0060] At 416, in some cases, an industrial device is operated using the generated PLC code.

[0061] Of course, those of skill in the art will recognize that, unless specifically indicated or required by the sequence of operations, certain steps in the processes described above may be omitted, performed concurrently or sequentially, or performed in a different order.

[0062] Those skilled in the art will recognize that, for simplicity and clarity, the full structure and operation of all computer systems suitable for use with the present disclosure is not being depicted or described herein. Instead, only so much of a computer system as is unique to the present disclosure or necessary for an understanding of thepresent disclosure is depicted and described. The remainder of the construction and operation of computer system 100 may conform to any of the various current implementations and practices known in the art.

[0063] It is important to note that while the disclosure includes a description in the context of a fully functional system, those skilled in the art will appreciate that at least portions of the mechanism of the present disclosure are capable of being distributed in the form of instructions contained within a machine-usable, computer-usable, or computer- readable medium in any of a variety of forms, and that the present disclosure applies equally regardless of the particular type of instruction or signal bearing medium or storage medium utilized to actually carry out the distribution. Examples of machine usable / readable or computer usable / readable mediums include: nonvolatile, hard-coded type mediums such as read only memories (ROMs) or erasable, electrically programmable read only memories (EEPROMs), and user-recordable type mediums such as floppy disks, hard disk drives and compact disk read only memories (CD-ROMs) or digital versatile disks (DVDs).

[0064] Although an exemplary embodiment of the present disclosure has been described in detail, those skilled in the art will understand that various changes, substitutions, variations, and improvements disclosed herein may be made without departing from the spirit and scope of the disclosure in its broadest form.

[0065] None of the description in the present application should be read as implying that any particular element, step, or function is an essential element which must be included in the claim scope: the scope of patented subject matter is defined only by the allowed claims. Moreover, none of these claims are intended to invoke 35 USC §112(f) unless the exact words "means for" are followed by a participle. The use of terms such as (but not limited to) “mechanism,” “module,” “device,” “unit,” “component,” “element,” “member,” “apparatus,” “machine,” “system,” “processor,” or “controller,” within a claim is understood and intended to refer to structures known to those skilled in the relevant art, as further modified or enhanced by the features of the claims themselves, and is not intended to invoke 35 U.S.C. §112(f).

Claims

WHAT IS CLAIMED IS:

1. A method (400) for generating programmable logic controller (PLC) code, the method (400) performed by a computer system (100) and comprising: receiving (402) at least one specification (160) by the computer system (100); generating (404) a model-based design plan (158) based on the at least one specification (160) and a large-language model (LLM) (154); processing (406) the model-based design plan (158) using low-rank adaption techniques (162) and the LLM (154) to produce PLC code (156); and performing (408) a syntax check on the PLC code (156); and outputting (414) the PLC code (156).

2. The method of claim 1, further comprising operating an industrial device (416) using the PLC code (156).

3. The method of claim 1, further comprising verifying execution (410) of the PLC code (156).

4. The method of claim 1, further comprising determining (412) whether the PLC code (156) is correct, and when the PLC code (156) is not correct, then updating (418) the LLM (154) and repeating the processing step (406).

5. The method of claim 4, wherein updating (418) the LLM (154) is based on results of the syntax check (408).

6. The method of claim 1, wherein the PLC code (156) includes structured text (ST) code, and performing the syntax check (408) includes using a structured text compiler (164) to identify syntax errors in the PLC code (156).

7. The method of claim 1, wherein the PLC code (156) includes symbolic model verifier (SMV) code.

8. The method of claim 7, further comprising verifying execution (410) of the PLC code (156) using an SMV specification file (160) or a plant specification (160).

9. The method of claim 1, wherein the at least one specification (160) includes a natural-language specification (160) defined via an interaction with a user.

10. The method of claim 1, wherein the at least one specification (160) includes a plant specification that outlines behavior, constraints, and requirements for the PLC code (156) or an SMV specification file that specifies formal properties and conditions that the PLC code (156) must satisfy.

11. A computer system (100) comprising a processor (102) and an accessible memory (108), the computer system (100) particularly configured to perform a process as in any of claims 1-10.

12. A non-transitory computer-readable medium (126) encoded with executable instructions (152) that, when executed, cause one or more computer systems (100) to perform a process as in any of claims 1-10.

Citation Information

Cited By

  • Structured text code generation and review method

    CN120743231A

  • Code generation method and device, equipment and storage medium

    CN121477769A

  • Code generation method based on knowledge topology alignment and dynamic complexity reduction

    CN121979505A

  • Industrial ST code generation-oriented constraint consistency training and decoding method

    CN122470163A