Industrial PLC code generation system and method based on artificial intelligence
Through the artificial intelligence-based PLC code generation system, the problems of low PLC code development efficiency, insufficient intelligence, disconnection between simulation and verification, and safety risks have been solved, and efficient and reliable code generation and deployment have been achieved to meet the needs of complex industrial scenarios.
Patent Information
- Application Number
- CN202510679524.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-09-05
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing PLC code development is inefficient and error-prone. Automation tools lack intelligence, simulation verification is disconnected from the real environment, cross-platform compatibility is poor, and there are major security risks, making it difficult to adapt to the needs of complex industrial scenarios.
An AI-based industrial PLC code generation system is used to achieve efficient and reliable code generation and deployment through multi-modal input analysis, deep learning model optimization, closed-loop verification, and multi-platform adaptation.
It significantly improves PLC code development efficiency, reduces error rates, enhances the system's ability to adapt to complex scenarios, ensures code security and compatibility, and shortens the cycle from demand analysis to device deployment.
Smart Images

Figure CN120596076A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of industrial automation, and in particular relates to an industrial PLC code generation system and method, equipment and medium based on artificial intelligence. Background Art
[0002] In existing technologies, PLCs (Programmable Logic Controllers) are widely used as core control devices in the industrial automation field. Their program development has long relied on engineers manually writing codes such as ladder diagrams (LADs) and structured text (STs). Although existing technologies have introduced some automation tools, they still have the following significant drawbacks:
[0003] 1. Manual programming is inefficient and error-prone
[0004] Traditional PLC code development requires engineers to write logic instructions line by line, resulting in long development cycles in complex scenarios. Statistics show that a significant amount of time spent on debugging and error correction in industrial equipment R&D is spent on debugging and error correction. For example, troubleshooting Siemens PLC hardware modules (such as I / O modules) requires point-by-point testing. Logical errors in the code can cause equipment downtime and result in financial losses. Furthermore, manual programming is prone to introducing syntax and logic errors, requiring repeated debugging and verification, further extending the development cycle.
[0005] 2. Existing automation tools are not intelligent enough
[0006] While existing auxiliary tools (such as CODESYS and Siemens TIA Portal) provide code generation capabilities, they are often based on rule engines or limited template libraries, making them inadequate for complex control logic. For example, CODESYS relies heavily on vendor-provided library files, rendering the program inoperable without key libraries. Furthermore, its code structure is loose and difficult to maintain. Furthermore, existing tools lack support for multimodal input (such as natural language and flowcharts), making it difficult to accurately interpret user intent.
[0007] 3. Simulation verification is out of touch with the real environment
[0008] While simulation tools (such as Siemens PLCSIM) can simulate PLC operation, they are limited by internal protocols and cannot interact with external software (such as HMIs and waveform recording tools) in real time, resulting in deviations between simulation results and actual device behavior. For example, PLCSIM requires third-party software (such as NetToPLCsim) to expand communication capabilities, but this configuration is complex and has poor compatibility, increasing debugging costs.
[0009] 4. Low cross-platform compatibility and deployment efficiency
[0010] PLCs from different brands (such as Siemens, Mitsubishi, and Omron) use heterogeneous programming languages and engineering environments, requiring manual rewriting of code migration. For example, the code generated by CODESYS performs poorly in terms of memory usage and execution speed, and lacks hardware-specific optimization. 26 Furthermore, existing tools lack a unified deployment interface, requiring manual configuration of communication parameters when downloading code to devices, which can easily lead to compatibility issues.
[0011] 5. Security and reliability risks
[0012] Code generation tools for industrial control systems are prone to widespread security vulnerabilities. For example, CODESYS has been repeatedly exposed to high-risk vulnerabilities (such as CVE-2021-29238 and CVE-2022-4048), which attackers can exploit to remotely execute malicious code or tamper with control logic, threatening the security of industrial equipment. Traditional tools lack static code checking and dynamic verification mechanisms, making it difficult to detect potential risks before deployment.
[0013] Existing AI-assisted programming tools are mostly rule-based or based on limited datasets, making them difficult to adapt to the demands of complex industrial scenarios. DeepSeek-V3, an advanced Mixture of Experts (MoE) language model with 671B parameters and efficient reasoning (MLA attention mechanism), can optimize PLC code generation tasks, but its application in the industrial control field has yet to be seen. Summary of the Invention
[0014] The purpose of the present invention is to solve the problems in the prior art and propose an industrial PLC code generation system and method based on artificial intelligence, providing a tool for generating PLC code from natural language based on artificial intelligence, thereby improving code development efficiency and reducing error rate.
[0015] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions.
[0016] The industrial PLC code generation system based on artificial intelligence includes an input module, a model optimization module, a code generation module and a deployment module, wherein:
[0017] The input module is used to receive and parse natural language, flow charts and I / O configuration tables and generate structured logical constraints;
[0018] The model optimization module is used to fine-tune artificial intelligence models using data from the industrial control field, supporting low-precision reasoning and dynamic expert network load balancing;
[0019] The code generation module is used to output PLC code that meets industrial standards and supports simulation verification and error correction;
[0020] The deployment module is used to download the generated code to the target PLC device or integrate it into the engineering software.
[0021] Furthermore, it also includes a simulation verification module for testing code logic through a virtual PLC environment and providing feedback on correction suggestions.
[0022] Furthermore, the input module includes a receiving unit, a parsing unit and a generating unit, wherein:
[0023] The receiving unit is used to receive user input, supports natural language description, process flow chart or I / O configuration table, and completes data upload through API interface or graphical interface;
[0024] The parsing unit is used to perform multimodal input parsing on input data, extract key control logic from natural language using semantic segmentation technology, identify electrical component symbols and their connection relationships using CV algorithms on flow charts and schematics, perform structured mapping on I / O tables, and generate variable declaration templates;
[0025] The generating unit is used to generate structured input data and uniformly encode multimodal input into JSON format, including control objectives, logical constraints and device parameters.
[0026] Furthermore, the code generation module includes an inference unit, a processing unit, an environment test unit and a dynamic detection unit, wherein:
[0027] The reasoning unit generates structured text and ladder diagrams based on structured input data and models in parallel, and device configuration files. It dynamically allocates expert networks to process different control logics through the load balancing strategy of the artificial intelligence architecture.
[0028] The processing unit is used to standardize the code, including adding standard comment templates, automatically optimizing variable naming, and performing static syntax checking;
[0029] The environment testing unit is used to perform virtual environment testing, including calling the simulator to build a virtual PLC environment, injecting test cases, and recording runtime indicators;
[0030] The dynamic detection unit is used to perform dynamic error detection, including logic error detection, timing error detection and safety compliance checking.
[0031] Furthermore,
[0032] The logic error detection includes verifying program reachability through symbolic execution;
[0033] The timing error detection includes comparing the deviation between the actual output and the expected timing diagram;
[0034] The security compliance check includes evaluating the security level against industry standards.
[0035] Furthermore, the code generation module also includes an optimization unit, which is used to perform feedback iterative optimization, including backpropagating the verification results to the reinforcement learning model and updating the attention weights; establishing a correction rule library for high-frequency error types; and generating revision suggestions with error markers.
[0036] Furthermore, the deployment module includes an adaptation unit, a packaging unit and a deployment unit, wherein:
[0037] The adaptation unit is used to perform multi-platform adaptation output and convert the generated code into the target platform format:
[0038] The packaging unit is used to package the project files and automatically generate supporting documents, which include hardware configuration instructions, HMI interface definition files and version control records.
[0039] The deployment unit is used to perform one-click deployment, including completing program downloads by directly connecting to PLC devices via the OPC UA protocol, supporting seamless integration with the integrated development environment, and generating deployment reports.
[0040] In order to achieve the above object, the present invention further provides an industrial PLC code generation method based on artificial intelligence, which uses the industrial PLC code generation system based on artificial intelligence as described above, comprising:
[0041] Receive natural language or graphic description input by the user;
[0042] Generate PLC code using an artificial intelligence model fine-tuned with industrial control data, which uses low-precision reasoning and multi-token prediction to optimize code generation efficiency.
[0043] Verify code logic through simulation environment, integrate PLC simulator, automatically test logic correctness after code generation, and optimize model output to target device based on feedback.
[0044] In order to achieve the above-mentioned purpose, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a program running on the processor, and when the processor runs the program, it executes the steps of the artificial intelligence-based industrial PLC code generation system as described above.
[0045] In order to achieve the above objectives, the present invention also provides a computer-readable storage medium having computer instructions stored thereon, which, when executed, execute the steps of the industrial PLC code generation system based on artificial intelligence as described above.
[0046] The present invention proposes an industrial PLC code generation system and method based on artificial intelligence, which has the following beneficial effects:
[0047] By integrating artificial intelligence and industrial automation technologies, the entire process of PLC code generation has been significantly optimized, enabling efficient, reliable and intelligent industrial control system development.
[0048] First, the system's multimodal input parsing capabilities break the traditional tools' reliance on a single input format. The effective integration of multiple input methods, including natural language descriptions, process flow diagrams, and I / O configuration tables, enables engineers to express control requirements in a more intuitive manner, significantly lowering the learning threshold for specialized programming languages. This increased flexibility not only shortens the demand conversion cycle but also enhances the system's adaptability to complex industrial scenarios, demonstrating exceptional performance when handling fuzzy or multi-level control logic.
[0049] Secondly, the deep learning-based model optimization mechanism overcomes the limitations of traditional rule engines. Through domain-adaptive training and dynamic load balancing of a hybrid expert architecture, the system deeply understands the specialized semantics of industrial control. When generating code such as structured text and ladder diagrams, it ensures compliance with industrial standards such as IEC 61131-3 while also accounting for the differences in characteristics of equipment from different manufacturers. This intelligent code generation approach significantly reduces reliance on preset templates and demonstrates enhanced generalization capabilities when addressing new equipment or non-standard control requirements.
[0050] The establishment of a closed-loop verification system fundamentally changes the problem of delayed debugging in traditional development processes. The collaborative work of a virtual simulation environment and a real-time error correction engine enables code logic verification to be moved from late-stage on-site debugging to the development phase. Using multi-dimensional detection methods such as symbolic execution and timing analysis, the system identifies potential risks, such as deadlocks and safety compliance violations, before code deployment. It also incorporates reinforcement learning mechanisms to continuously optimize model output. This feed-forward verification mechanism not only reduces on-site debugging costs but also effectively mitigates operational risks associated with coding errors.
[0051] In terms of system compatibility, multi-platform adaptation technology overcomes the integration challenges presented by the heterogeneity of industrial equipment. Through abstraction layer design and in-depth analysis of the core protocols of mainstream PLC brands, the generated code seamlessly integrates with devices from diverse manufacturers, including Siemens, Mitsubishi, and Omron. This standardized output capability preserves the unique strengths of each platform while enabling an efficient "develop once, deploy across multiple platforms" model, fundamentally resolving the repetitive coding requirements of traditional cross-platform development.
[0052] Furthermore, the system's security is designed throughout its entire lifecycle. From semantic filtering during input parsing and static syntax checking during code generation to digital signatures and communication encryption during deployment, a multi-layered protection system has been established. Compared to the common security vulnerabilities of traditional tools, this solution significantly improves code robustness through a combination of formal verification and dynamic monitoring, meeting the dual standards of functional safety and information security for industrial control systems.
[0053] Overall, this invention reshapes the development paradigm for industrial control code through its intelligent, closed-loop design philosophy. It not only significantly shortens the cycle from requirements analysis to device deployment, but also, through a continuously optimized feedback mechanism, enables the system to evolve as application scenarios expand, providing reliable technical support for the transition from industrial automation to intelligent systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0055] Figure 1 This is a schematic diagram of the architecture of an industrial PLC code generation system based on artificial intelligence of the present invention;
[0056] Figure 2 This is a schematic diagram of the training process for PLC code generation using DeepSeek-V3, an embodiment of the present invention;
[0057] Figure 3 This is a schematic diagram of the system architecture for automatic generation of PLC code based on DeepSeek-V3 in an embodiment of the present invention;
[0058] Figure 4 This is a schematic diagram of the PLC code generation results and simulation verification of an embodiment of the present invention;
[0059] Figure 5 A schematic diagram of the structure of an electronic device 300 for implementing an embodiment of the present application. DETAILED DESCRIPTION
[0060] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0061] Example 1
[0062] Figure 1 FIG. 1 is a schematic diagram of an industrial PLC code generation system architecture based on artificial intelligence according to the present invention, as shown in FIG. Figure 1As shown, the artificial intelligence-based industrial PLC code generation system of the present invention includes an input module, a model optimization module, a code generation module and a deployment module, wherein:
[0063] The input module is used to receive user requirements (such as natural language description, process flow chart or I / O configuration table).
[0064] Optionally, the input module includes a receiving unit, a parsing unit and a generating unit, wherein:
[0065] The receiving unit is used to receive user input, supports natural language descriptions (such as "Design a motor start-stop control program that requires overload protection"), process flow charts (PNG / PDF format) or I / O configuration tables (Excel / CSV format), and completes data uploading through an API interface or a graphical interface.
[0066] The parsing unit is used to perform multimodal input parsing on input data, extract key control logic (such as "start and stop conditions → protection mechanism → execution action") from natural language using semantic segmentation technology, identify electrical component symbols and their connection relationships using CV algorithms (such as YOLOv8) on flow charts / schematic diagrams, perform structured mapping on I / O tables, and generate variable declaration templates.
[0067] The generation unit is used to generate structured input data and uniformly encode multimodal input into JSON format, including: control objectives (such as motor start and stop), logical constraints (such as interlocking conditions and timing requirements), and device parameters (such as input and output point addresses).
[0068] The model optimization module is used to fine-tune the model for PLC programming languages (such as the IEC61131-3 standard) using DeepSeek-V3's multi-token prediction (MTP) and FP8 low-precision inference 46.
[0069] Optionally, domain-adaptive model fine-tuning can be performed, and DeepSeek-V3 can be supervised fine-tuned (SFT) on industrial control domain datasets (such as PLC program libraries and equipment manuals). The FP8 mixed precision training strategy is adopted to reduce the model's memory usage, and the multi-token prediction (MTP) mechanism is introduced to accelerate the generation of long code sequences.
[0070] In this embodiment, different AI models are used as alternatives, such as a. GPT-4 or Claude 3: general-purpose large language models that require additional fine-tuning to adapt to PLC programming syntax; b. CodeLlama or StarCoder: models focused on code generation that may reduce fine-tuning costs; and c. small domain-specific models (such as small-parameter models trained based on the BERT architecture): suitable for resource-constrained edge devices.
[0071] The code generation module outputs PLC code that complies with industrial standards (such as ST and LAD) and supports simulation verification and error correction.
[0072] Optionally, the code generation module includes an inference unit, a processing unit, an environment testing unit and a dynamic detection unit, wherein:
[0073] The reasoning unit includes a function for performing code generation reasoning, based on structured input data, model parallel generation of structured text (ST) and ladder diagram (LAD), device configuration files (such as GSDML files), and dynamically allocating expert networks to process different control logics (such as sequential control → expert A, motion control → expert B) through the load balancing strategy of the DeepSeekMoE architecture.
[0074] In this embodiment, structured text (ST) complies with the IEC 61131-3 syntax specification; ladder diagram (LAD) generates graphical codes with comments.
[0075] The processing unit is used to perform code standardization, including adding standard comment templates (including function description, version information, input and output mapping tables), automatically optimizing variable naming (such as "Motor_Start" instead of "Var001"), and performing static syntax checking (based on the IEC Checker plug-in).
[0076] The environmental testing unit is used to perform virtual environment testing, including calling PLCSIM (Siemens) or CODESYS simulator to build a virtual PLC environment, injecting test cases (such as simulated sensor trigger signals and abnormal overload scenarios), and recording runtime indicators: scan cycle time, memory usage, and I / O response delay.
[0077] The dynamic detection unit is used to perform dynamic error detection, including logic error detection, timing error detection and safety compliance checking.
[0078] Logical error detection: Verifying program reachability through symbolic execution (e.g., deadlock risk identification);
[0079] Timing error detection: compare the deviation between the actual output and the expected timing diagram;
[0080] Security compliance check: Assess security levels against the ISO 13849 standard.
[0081] Optionally, the code generation module also includes an optimization unit, which is used to perform feedback iterative optimization, including backpropagating the verification results to the model (reinforcement learning mechanism) and updating the attention weight; establishing a correction rule library for high-frequency error types (such as address conflicts); and generating revision suggestions with error markers (such as "Line 25: Add interlocking contact X1").
[0082] In this embodiment, PLC code generation also includes non-LLM AI methods. For example: a. Rule Engine + Template Library: Based on predefined code templates (such as standardized motor control logic) and rules (such as IF-THEN conditional judgments), code is generated by matching user input. It has low flexibility but strong interpretability. Example: If the user enters "The temperature sensor needs to be detected when the motor starts", the system will call the "Motor Start Template" and insert the temperature detection rule (such as "IF Temperature>80℃ THENStop Motor"); b. Program Synthesis: Use formal methods (such as SyGuS) to generate code from input-output examples. It is suitable for deterministic logic. Example: Given an input signal (such as a button press) and an expected output (such as a motor start), the system automatically generates a LAD ladder diagram that satisfies the logic. c. Genetic Algorithm (GA): It iteratively optimizes code through evolutionary algorithms. It is suitable for complex control logic but has high computational cost. Example: When optimizing the motion trajectory control code of a robotic arm, multiple generations of evolution are used to screen out the code version with the shortest response time.
[0083] Traditional non-AI methods include: a. Visual drag-and-drop programming: Users manually drag and drop logic elements (such as AND gates and timers) through a graphical interface (e.g., Function Block Diagram (FBD)) and connect them together. Example: Using the FBD editor in CODESYS to build motor start / stop control logic. b. Code library reuse: Retrieving PLC code snippets with similar functions from a legacy project library, manually modifying them, and applying them to a new project. Example: Copying a conveyor control program from an old project, modifying sensor addresses, and applying them to a new production line.
[0084] As an example, Figure 3 As shown, the code generation process is
[0085] User input: For example, "Design a motor start-stop control program that requires overload protection."
[0086] Model parsing: DeepSeek-V3 generates structured text (ST) or ladder diagram (LAD) code.
[0087] Simulation testing: Verify the logic correctness through a virtual PLC environment (such as PLCSIM).
[0088] Output and deployment: Export to .awl (Siemens) or .ld (CODESYS) format and download to the hardware. Figure 4 shown.
[0089] The deployment module is used to download the generated code directly to the target PLC device or integrate it into engineering software (such as TIA Portal, CODESYS).
[0090] Optionally, the deployment module includes an adaptation unit, a packaging unit and a deployment unit, wherein:
[0091] The adaptation unit is used to perform multi-platform adaptation output and convert the generated code into the target platform format:
[0092] Siemens S7 series → .awl / .scf
[0093] CODESYS V3→.project / .library
[0094] Mitsubishi FX→.gxw
[0095] The packaging unit is used to package project files and automatically generate supporting documents, including hardware configuration instructions (including module models and network topology), HMI interface definition files (such as WinCC screen element binding), and version control records (Git repository initialization template).
[0096] The deployment unit is used for one-click deployment, including program download via direct connection to PLC devices via the OPC UA protocol, supporting seamless integration with IDEs (Integrated Development Environment) such as TIA Portal (Totally Integrated Automation Portal) (providing a VS Code plug-in), and generating deployment reports (including verification codes, digital signatures, and performance benchmark data).
[0097] Example 2
[0098] Figure 2 This is a flow chart of an industrial PLC code generation method based on artificial intelligence of the present invention, as shown in FIG. Figure 2 As shown, the present invention provides an industrial PLC code generation method based on artificial intelligence, comprising:
[0099] S1. Receive natural language or graphic description input by the user;
[0100] S2, using the DeepSeek-V3 model fine-tuned with industrial control data to generate PLC code;
[0101] Optionally, DeepSeek-V3 uses FP8 low-precision reasoning and multi-token prediction (MTP) to optimize code generation efficiency.
[0102] Optionally, industry-specific model optimization includes: Using domain-adaptive training, DeepSeek-V3 is fine-tuned using industrial control data (e.g., Siemens S7, Rockwell Logix) to improve code generation accuracy. In combination with the load balancing strategy of the DeepSeek MoE architecture, the model's reasoning efficiency is optimized for complex logic control tasks.
[0103] In this embodiment, a load balancing strategy is used to optimize the allocation of computing resources of the model in complex control tasks.
[0104] Optionally, multimodal input supports natural language descriptions, electrical schematics, or timing logic tables as input, and the model is automatically converted into structured PLC code.
[0105] S3. Verify the code logic through the simulation environment and output it to the target device.
[0106] Optional real-time verification and optimization: Integrate a PLC simulator to automatically test the logic correctness after code generation and optimize the model output based on feedback.
[0107] This paper proposes an artificial intelligence-based industrial PLC code generation system and method that improves development efficiency, increasing code generation speed by over 80% compared to manual programming. It also reduces error rates by eliminating logical and syntactic errors through model validation. It also offers scalability, supporting code generation for multiple PLC brands (such as Siemens, Mitsubishi, and Omron).
[0108] Example 3
[0109] Reference below Figure 5 , which shows a block diagram of an electronic device 300 suitable for implementing an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0110] like Figure 5As shown, the electronic device 300 may include a processing device 310, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 320 or a program loaded from a storage device 380 into a random access memory (RAM) 330. The processing device 310 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processing device 310 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processing device 310 performs the various methods and processes described above.
[0111] Various programs and data required for the operation of the electronic device 300 are also stored in the RAM 330. The processing device 310, the ROM 320, and the RAM 330 are connected to each other via a bus 340. An input / output (I / O) interface 350 is also connected to the bus 340.
[0112] Typically, the following devices may be connected to the I / O interface 350: an input device 360 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 370 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 380 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 390. The communication device 390 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0113] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 390, or installed from a storage device 380, or installed from a ROM 320. When the computer program is executed by the processing device 310, the above-mentioned functions defined in the method of the embodiment of the present application are executed. Alternatively, in other embodiments, the processing device 310 can be configured to execute the method in any other appropriate manner (e.g., by means of firmware): receiving a natural language or diagram description input by a user; generating PLC code using an artificial intelligence model fine-tuned by industrial control data, wherein the artificial intelligence model uses low-precision reasoning and multi-token prediction to optimize code generation efficiency; verifying code logic through a simulation environment, integrating a PLC simulator, automatically testing the logical correctness after generating the code, and outputting the model to the target device based on feedback optimization.
[0114] Example 4
[0115] The computer-readable medium mentioned above in this application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0116] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0117] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0118] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: receives natural language or graphic descriptions input by the user; generates PLC code using an artificial intelligence model fine-tuned by industrial control data, and the artificial intelligence model uses low-precision reasoning and multi-token prediction to optimize code generation efficiency; verifies the code logic through a simulation environment, integrates a PLC simulator, automatically tests the logical correctness after the code is generated, and outputs it to the target device based on the feedback optimization model.
[0119] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0120] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0121] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the module itself.
[0122] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof.
[0123] The program code for implementing the methods of the present application can be written in any combination of one or more programming languages. Such program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow charts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0124] In the context of the present application, a machine-readable medium can be a tangible medium that can contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0125] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0126] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0127] A computer system may include a client and a server. The client and server are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services. The server may also be a server in a distributed system or a server integrated with blockchain.
[0128] Artificial intelligence (AI) is the study of how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily encompass computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graphs.
[0129] Cloud computing refers to a technology system that provides network access to elastically scalable shared pools of physical or virtual resources. These resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on-demand in a self-service manner. Cloud computing technology provides efficient and powerful data processing capabilities for the application of technologies such as artificial intelligence and blockchain, as well as for model training.
[0130] The embodiments described above are only part of the embodiments of the present application, not all of them. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.
[0131] In the description of the embodiments of the present application, it should be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the application is usually placed when in use. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the electric vehicle or component referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0132] In the description of the embodiments of the present application, it should also be noted that, unless otherwise expressly specified or limited, the terms "disposed," "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on the specific circumstances.
[0133] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present application, or perform equivalent replacements for some of the technical features thereof. These modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the scope of protection of the claims.
Claims
1. An industrial PLC code generation system based on artificial intelligence, characterized in that: It includes input module, model optimization module, code generation module and deployment module, among which, The input module is used to receive and parse natural language, flow charts and I / O configuration tables and generate structured logical constraints; The model optimization module is used to fine-tune artificial intelligence models using data from the industrial control field, supporting low-precision reasoning and dynamic expert network load balancing; The code generation module is used to output PLC code that meets industrial standards and supports simulation verification and error correction; The deployment module is used to download the generated code to the target PLC device or integrate it into the engineering software.
2. The industrial PLC code generation system based on artificial intelligence according to claim 1 is characterized in that: It also includes a simulation verification module for testing code logic in a virtual PLC environment and providing feedback on correction suggestions.
3. The industrial PLC code generation system based on artificial intelligence according to claim 1 is characterized in that: The input module includes a receiving unit, a parsing unit and a generating unit, wherein: The receiving unit is used to receive user input, supports natural language description, process flow chart or I / O configuration table, and completes data upload through API interface or graphical interface; The parsing unit is used to perform multimodal input parsing on input data, extract key control logic from natural language using semantic segmentation technology, identify electrical component symbols and their connection relationships using CV algorithms on flow charts and schematics, perform structured mapping on I / O tables, and generate variable declaration templates; The generating unit is used to generate structured input data and uniformly encode multimodal input into JSON format, including control objectives, logical constraints and device parameters.
4. The industrial PLC code generation system based on artificial intelligence according to claim 1 is characterized in that: The code generation module includes an inference unit, a processing unit, an environment test unit and a dynamic detection unit, wherein: The reasoning unit generates structured text and ladder diagrams based on structured input data and models in parallel, and device configuration files. It dynamically allocates expert networks to process different control logics through the load balancing strategy of the artificial intelligence architecture. The processing unit is used to standardize the code, including adding standard comment templates, automatically optimizing variable naming, and performing static syntax checking; The environment testing unit is used to perform virtual environment testing, including calling the simulator to build a virtual PLC environment, injecting test cases, and recording runtime indicators; The dynamic detection unit is used to perform dynamic error detection, including logic error detection, timing error detection and safety compliance checking.
5. The artificial intelligence-based industrial PLC code generation system according to claim 4, characterized in that: Also includes, The logic error detection includes verifying program reachability through symbolic execution; The timing error detection includes comparing the deviation between the actual output and the expected timing diagram; The security compliance check includes evaluating the security level against industry standards.
6. The industrial PLC code generation system based on artificial intelligence according to claim 1 is characterized in that: The code generation module further includes an optimization unit, which is used to perform feedback iterative optimization, including back-propagating the verification results to the reinforcement learning model and updating the attention weights; Establish a correction rule base for high-frequency error types; Generates revision suggestions with error markers.
7. The artificial intelligence-based industrial PLC code generation system according to claim 1, characterized in that: The deployment module includes an adaptation unit, a packaging unit and a deployment unit, wherein: The adaptation unit is used to perform multi-platform adaptation output and convert the generated code into the target platform format: The packaging unit is used to package the project files and automatically generate supporting documents, which include hardware configuration instructions, HMI interface definition files and version control records. The deployment unit is used to perform one-click deployment, including completing program downloads by directly connecting to PLC devices via the OPC UA protocol, supporting seamless integration with the integrated development environment, and generating deployment reports.
8. An artificial intelligence-based industrial PLC code generation method, using the artificial intelligence-based industrial PLC code generation system according to claims 1-7, characterized in that: include: Receive natural language or graphic description input by the user; Generate PLC code using an artificial intelligence model fine-tuned with industrial control data, which uses low-precision reasoning and multi-token prediction to optimize code generation efficiency. Verify code logic through simulation environment, integrate PLC simulator, automatically test logic correctness after code generation, and optimize model output to target device based on feedback.
9. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a program running on the processor, and the processor executes the industrial PLC code generation method based on artificial intelligence as described in claim 8 when running the program.
10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed, the method for generating industrial PLC code based on artificial intelligence as described in claim 8 is executed.
Citation Information
Cited By
Code generation method and device, equipment and storage medium
CN121477769A
Code generation method and device, equipment and storage medium
CN121477769B
Programmable logic controller program generation method and device, equipment and storage medium
CN121613810A
Hardware configuration generation method and device, terminal equipment and readable storage medium
CN121704322A
Method for generating ladder diagram of programmable controller based on large language model
CN122018423A