Programmable logic controller integration system and method based on artificial intelligence

By integrating artificial intelligence-based systems in programmable logic controllers, including AI model library, error code detection module, code optimization module and optimal code generation module, the problem of errors prone to traditional systems when writing complex logic is solved, and higher stability and reliability are achieved.

CN120196045APending Publication Date: 2025-06-24GUANGCHENG IND TECHNOLOGY (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510352252.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

Traditional programmable logic controllers are prone to errors when writing complex logic and are difficult to detect potential problems, affecting the stability and reliability of the system.

Method used

The programmable logic controller integrated system based on artificial intelligence is adopted, including the AI ​​model library integration module, error code detection module, code optimization module, optimal code generation module and intelligent PLC system integration module. Error detection, code optimization and optimal code generation are carried out through the AI ​​model library to improve the stability and reliability of the system.

Benefits of technology

Through the integration of AI model library, it is possible to quickly locate and fix errors in the code, optimize code logic, improve code accuracy and reliability, reduce the workload of manual debugging and optimization, and improve development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120196045A_ABST
    Figure CN120196045A_ABST
Patent Text Reader

Abstract

The invention relates to the field of artificial intelligence, and discloses a programmable logic controller integration system and method based on artificial intelligence, and the method comprises the steps: collecting a PLC code sample and operation data of a PLC, integrating an A I model library of the PLC, collecting a PLC code corresponding to the PLC, recognizing an error code of the PLC code, and analyzing the error type of the error code. Generating an error prompt of the error code; optimizing the PLC code, analyzing the gain effect of optimizing the PLC code, and generating an optimization scheme of the PLC code according to the gain effect; generating a PLC code set of the PLC, analyzing the code logic of the PLC code set, verifying the operation effect of the PLC code set, and determining the optimal PLC code of the PLC code set; a user interaction interface of the PLC is constructed, and an intelligent PLC system of the PLC is integrated. According to the invention, the stability and reliability of the programmable logic controller can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and particularly to a programmable logic controller integration system and method based on artificial intelligence. Background Art

[0002] A programmable logic controller refers to an electronic device specifically designed for industrial environments, which is a digital operation controller for automation control. It uses programmable memories to store instructions for executing operation commands to control machinery or production processes. The programmable logic controller can quickly respond to input signals, timely adjust the production process, and automatically execute repetitive tasks without manual intervention, thereby improving production efficiency.

[0003] Traditional programmable logic controllers are mainly used for logic control and sequential control. Since they cannot provide automated error detection and optimization suggestions, it is easy to make mistakes when writing complex logic, and it is difficult to discover potential problems, thus affecting the stability and reliability of the system. Summary of the Invention

[0004] The present invention provides a programmable logic controller integration system and method based on artificial intelligence, and its main purpose is to improve the stability and reliability of the programmable logic controller.

[0005] To achieve the above object, a programmable logic controller integration system based on artificial intelligence provided by the present invention includes: an AI model library integration module, an error code detection module, a code optimization module, an optimal code generation module, and an intelligent PLC system integration module;

[0006] The AI model library integration module is used to collect PLC code samples and operation data of the PLC, and based on the PLC code samples and the operation data, integrate the AI model library of the PLC, wherein the AI model library includes: an error detection model, a code generation model, and a code optimization model;

[0007] The error code detection module is used to collect the PLC code corresponding to the PLC, use the error detection model to identify the error codes of the PLC code, mark the error codes to obtain marked error codes, analyze the error types of the error codes, and generate error prompts for the error codes based on the error types and the marked error codes;

[0008] The code optimization module is used to optimize the PLC code using the code optimization model based on the error prompts to obtain optimized PLC code, analyze the gain effect of the optimized PLC code, and generate an optimization plan for the PLC code according to the gain effect;

[0009] The optimal code generation module is used to obtain the code function description of the target user. Based on the code function description, it initially generates a set of PLC codes for the PLC by using the code generation model, analyzes the code logic of the PLC code set, verifies the running effect of the PLC code set according to the code logic, and determines the optimal PLC code of the PLC code set based on the running effect.

[0010] The intelligent PLC system integration module is used to construct the user interface of the PLC according to the error prompt, the optimization scheme, and the optimal PLC code, and integrate the intelligent PLC system of the PLC based on the user interface and the AI model library.

[0011] Optionally, integrating the AI model library of the PLC based on the PLC code sample and the running data includes:

[0012] Perform data conversion on the PLC code sample and the running data to obtain a standard code sample and standard running data;

[0013] Extract the sample features of the standard code sample and the data features of the standard running data;

[0014] Determine the initial AI model of the PLC;

[0015] Determine the model parameters of the initial AI model, where the model parameters include: learning rate, number of model layers, and number of neurons;

[0016] Train the initial AI model based on the model parameters, the sample features, and the data features to obtain a trained AI model;

[0017] Analyze the model performance of the trained AI model, and use the trained AI model as the AI model of the PLC according to the model performance;

[0018] Integrate the AI model into a preset AI plugin to obtain an AI model library.

[0019] Optionally, using the error detection model to identify the error code of the PLC code includes:

[0020] Extract the PLC code features of the PLC code;

[0021] Vectorize the PLC code features to obtain a code feature vector;

[0022] Extract the error probability analysis algorithm of the error detection model, and calculate the code error probability of the PLC code based on the code feature vector by using the error probability analysis algorithm.

[0023] Determine the error code of the PLC code according to the code error probability.

[0024] Optionally, generating an error prompt for the error code based on the error type and the marked error code includes:

[0025] Identify the location information of the error code according to the marked error code;

[0026] Generate descriptive error information for the error code based on the error type;

[0027] Construct a correction code database for the error code, and match the correction opinion of the error code in the correction code database according to the descriptive error information;

[0028] Generate an error prompt for the error code according to the error type, the location information, the descriptive error information, and the correction opinion.

[0029] Optionally, optimizing the PLC code by using the code optimization model based on the error prompt to obtain an optimized PLC code includes:

[0030] Determine the optimized target code of the PLC code according to the error prompt;

[0031] Calculate the query matrix, key matrix, and value matrix of the optimized target code according to the code feature vector corresponding to the PLC code;

[0032] Determine the key dimension of the key matrix;

[0033] Based on the key dimension, the query matrix, the key matrix, and the value matrix, calculate the optimization matrix of the optimized target code by using the code optimization algorithm corresponding to the code optimization model;

[0034] Optimize the optimized target code according to the optimization matrix to obtain an optimized PLC code.

[0035] Optionally, analyzing the gain effect of the optimized PLC code includes:

[0036] Define the performance index of the optimized PLC code;

[0037] According to the performance index, test the performance of the optimized code of the optimized PLC code and the performance of the code before optimization corresponding to the optimized PLC code respectively;

[0038] Calculate the gain coefficient of the optimized PLC code according to the performance of the optimized code and the performance of the code before optimization.

[0039] Determine the gain effect of the optimized PLC code according to the gain coefficient.

[0040] Optionally, based on the code function description, initially generate a set of PLC codes for the PLC by using the code generation model, including:

[0041] Convert the code function description into code features to be generated;

[0042] Define the code generation task of the code generation model according to the code features to be generated;

[0043] Generate candidate codes for the PLC by using the code generation model according to the code generation task;

[0044] Detect the code quality of the candidate codes according to the code function description;

[0045] Preliminarily screen out a set of PLC codes from the candidate codes according to the code quality.

[0046] Optionally, analyze the code logic of the set of PLC codes, including:

[0047] Identify the conditional statements and loop statements in the set of PLC codes;

[0048] Determine the running process of the set of PLC codes according to the conditional statements and the loop statements;

[0049] Identify the running algorithms in the set of PLC codes, and analyze the algorithm parameters and calculation steps of the running algorithms;

[0050] Determine the algorithm logic of the set of PLC codes according to the algorithm parameters and the calculation steps;

[0051] Determine the code logic of the set of PLC codes according to the running process and the algorithm logic.

[0052] Optionally, construct a user interface for the PLC according to the error prompt, the optimization scheme, and the optimal PLC code, including:

[0053] Determine the marking method and prompt method of the error prompt;

[0054] Determine the form of presenting the optimization scheme;

[0055] Clarify the input method of the code function description corresponding to the optimal PLC code and the output method of the optimal PLC code;

[0056] Construct the user interaction interface of the PLC according to the marking method, the prompting method, the scheme presentation form, the input method, and the output method.

[0057] A programmable logic controller integration method based on artificial intelligence, characterized in that the method includes:

[0058] Collect the PLC code samples and operation data of the PLC, and integrate the AI model library of the PLC based on the PLC code samples and the operation data, wherein the AI model library includes: an error detection model, a code generation model, and a code optimization model;

[0059] Collect the PLC code corresponding to the PLC, use the error detection model to identify the error codes in the PLC code, mark the error codes to obtain marked error codes, analyze the error types of the error codes, and generate error prompts for the error codes based on the error types and the marked error codes;

[0060] Based on the error prompts, use the code optimization model to optimize the PLC code to obtain optimized PLC code, analyze the gain effect of the optimized PLC code, and generate an optimization scheme for the PLC code according to the gain effect;

[0061] Obtain the code function description of the target user, and based on the code function description, use the code generation model to initially generate a set of PLC codes for the PLC, analyze the code logic of the PLC code set, verify the operation effect of the PLC code set according to the code logic, and determine the optimal PLC code of the PLC code set based on the operation effect;

[0062] Construct the user interaction interface of the PLC according to the error prompts, the optimization scheme, and the optimal PLC code, and integrate the intelligent PLC system of the PLC based on the user interaction interface and the AI model library.

[0063] In the embodiments of the present invention, by integrating the AI model library of the PLC based on the PLC code sample and the operation data, the PLC program can be written and modified more quickly, reducing the time required for programming; optionally, in the embodiments of the present invention, by using the error detection model to identify the error codes of the PLC code, potential problems can be discovered in advance to avoid the program crashing or producing error results during operation; in the embodiments of the present invention, by generating error prompts for the error codes based on the error type and the marked error codes, the problem can be quickly located and relevant error information such as error type, error location, and repair suggestions can be provided; in the embodiments of the present invention, by optimizing the PLC code using the code optimization model based on the error prompt, the optimized PLC code can better retain the features of the point cloud, reduce noise and errors, and at the same time reduce the workload of manual debugging and optimization, improving the development efficiency; in the embodiments of the present invention, by determining the optimal PLC code of the PLC code set based on the operation effect, it can not only meet the basic needs of users, but also show excellent performance and reliability in practical applications. Finally, in the embodiments of the present invention, by constructing the user interface of the PLC according to the error prompt, the optimization scheme, and the optimal PLC code, the errors in the code during the writing process can be detected in real time, corresponding prompts and suggestions can be given, and corresponding codes can be generated according to the needs of the target users, thereby improving the accuracy of PLC code writing and reducing the risk of code operation. Therefore, the stability and reliability of the programmable logic controller are improved. Description of the Drawings

[0064] Figure 1 It is a functional module diagram of an artificial intelligence-based programmable logic controller integration system provided by an embodiment of the present invention;

[0065] Figure 2 It is a schematic flowchart of an artificial intelligence-based programmable logic controller integration method provided by an embodiment of the present invention;

[0066] The realization, functional characteristics, and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. Detailed Embodiments

[0067] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0068] In addition, the step timings in the following method embodiments are only examples and not strictly limited.

[0069] In fact, the server device deployed by the programmable logic controller integration system based on artificial intelligence may be composed of one or more devices. The programmable logic controller integration system based on artificial intelligence described above can be implemented as: a service instance, a virtual machine, or a hardware device. For example, the programmable logic controller integration system based on artificial intelligence can be implemented as a service instance deployed on one or more devices in a cloud node. Simply put, the programmable logic controller integration system based on artificial intelligence can be understood as a piece of software deployed on a cloud node, used to provide services for programmable logic controller integration based on artificial intelligence to each client. Alternatively, the programmable logic controller integration system based on artificial intelligence can also be implemented as a virtual machine deployed on one or more devices in a cloud node. An application software for managing each client is installed in the virtual machine. Or, the programmable logic controller integration system based on artificial intelligence can also be implemented as a server composed of many identical or different types of hardware devices, with one or more hardware devices set to provide services for programmable logic controller integration based on artificial intelligence to each client.

[0070] In terms of implementation form, the programmable logic controller integration system based on artificial intelligence and the client adapt to each other. That is, if the programmable logic controller integration system based on artificial intelligence is an application installed on a cloud service platform, then the client is a client that establishes a communication connection with this application; or if the programmable logic controller integration system based on artificial intelligence is implemented as a website, then the client is implemented as a web page; or if the programmable logic controller integration system based on artificial intelligence is implemented as a cloud service platform, then the client is implemented as a small program in an instant messaging application.

[0071] Refer to Figure 1 As shown, it is a functional module diagram of a programmable logic controller integration system based on artificial intelligence provided by an embodiment of the present invention.

[0072] The programmable logic controller integration system 100 based on artificial intelligence described in the present invention can be set in a cloud server. In terms of implementation form, it can be used as one or more service devices, or can be installed as an application on the cloud (such as a server for programmable logic controller integration based on artificial intelligence, a server cluster, etc.), or can also be developed into a website. According to the functions achieved, the programmable logic controller integration system 100 based on artificial intelligence includes an AI model library integration module 101, an error code detection module 102, a code optimization module 103, an optimal code generation module 104, and an intelligent PLC system integration module 105.

[0073] In the embodiments of the present invention, in the tracking based on the integration of an artificial intelligence-based programmable logic controller, each of the above modules can be independently implemented and called with other modules. Here, the call can be understood as that a certain module can be connected to multiple modules of another type and provide corresponding services for the multiple modules it is connected to. In the artificial intelligence-based programmable logic controller integration system provided by the embodiments of the present invention, without modifying the program code, the applicable range of the artificial intelligence-based programmable logic controller integration architecture can be adjusted in the form of adding modules and directly calling, so as to achieve cluster-level horizontal expansion, so as to achieve the purpose of quickly and flexibly expanding the artificial intelligence-based programmable logic controller integration system. In practical applications, the above modules can be set in the same device or different devices, or can be set in virtual devices, such as service instances in a cloud server.

[0074] The following will respectively describe each component and the specific working process of the artificial intelligence-based programmable logic controller integration system in combination with specific embodiments.

[0075] The AI model library integration module 101 is used to collect the PLC code samples and operation data of the PLC, and integrate the AI model library of the PLC based on the PLC code samples and the operation data, wherein the AI model library includes: an error detection model, a code generation model, and a code optimization model.

[0076] By collecting the PLC code samples and operation data of the PLC in the embodiments of the present invention, data can be provided for the continuous learning and optimization of subsequent models. Among them, the PLC (Programmable Logic Controller) refers to a programmable logic controller, which is an industrial automation electronic device used to control machinery or production processes. The PLC code sample refers to the actual PLC program code segment or complete code file used to train and test the AI model. The operation data refers to various data generated during the actual operation of the PLC, including input / output signals, device status, operation logs, resource usage, etc.

[0077] Optionally, the PLC code samples and operation data of the PLC can be collected through blockchain technology, such as using blockchain technology to collect the code sample set and operation data set of the PLC, verifying the integrity of the code samples in the code sample set and the integrity of the operation data in the operation data set, and filtering out the PLC code samples in the code sample set and the operation data in the operation data set based on the code sample integrity and the data integrity.

[0078] Furthermore, in the embodiments of the present invention, by integrating the AI model library of the PLC based on the PLC code sample and the operation data, the PLC program can be written and modified more quickly, reducing the time required for programming. Among them, the AI model library refers to a collection containing multiple AI models, and these models are specifically used to solve specific tasks related to the PLC. The error detection model refers to a model specifically used to analyze PLC code, identify errors (such as syntax errors and logical errors) in the code, and provide repair suggestions. The code generation model refers to a model specifically used to generate corresponding PLC code according to the function description. The code optimization model refers to a model specifically used to analyze PLC code, provide optimization suggestions (such as reducing memory occupancy and improving execution efficiency), and generate optimized code.

[0079] As an embodiment of the present invention, the integrating the AI model library of the PLC based on the PLC code sample and the operation data includes:

[0080] Perform data conversion on the PLC code sample and the operation data to obtain a standard code sample and standard operation data;

[0081] Extract the sample features of the standard code sample and the data features of the standard operation data;

[0082] Determine the initial AI model of the PLC;

[0083] Determine the model parameters of the initial AI model, where the model parameters include: learning rate, number of model layers, and number of neurons;

[0084] Train the initial AI model based on the model parameters, the sample features, and the data features to obtain a trained AI model;

[0085] Analyze the model performance of the trained AI model, and according to the model performance, use the trained AI model as the AI model of the PLC;

[0086] Integrate the AI model into a preset AI plugin to obtain an AI model library.

[0087] Among them, the standard code sample refers to the PLC code sample after data cleaning, format unification, and annotation processing. The standard operation data refers to the PLC operation data after data cleaning, format unification, and annotation processing. The sample feature refers to the key attributes or indicators extracted from the standard code sample that can characterize the code characteristics and rules. The data feature refers to the key attributes or indicators extracted from the standard operation data that can characterize the system operation state and rules. The initial AI model refers to a basic model selected and designed at the initial stage of building the AI model library, such as LSTM, Transformer, or BERT, etc. The model parameter refers to the variable that the AI model needs to learn and optimize during the training process. The learning rate refers to the hyperparameter used to control the update step size of the model parameters. The number of model layers refers to the number of layers included in the model, which is used to extract features from the input data and gradually generate the output. The number of neurons refers to the number of neurons (or nodes) included in each layer of the model neural network. The model performance refers to the performance and ability of the trained AI model on a specific task, reflecting the accuracy, generalization ability, and efficiency of the model on the training data, validation data, and test data. The AI model refers to an intelligent model that can analyze and process PLC codes by learning the rules and patterns in the data. The preset AI plugin refers to a software module that is pre-designed and integrated into the PLC programming environment.

[0088] Exemplarily, the data conversion of the PLC code sample and the operation data includes:

[0089] Identifying the invalid samples of the PLC code sample and the invalid data of the operation data;

[0090] Deleting the invalid samples and the invalid data to obtain the cleaned code sample and the cleaned operation data;

[0091] Standardizing the cleaned code sample and the cleaned operation data to obtain the standard code sample and the standard operation data.

[0092] Optionally, the sample features of the standard code sample and the data features of the standard operation data can be extracted through a multi-modal learning framework. For example, by combining the structural features of the standard code sample and the dynamic features of the standard operation data, different sources of sample features and data features can be extracted through the multi-modal learning framework.

[0093] Optionally, the model parameters of the initial AI model can construct the parameter space of the initial AI model through the Gaussian process, and determine the model parameters of the initial AI model according to the parameter space.

[0094] Exemplarily, the performance of the model is 0.9, and the preset model performance standard is 0.8. When the model performance is greater than the preset model performance standard, the trained AI model is used as the AI model of the PLC.

[0095] The error code detection module 102 is configured to collect the PLC code corresponding to the PLC, identify the error code of the PLC code by using the error detection model, mark the error code to obtain the marked error code, analyze the error type of the error code, and generate an error prompt for the error code based on the error type and the marked error code.

[0096] In an embodiment of the present invention, collecting the PLC code corresponding to the PLC can provide data for subsequent code analysis. Wherein, the PLC code refers to the code written using the PLC.

[0097] In an embodiment of the present invention, identifying the error code of the PLC code by using the error detection model can discover potential problems in advance and avoid the program from crashing or producing incorrect results during operation. Wherein, the error code refers to the error part existing in the PLC code, and these errors may include syntax errors, logical errors, runtime errors, or API usage errors, etc.

[0098] As an embodiment of the present invention, the identifying the error code of the PLC code by using the error detection model includes:

[0099] Extracting the PLC code features of the PLC code;

[0100] Vectorizing the PLC code features to obtain a code feature vector;

[0101] Extracting the error probability analysis algorithm of the error detection model, and based on the code feature vector, calculating the code error probability of the PLC code by using the error probability analysis algorithm, where the error probability analysis algorithm includes:

[0102]

[0103] Where θ represents the code error probability, e represents the exponential function with base e, q represents the weight vector corresponding to the code feature vector, q T represents the transpose of the weight vector, d represents the code feature vector, and p represents the bias term;

[0104] Determining the error code of the PLC code according to the code error probability.

[0105] Among them, the PLC code feature refers to the attributes or patterns extracted from the code that can reflect its syntax, semantics, structure, and context information. The code feature vector refers to the vector representation of the code features (such as syntax, semantics, statistical information, etc.) converted into numerical form. The error probability analysis algorithm refers to a mathematical algorithm for calculating the code error probability. The code error probability refers to the possibility that a certain piece of code has an error calculated by the error probability analysis algorithm. The weight vector refers to the degree of contribution of each feature to the error probability. The bias term refers to the role of adjusting the baseline of the prediction result in the model and is a constant term in linear models (such as linear regression, logistic regression).

[0106] Optionally, for the vectorization of the PLC code features, the code feature vector can be obtained through the bag-of-words model. For example, according to the PLC code features, the PLC code is segmented into words, a bag-of-words for the PLC code is constructed based on the words, and the PLC code features are quantified based on the bag-of-words.

[0107] Exemplarily, there is a code error probability of 80%, and the preset code error probability threshold is 50%. When the code error probability is greater than the code error probability threshold, the PLC code is classified as an error code.

[0108] In the embodiment of the present invention, by marking the error code, the marked error code can quickly locate and fix problems in the code, thereby quickly discovering potential problems and reducing defects in the code. Among them, the marked error code refers to the part in the code that clearly identifies the existence of an error, and the error code is distinguished from the normal code through annotations, tags, or other visualization methods.

[0109] Optionally, for the marking of the error code, the marked error code can be marked by the color marking method.

[0110] In the embodiment of the present invention, by analyzing the error types of the error code, high-frequency error patterns in the code can be discovered, thereby optimizing the code quality. Among them, the error type refers to the classification of specific problems or defects existing in the code, such as syntax errors, logical errors, runtime errors, etc.

[0111] Optionally, the error types of the error code can be analyzed through deep learning models, such as LSTM, Transformer, CodeBERT, etc.

[0112] In the embodiments of the present invention, by generating an error prompt for the error code based on the error type and the marked error code, the problem can be quickly located, and relevant error information such as the error type, error location, and repair suggestions can be provided. Among them, the error prompt refers to the detailed information generated by the system to describe the error type, error location, and repair suggestions after an error is detected in the code.

[0113] As an embodiment of the present invention, the generating the error prompt for the error code based on the error type and the marked error code includes:

[0114] Identify the location information of the error code according to the marked error code;

[0115] Generate descriptive error information for the error code based on the error type;

[0116] Construct a correction code database for the error code, and match the correction opinions for the error code in the correction code database according to the descriptive error information;

[0117] Generate an error prompt for the error code according to the error type, the location information, the descriptive error information, and the correction opinions.

[0118] Among them, the location information refers to the specific location where the error occurs in the code, usually represented in the form of line numbers and column numbers, such as the third line and the second column. The descriptive error information refers to a detailed description of the error in the code, including the nature and cause of the error. The correction code database refers to a structured data set that stores common errors and their corresponding correction codes. The correction opinion refers to the specific repair suggestions provided for the error detected in the code.

[0119] Optionally, the descriptive error information of the error code can be generated by converting the code into a vector representation using a code embedding model (such as CodeBERT, CodeT5).

[0120] Optionally, the correction code database of the error code can be constructed by a sequence-to-sequence model, such as using the encoder-decoder architecture corresponding to the sequence-to-sequence model to learn the mapping relationship between the error code and the correction code, and constructing the correction code database of the error code according to the mapping relationship.

[0121] The code optimization module 103 is used to optimize the PLC code by using the code optimization model based on the error prompt to obtain an optimized PLC code, analyze the gain effect of the optimized PLC code, and generate an optimization plan for the PLC code according to the gain effect.

[0122] In an embodiment of the present invention, based on the error prompt, the PLC code is optimized by using the code optimization model, and the optimized PLC code obtained can better retain the features of the point cloud, reduce noise and errors, and at the same time reduce the workload of manual debugging and optimization, improving the development efficiency. Among them, the optimized PLC code refers to a code version that is improved in terms of performance, readability, maintainability, resource utilization, etc. by analyzing, improving, and reconstructing the original PLC code.

[0123] As an embodiment of the present invention, the method of optimizing the PLC code by using the code optimization model based on the error prompt to obtain the optimized PLC code includes:

[0124] Determine the optimized target code of the PLC code according to the error prompt;

[0125] Calculate the query matrix, key matrix, and value matrix of the optimized target code according to the code feature vector corresponding to the PLC code;

[0126] Determine the key dimension of the key matrix;

[0127] Based on the key dimension, the query matrix, the key matrix, and the value matrix, use the code optimization algorithm corresponding to the code optimization model to calculate the optimization matrix of the optimized target code, where the code optimization algorithm includes:

[0128]

[0129] Where Y represents the optimization matrix, softmax represents the softmax activation function, C represents the query matrix, R represents the key matrix, R T represents the transpose of the key matrix, Z represents the value matrix, and w R represents the key dimension;

[0130] Optimize the optimized target code according to the optimization matrix to obtain the optimized PLC code.

[0131] Among them, the optimized target code refers to a specific code segment that is selected and needs to be improved during the code optimization process. The query matrix refers to the information that the code features corresponding to the optimized target code want to query. The key matrix refers to the information contained in the code features corresponding to the optimized target code. The value matrix refers to the value of the code features corresponding to the optimized target code. The key dimension refers to the dimension of each key vector in the key matrix. The softmax activation function refers to an activation function that converts a real number vector into a probability distribution. The optimization matrix refers to a matrix output by the code optimization model, which contains the improved feature representation.

[0132] It should be noted that in this application, the optimized matrix calculated by the above formula can guide code optimization, such as replacing inefficient algorithms, parallel processing, or using efficient data structures, thereby significantly reducing the running time of the code. In particular, it should be noted that in this formula, the activation function softmax is used to convert the result into a probability distribution, ensuring that the sum of all probabilities is 1. Dividing the result of CR T by the square root of the dimension w R of the key matrix R ensures numerical stability when the dot product is large and avoids the problem of vanishing gradients.

[0133] Optionally, the query matrix, key matrix, and value matrix of the optimized target code can be calculated by a reinforcement learning model. For example, the weights of the query matrix, key matrix, and value matrix of the code feature vector are determined by using the reinforcement learning model, and the products of the code feature vector and the weights of the query matrix, key matrix, and value matrix are calculated respectively, so as to obtain the query matrix, key matrix, and value matrix.

[0134] By analyzing the gain effect of the optimized PLC code in the embodiments of the present invention, the aspects with significant improvement in code performance can be determined, ensuring that the optimized code can better meet the actual application requirements. Among them, the gain effect refers to the improvements and enhancements achieved in terms of performance, resource occupancy, code quality, function, energy consumption, compatibility, robustness, and development efficiency after code optimization.

[0135] As an embodiment of the present invention, the analysis of the gain effect of the optimized PLC code includes:

[0136] Defining the performance indicators of the optimized PLC code;

[0137] According to the performance indicators, the performance of the optimized code of the optimized PLC code and the performance of the pre-optimization code of the PLC code corresponding to the optimized PLC code are respectively tested;

[0138] According to the performance of the optimized code and the performance of the pre-optimization code, the gain coefficient of the optimized PLC code is calculated;

[0139] According to the gain coefficient, the gain effect of the optimized PLC code is determined.

[0140] Among them, the performance indicators refer to a series of quantitative parameters used to measure the performance of the code during operation, such as execution time, memory usage, CPU utilization, code readability, maintainability, error rate, etc. The optimized code performance refers to the performance parameters shown by the code in multiple dimensions after the optimization process. The pre-optimization code performance refers to the performance of the code in each performance evaluation dimension before the optimization operation. The gain coefficient is a quantitative indicator used to measure the degree of improvement in code performance by the optimization operation.

[0141] Exemplarily, if the optimized code performance is 100 and the pre-optimization code performance is 80, then the gain coefficient is 25%.

[0142] By generating an optimization plan for the PLC code according to the gain effect, the embodiments of the present invention can significantly improve the performance, resource utilization rate, functionality, and maintainability of the PLC code, thereby better meeting the actual application requirements. Among them, the optimization plan refers to a series of improvement measures and specific implementation steps proposed for the problems existing in the PLC code in terms of performance, resource occupancy, code quality, function, energy consumption, compatibility, robustness, and development efficiency.

[0143] Optionally, the optimization plan for the PLC code can be generated by a multi-objective optimization algorithm. For example, by simultaneously optimizing multiple performance indicators (such as running time, memory occupancy, algorithm accuracy) through NSGA-II, an optimization plan for the PLC code can be obtained.

[0144] The optimal code generation module 104 is used to obtain the code function description of the target user, based on the code function description, initially generate a set of PLC codes of the PLC using the code generation model, analyze the code logic of the set of PLC codes, verify the running effect of the set of PLC codes according to the code logic, and determine the optimal PLC code of the set of PLC codes based on the running effect.

[0145] By obtaining the code function description of the target user in the embodiments of the present invention, a target can be provided for subsequent code generation. Among them, the code function description refers to a detailed description of the functions to be implemented by the code, performance requirements, input / output formats, usage scenarios, etc.

[0146] By initially generating a set of PLC codes of the PLC using the code generation model based on the code function description in the embodiments of the present invention, candidate codes can be quickly generated, reducing the workload of the development team and supporting rapid iterative development of the code. Among them, the set of PLC codes refers to a group of candidate PLC codes generated using a code optimization model based on the code function description of the target user, and these code sets include multiple code versions that implement the same or similar functions.

[0147] As an embodiment of the present invention, based on the code function description, initially generating a PLC code set for the PLC by using the code generation model, including:

[0148] Converting the code function description into code features to be generated;

[0149] Defining a code generation task for the code generation model according to the code features to be generated;

[0150] Generating candidate codes for the PLC by using the code generation model according to the code generation task;

[0151] Detecting the code quality of the candidate codes according to the code function description;

[0152] Preliminarily screening out a PLC code set from the candidate codes according to the code quality.

[0153] Among them, the code features to be generated refer to the key attributes and constraint conditions extracted from the code function description and used to guide the code generation model to generate target codes. The code generation task refers to the specific goal that the code generation model needs to complete based on the code features to be generated. The candidate codes refer to the code snippets or complete code files generated by the code generation model according to the input task description or features. The code quality refers to the comprehensive performance of the code in terms of functionality, correctness, readability, maintainability, robustness, etc.

[0154] Optionally, the code generation task of the code generation model can be defined by natural language description, such as Prompt Engineering, Few-shot Learning, etc.

[0155] Exemplarily, if the quality score of the code quality is 90 points and the preset code quality standard is 80 points, then the candidate codes with code quality greater than the preset code quality standard are classified into the PLC code set.

[0156] The embodiment of the present invention can identify potential security vulnerabilities by analyzing the code logic of the PLC code set, reducing runtime errors and crashes. Among them, the code logic refers to the algorithms, processes, and control structures in the code that implement specific functions.

[0157] As an embodiment of the present invention, the analyzing the code logic of the PLC code set includes:

[0158] Identifying the conditional statements and loop statements in the PLC code set;

[0159] Determining the running process of the PLC code set according to the conditional statements and the loop statements;

[0160] Identify the running algorithm of the PLC code set, and analyze the algorithm parameters and calculation steps of the running algorithm;

[0161] Determine the algorithm logic of the PLC code set according to the algorithm parameters and the calculation steps;

[0162] Determine the code logic of the PLC code set according to the running process and the algorithm logic.

[0163] Among them, the conditional statement refers to a statement used to determine the code execution path according to specific conditions, such as if statement, else statement, Switch statement, etc. The loop statement refers to a statement used to repeatedly execute a certain section of code, such as for statement, while statement, etc. The running process refers to the execution order and logical path of the code during operation. The running algorithm refers to the core algorithm or mathematical model that realizes specific functions in the code. The algorithm parameters refer to the external input values required during the operation of the algorithm, and these parameters are used to control the behavior of the algorithm, adjust the performance of the algorithm, or affect the output result of the algorithm. The calculation steps refer to the specific operations and calculation processes experienced by the algorithm during execution. The algorithm logic refers to the calculation rules and processes followed by the algorithm during execution.

[0164] Optionally, the running process of the PLC code set can be determined through static code analysis. For example, according to the conditional statement and the loop statement, use static code analysis to analyze the logical path of the PLC code set, and determine the running process of the PLC code set according to the logical path.

[0165] Optionally, the algorithm parameters and calculation steps of the running algorithm can be analyzed through mathematical modeling and simulation. For example, analyze the algorithm principle of the running algorithm, and verify the calculation steps and algorithm parameters of the running algorithm through mathematical modeling and simulation according to the algorithm principle.

[0166] In the embodiment of the present invention, by verifying the running effect of the PLC code set according to the code logic, it can be ensured that the code set can run stably on different point cloud data sets and will not go wrong due to data changes. Among them, the running effect refers to various performance and functional manifestations shown after the execution of the PLC code set, such as stability, accuracy, running speed, etc.

[0167] Optionally, the running effect of the PLC code set can be verified through data set diversity testing. For example, use a variety of different point cloud data sets to test the running effect of the code.

[0168] In an embodiment of the present invention, determining the optimal PLC code of the PLC code set based on the operation effect can not only meet the basic needs of users, but also exhibit excellent performance and reliability in practical applications. Among them, the optimal PLC code refers to the PLC code with the best operation effect in the PLC code set.

[0169] Optionally, the optimal PLC code of the PLC code set can be selected by comparing the operation effects of the PLC code set, and the PLC code with the best operation effect in the PLC code set is selected as the optimal PLC code.

[0170] The intelligent PLC system integration module 105 is used to construct the user interface of the PLC according to the error prompt, the optimization scheme, and the optimal PLC code, and integrate the intelligent PLC system of the PLC based on the user interface and the AI model library.

[0171] In an embodiment of the present invention, by constructing the user interface of the PLC according to the error prompt, the optimization scheme, and the optimal PLC code, errors in the code during the writing process can be detected in real time, corresponding prompts and suggestions can be given, and corresponding code can be generated according to the needs of the target user, thereby improving the accuracy of PLC code writing and reducing the risk of code operation. Among them, the user interface refers to an interface that allows users to input commands, configure parameters, start processing flows, and view processing results in an intuitive manner.

[0172] As an embodiment of the present invention, constructing the user interface of the PLC according to the error prompt, the optimization scheme, and the optimal PLC code includes:

[0173] Determine the marking method and prompt method of the error prompt;

[0174] Determine the form of presenting the optimization scheme;

[0175] Clarify the input method of the code function description corresponding to the optimal PLC code and the output method of the optimal PLC code;

[0176] Construct the user interface of the PLC according to the marking method, the prompt method, the form of presenting the scheme, the input method, and the output method.

[0177] Among them, the marking method refers to the method for indicating information of error codes, such as color marking, graphic marking, etc. The prompting method refers to the method for conveying information to users, guiding operations, or providing assistance, such as text prompts, window prompts, annotation prompts, etc. The form of presenting the solution refers to the method for presenting the optimization solution intuitively and understandably, such as text form, chart form, etc. The input method refers to the method for inputting the description of the code function, such as input window, interface selection input, etc. The output method refers to the presentation method of the optimal PLC code generated according to the description of the code function, such as window output, text output, etc.

[0178] In an embodiment of the present invention, through the user interaction interface and the AI model library, the intelligent PLC system integrating the PLC can provide real-time code suggestions and optimizations, accelerating the programming process, reducing potential logic errors and vulnerabilities, thereby improving the stability and security of the system.

[0179] In an embodiment of the present invention, through the PLC code samples and the operation data, the AI model library integrating the PLC can write and modify PLC programs faster, reducing the time required for programming; optionally, in an embodiment of the present invention, by using the error detection model to identify the error codes of the PLC code, potential problems can be discovered in advance to avoid the program crashing or producing error results during operation; in an embodiment of the present invention, through the error type and the marked error codes, the error prompt for the error codes can be generated to quickly locate the problem and provide relevant error information, such as error type, error location, and repair suggestions; in an embodiment of the present invention, through the error prompt, using the code optimization model to optimize the PLC code to obtain the optimized PLC code can better retain the features of the point cloud, reduce noise and errors, while reducing the workload of manual debugging and optimization, improving the development efficiency; in an embodiment of the present invention, through the operation effect, determining the optimal PLC code of the PLC code set can not only meet the basic needs of users, but also show excellent performance and reliability in practical applications. Finally, in an embodiment of the present invention, by constructing the user interaction interface of the PLC according to the error prompt, the optimization solution, and the optimal PLC code, the errors in the code during the writing process can be detected in real time, and corresponding prompts and suggestions can be given, and corresponding codes can also be generated according to the needs of the target users, thereby improving the accuracy of PLC code writing and reducing the risk of code operation. Therefore, the present invention can improve the stability and reliability of the programmable logic controller.

[0180] As Figure 2 shown, it is a schematic flowchart of a method for integrating an artificial intelligence-based programmable logic controller provided by an embodiment of the present invention. In this embodiment, the method for integrating an artificial intelligence-based programmable logic controller includes:

[0181] Collect the PLC code samples and operation data of the PLC. Based on the PLC code samples and the operation data, integrate the AI model library of the PLC, where the AI model library includes: an error detection model, a code generation model, and a code optimization model;

[0182] Collect the PLC code corresponding to the PLC. Use the error detection model to identify the error codes in the PLC code, mark the error codes to obtain marked error codes, analyze the error types of the error codes, and generate error prompts for the error codes based on the error types and the marked error codes;

[0183] Based on the error prompts, use the code optimization model to optimize the PLC code to obtain optimized PLC code, analyze the gain effect of the optimized PLC code, and generate an optimization plan for the PLC code according to the gain effect;

[0184] Obtain the code function description of the target user. Based on the code function description, use the code generation model to initially generate a set of PLC codes for the PLC, analyze the code logic of the set of PLC codes, verify the operation effect of the set of PLC codes according to the code logic, and determine the optimal PLC code in the set of PLC codes based on the operation effect;

[0185] Construct a user interface for the PLC according to the error prompts, the optimization plan, and the optimal PLC code, and integrate an intelligent PLC system for the PLC based on the user interface and the AI model library.

[0186] In several embodiments provided by the present invention, it should be understood that the provided systems and methods can be implemented in other ways. For example, the system embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.

[0187] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional modules.

[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A programmable logic controller integrated system based on artificial intelligence, characterized in that: The system's AI-based programmable logic controller integration includes: The AI ​​model library integration module is used to collect PLC code samples and operation data of the PLC, and integrate the AI ​​model library of the PLC based on the PLC code samples and the operation data, wherein the AI ​​model library includes: an error detection model, a code generation model, and a code optimization model; The error code detection module is used to collect the PLC code corresponding to the PLC, identify the error code of the PLC code using the error detection model, mark the error code to obtain a marked error code, analyze the error type of the error code, and generate an error prompt for the error code based on the error type and the marked error code; The code optimization module is used to optimize the PLC code based on the error prompt using the code optimization model to obtain an optimized PLC code, analyze the gain effect of the optimized PLC code, and generate an optimization solution for the PLC code according to the gain effect; The optimal code generation module is used to obtain a code function description of a target user, preliminarily generate a PLC code set of a PLC based on the code function description using the code generation model, analyze the code logic of the PLC code set, verify the operation effect of the PLC code set according to the code logic, and determine the optimal PLC code of the PLC code set based on the operation effect; The intelligent PLC system integration module is used to build a user interaction interface of the PLC according to the error prompt, the optimization plan and the optimal PLC code, and integrate the intelligent PLC system of the PLC based on the user interaction interface and the AI ​​model library.

2. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 1, characterized in that: The AI ​​model library of the PLC is integrated based on the PLC code sample and the operation data, including: Performing data conversion on the PLC code sample and the operation data to obtain a standard code sample and standard operation data; Extracting sample features of the standard code sample and data features of the standard operation data; Determining an initial AI model of the PLC; Determine the model parameters of the initial AI model, wherein the model parameters include: learning rate, number of model layers, and number of neurons; Based on the model parameters, the sample characteristics, and the data characteristics, the initial AI model is trained to obtain a training AI model; Analyze the model performance of the training AI model, and use the training AI model as the AI ​​model of the PLC according to the model performance; Integrate the AI ​​model into a preset AI plug-in to obtain an AI model library.

3. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 1, characterized in that: The step of using the error detection model to identify the error code of the PLC code includes: extracting PLC code features of the PLC code; Vectorizing the PLC code feature to obtain a code feature vector; Extracting the error probability analysis algorithm of the error detection model, and calculating the code error probability of the PLC code based on the code feature vector using the error probability analysis algorithm; An error code of the PLC code is determined according to the code error probability.

4. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 1, characterized in that: The generating an error prompt of the error code based on the error type and the marked error code includes: According to the marked error code, identifying the position information of the error code; Based on the error type, generate descriptive error information of the error code; Building a correction code database for the error code, and matching correction suggestions for the error code in the correction code database according to the descriptive error information; An error prompt for the error code is generated according to the error type, the location information, the descriptive error information and the correction suggestion.

5. The programmable logic controller integrated system based on artificial intelligence according to claim 1, characterized in that: The step of optimizing the PLC code based on the error prompt using the code optimization model to obtain an optimized PLC code includes: According to the error prompt, determining the optimized target code of the PLC code; Calculate the query matrix, key matrix and value matrix of the optimized target code according to the code feature vector corresponding to the PLC code; determining a bond dimension of the bond matrix; Based on the key dimension, the query matrix, the key matrix and the value matrix, using the code optimization algorithm corresponding to the code optimization model, calculating the optimization matrix of the optimized target code; According to the optimization matrix, the optimization target code is optimized to obtain an optimized PLC code.

6. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 1, characterized in that: The analyzing the gain effect of the optimized PLC code includes: Defining performance indicators of the optimized PLC code; According to the performance index, respectively testing the optimized code performance of the optimized PLC code and the pre-optimized code performance of the PLC code corresponding to the optimized PLC code; Calculating a gain coefficient of the optimized PLC code according to the optimized code performance and the optimized code performance; The gain effect of the optimized PLC code is determined according to the gain coefficient.

7. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 1, characterized in that: The method of preliminarily generating a PLC code set of a PLC by using the code generation model based on the code function description includes: Converting the code function description into code features to be generated; Defining a code generation task of the code generation model according to the features of the code to be generated; According to the code generation task, using the code generation model, generating candidate codes for the PLC; According to the code function description, detecting the code quality of the candidate code; According to the code quality, a PLC code set is preliminarily screened out from the candidate codes.

8. The programmable logic controller integrated system based on artificial intelligence as claimed in claim 7, characterized in that: The analyzing the code logic of the PLC code set includes: Identifying conditional statements and loop statements of the PLC code set; Determine the operation flow of the PLC code set according to the conditional statement and the loop statement; Identifying an operating algorithm of the PLC code set, and analyzing algorithm parameters and calculation steps of the operating algorithm; Determining the algorithm logic of the PLC code set according to the algorithm parameters and the calculation steps; According to the operation process and the algorithm logic, the code logic of the PLC code set is determined.

9. The programmable logic controller integrated system based on artificial intelligence according to claim 1, characterized in that: The step of constructing the user interaction interface of the PLC according to the error prompt, the optimization scheme and the optimal PLC code includes: Determine the marking method and prompting method of the error prompt; Determine the solution presentation form of the optimization solution; Specifying the input method of the code function description corresponding to the optimal PLC code and the output method of the optimal PLC code; A user interaction interface of the PLC is constructed according to the marking method, the prompting method, the solution presentation form, the input method and the output method.

10. A programmable logic controller integration method based on artificial intelligence, characterized in that: The method comprises: Collecting PLC code samples and operation data of the PLC, and integrating an AI model library of the PLC based on the PLC code samples and the operation data, wherein the AI ​​model library includes: an error detection model, a code generation model, and a code optimization model; Collecting a PLC code corresponding to the PLC, identifying an error code of the PLC code using the error detection model, marking the error code to obtain a marked error code, analyzing an error type of the error code, and generating an error prompt for the error code based on the error type and the marked error code; Based on the error prompt, the PLC code is optimized using the code optimization model to obtain an optimized PLC code, a gain effect of the optimized PLC code is analyzed, and an optimization scheme of the PLC code is generated according to the gain effect; Obtain a code function description of a target user, preliminarily generate a PLC code set of a PLC using the code generation model based on the code function description, analyze the code logic of the PLC code set, verify the operation effect of the PLC code set according to the code logic, and determine the optimal PLC code of the PLC code set based on the operation effect; According to the error prompt, the optimization plan and the optimal PLC code, a user interaction interface of the PLC is constructed, and based on the user interaction interface and the AI ​​model library, an intelligent PLC system of the PLC is integrated.