Exploring LLM Support for Generating IEC 61131-3 Graphic Language Programs
Yimin Zhang, Mario de Sousa
TL;DR
This paper investigates the use of Large Language Models to generate IEC 61131-3 graphic PLC languages, focusing on Ladder Diagram (LD) and Sequential Function Chart (SFC) expressed as ASCII art. Through a structured set of prompts, few-shot examples, and manual evaluation, the study shows that LLMs can produce semantically and syntactically correct SFCs for simple control logic but struggle with LD generation and LD↔SFC conversions. The results reveal significant challenges due to ASCII-art representation, tokenization of spaces, and the lack of domain-specific fine-tuning, while few-shot learning provides some gains for simpler tasks. The work highlights the potential of LLM-assisted PLC programming, identifies key bottlenecks, and outlines directions such as retrieval-augmented generation and targeted fine-tuning to improve correctness and reliability in industrial contexts.
Abstract
The capabilities demonstrated by Large Language Models (LLMs) inspire researchers to integrate them into industrial production and automation. In the field of Programmable Logic Controller (PLC) programming, previous researchers have focused on using LLMs to generate Structured Text (ST) language, and created automatic programming workflows based on it. The IEC 61131 graphic programming languages, which still has the most users, have however been overlooked. In this paper we explore using LLMs to generate graphic languages in ASCII art to provide assistance to engineers. Our series of experiments indicate that, contrary to what researchers usually think, it is possible to generate a correct Sequential Function Chart (SFC) for simple requirements when LLM is provided with several examples. On the other hand, generating a Ladder Diagram (LD) automatically remains a challenge even for very simple use cases. The automatic conversion between LD and SFC without extra information also fails when using prompt engineering alone.
