Secure, local code generation for programmable logic controllers
Lemgo. Programming programmable logic controllers (PLCs) is a time-consuming and error-prone process. Each manufacturer uses its own dialects and proprietary function blocks – what works on a Siemens controller cannot be easily transferred to a Mitsubishi Electric controller. At the same time, cloud-based AI assistants such as ChatGPT or GitHub Copilot are not an option for many industrial companies due to data protection reasons. In a contract research project, Fraunhofer IOSB-INA and SmartFactoryOWL, together with Mitsubishi Electric, have developed a specialized programming assistant that solves these challenges.
Challenge: Proprietary systems and data protection requirements
Modern Large Language Models (LLMs) such as GPT-5.2 can generally write code, but do not know the specific function blocks and syntax rules of individual PLC manufacturers. This information is documented in extensive manuals, often thousands of pages long, partly consists of images and is not easily accessible to the training data of the AI models. In any case, they do not lead to the ability to generate code for the respective dialect of a manufacturer. In addition, companies in the automation industry and users, such as manufacturing companies, regard their control logic as a trade secret and do not want to transmit any data to external cloud services. Unlike programming languages such as Python or C, control code is not massively available online.
Solution: Retrieval-Augmented Generation with Compiler Integration
In the GeneriST project, an AI assistant was developed that is specifically tailored to the Structured Text implementation of Mitsubishi Electric and the MELSOFT GX Works3 development environment. The system uses Retrieval-Augmented Generation (RAG): A specialized knowledge database contains function blocks, syntax rules and code examples that are specifically retrieved for each request and provided to the language model as context. This allows the AI to generate manufacturer-specific code without the need for extensive training data.
A special feature is the direct integration of the GX Works3 compiler. Generated code is automatically compiled and iteratively corrected in case of errors – the user receives validated, executable code. The system supports both cloud-based models and a locally executable, fine-tuned model that can be operated completely offline on a standard laptop and thus meets the highest data protection requirements.
Results: High compilation rates and practical solution
The evaluation with 100 test tasks shows impressive results: The RAG-supported system achieves compilation rates of up to 87 percent – compared to only 38 percent without the specialized knowledge database. The local model also achieves a comparable performance with 86 percent and thus enables use in safety-critical environments without external dependencies. The solution is currently being piloted by Mitsubishi Electric; a follow-up project for further development is planned.
Transferability to other applications
The developed architecture is not limited to Mitsubishi Electric. By exchanging the knowledge database and adapting the prompt templates, the system can be transferred to other PLC manufacturers and control dialects. GeneriST thus offers a blueprint for companies that want to develop AI-supported programming assistants for proprietary systems – without transferring sensitive data to the cloud.