Table of Contents
ToggleLarge language models can now draft Structured Text in seconds, but a confident wrong rung can still crash a machine or defeat an interlock. This guide shows where AI really helps a PLC engineer and how to test every line it writes.
AI chatbots are good at drafting and explaining PLC code but weak at real ladder diagrams and plant specific detail. Here we cover tested results, prompt patterns, vendor copilots and a review method that keeps the plant safe.

What Is ChatGPT for PLC Programming?
ChatGPT for PLC programming means using a large language model to draft, explain, convert or review PLC code from plain English prompts, mostly in Structured Text. It is a fast assistant for first drafts and documentation, but every line still needs an engineer to test it in simulation before it reaches a live machine.
- Strong at Structured Text drafts, code comments, explaining old logic and writing test cases.
- Weak at real ladder diagrams, which come out as text descriptions rather than editable rungs.
- Vendor tools such as Siemens Industrial Copilot and Rockwell FactoryTalk Design Studio Copilot work inside the engineering software.
- Never paste confidential client code into a public chatbot.
- Never use AI drafts in safety PLC logic without full IEC 61511 verification.
Our earlier article on generative AI in industrial automation covered the big picture of AI in engineering. This one goes deeper into daily coding work, building on our overview of AI in PLC, SCADA and DCS.

Control.com author Michael Levanduski tested ChatGPT on Rockwell style tasks in April 2023. He found the Structured Text a solid starting point but judged the ladder and function block outputs much weaker.
What ChatGPT Can and Cannot Do in PLC Code
| Task | How Well It Works | Engineer Must Check |
|---|---|---|
| Structured Text function blocks | Good first draft | Tags, data types, scan behaviour |
| Explaining old code | Very good | Plant specific meaning of tags |
| Comments and documentation | Very good | Accuracy against real I/O |
| Ladder diagram output | Poor, text only | Everything, redraw by hand |
| Function block diagrams | Poor diagrams, useful text | Block wiring and order |
| Vendor specific instructions | Mixed, can be outdated | Manual for your firmware |
| Test case lists | Good | Missing edge cases |
An ABB research team led by Heiko Koziolek built 100 prompts in 10 categories and ran them through ChatGPT with GPT 4. In many cases the output was syntactically valid IEC 61131 Structured Text, and the model showed reasoning skills that could make control engineers more productive.
A 2024 University of Porto study by Yimin Zhang and Mario de Sousa was less kind to graphic languages. GPT 4 still could not produce correct ladder diagrams even for simple cases, and the authors found no clear winner between GPT 4, Claude 3 and Gemini 1.5.
The same Porto study found that GPT 4 produced fully correct Sequential Function Charts for two of its three test cases. The case it failed had hidden states that were not spelled out in the prompt.
Can ChatGPT Write Ladder Logic?
A chatbot writes text, so ladder logic comes back as a list of rungs in words or a rough text sketch. You still need to enter each rung by hand, which is fine for learning but slow for real projects, as anyone who has studied ladder logic for beginners will see.
Levanduski noticed that the latch explanation was vague and that the addressing looked like RSLogix 500 for older PLCs. ChatGPT also named RSLogix 5000, while from version 21 the software is called Studio 5000.
The practical answer is to ask for Structured Text or for a rung by rung description, then build the rungs yourself. Timers are a common trap, so compare every suggested timer against how TON, TOF and RTO timers behave on your platform.
Structured Text Prompt Examples That Work
When you use ChatGPT for PLC programming, a weak prompt says only start a motor with a button. A good prompt gives the tags, says the stop button and overload are wired NC, asks for stop priority and requests test cases.
Motor_Run := TRUE;
END_IF;
IF NOT Stop_OK OR NOT OL_OK THEN
Motor_Run := FALSE;
END_IF;
Because the second IF runs after the first in the same scan, stop always wins over start. If the AI had assumed a normally open stop button, a broken wire would leave the motor unstoppable, which is exactly the kind of error a reviewer must catch.
For deeper syntax, see our guide to PLC Structured Text programming and the wider family of IEC 61131 3 programming languages.
Paste your real tag list and ask the chatbot to use only those names. This one step removes most invented tags and makes the draft far easier to import.
Vendor AI Copilots for PLC Engineering
Generates SCL code inside TIA Portal, explains existing blocks and helps build first WinCC Unified screens.
Powered by Microsoft Azure OpenAI Service, it generates and explains ladder and other Logix code from prompts.
A chat window in TwinCAT XAE that links to cloud LLMs to create, optimise and document function block code.
ChatGPT, Claude and Gemini give vendor neutral drafts and explanations, but have no link to your project.
Siemens presented its Industrial Copilot for engineering at Hannover Messe 2024, and Elektroniknet reported that TIA Portal takes the generated SCL code directly, with no copy and paste. Healthcare Packaging reported the Rockwell copilot in December 2024, and Beckhoff announced TwinCAT Chat in April 2023.
Compared with ChatGPT for PLC programming, vendor copilots know their own instruction sets better, which reduces outdated addressing and wrong instruction names. They still need the same testing, because none of them knows your plant or your hazard study.
How to Verify AI Generated PLC Code
Simulation is where AI drafts are proven or rejected, so plan it from the start using offline programming and simulation. Final proof still comes from a witnessed FAT and SAT against the approved control narrative.
Watch scan order closely, because code that looks right on paper can behave differently in the PLC scan cycle. Edge detection, one shots and timer resets are where ChatGPT for PLC programming most often slips.
Test Case Calculator for AI Generated Logic
Using ChatGPT for PLC programming saves drafting time only if you spend some of it on testing. This calculator gives a simple planning count: every combination of the boolean inputs, two cases per sequence step and three points per analog trip.
6 steps × 2 (entry and timeout) = 12 cases
2 analog trips × 3 (below, at, above) = 6 cases
Total = 16 + 12 + 6 = 34 test cases
34 × 5 min = 170 min ≈ 2.8 h
This is a planning rule of thumb, not a standard, and it grows fast because each extra boolean input doubles the truth table. Above about 8 inputs, split the logic into smaller blocks that can be tested one at a time.
Safety and Security Risks of AI Written Code
Language models can invent instructions, mix vendor syntax and assume normally open contacts where the field uses fail safe NC wiring. Safety logic belongs in a certified safety PLC under IEC 61511, kept separate from the control system as explained in SIS and BPCS differences.
Pasting a client program into a public chatbot can also break a confidentiality agreement. Check your company policy and the cybersecurity standards for PLCs before any project file leaves the engineering network.
Troubleshooting AI Generated PLC Code
| Symptom | Likely Cause | Fix |
|---|---|---|
| Import fails | Invented or wrong tag names | Give the real tag list in the prompt |
| Output latches on | Missing reset or wrong priority | Put the stop or reset logic last |
| Timer never finishes | Timer re enabled every scan | Check enable conditions and resets |
| Event counted many times | No edge detection | Add a one shot or rising edge trigger |
| Works in simulation, fails on site | NO or NC assumption wrong | Recheck field wiring against the I/O list |
| Old style addresses | Model trained on older platforms | State the software and version |
Many of these faults also show up as controller faults on site, so keep our guide on PLC fault handling and recovery nearby during commissioning.
Koziolek and his ABB colleagues proposed their 100 prompt collection as the base for a formal benchmark of LLMs on control logic. Such benchmarks matter because each model update can change the code it writes.
Code Review Checklist Before Download
- Every tag exists in the I/O list with the correct data type.
- NO and NC field contacts match the logic.
- Stop, trip and reset logic has priority over start.
- Outputs go to the safe state on fault and power loss.
- Timers, counters and one shots reset as intended.
- All test cases pass in simulation with records kept.
- No safety function depends on AI written code without full verification.
- A second engineer has reviewed and signed the block.
- Fast first drafts in Structured Text.
- Clear comments and documentation.
- Explaining old or unfamiliar code.
- Generating test case lists.
- No real ladder diagram output.
- Outdated or mixed vendor syntax.
- No knowledge of your plant hazards.
- Confident answers that can be wrong.
Keep a prompt log with each AI generated block in your project folder. It shows reviewers what was asked and makes later changes easier to trace.
Skills PLC Engineers Still Need
Good use of ChatGPT for PLC programming depends on knowing the basics well enough to spot a wrong answer. Practise on free PLC programming software and learn all the PLC programming languages before you lean on any assistant.
Use AI to draft a first out alarm logic block, then write the test cases yourself and compare. This habit builds the judgement that no chatbot can supply.
University of Porto Study on LLM PLC Code PDF
Video: Using ChatGPT AI to Program a Click PLC
ChatGPT for PLC Programming FAQ
Yes, ChatGPT for PLC programming can produce useful Structured Text drafts, explain existing code and suggest test cases. Research by ABB found its Structured Text was often syntactically valid.
It cannot see your plant, your wiring or your hazard study. So every draft must be reviewed, simulated and tested by a qualified engineer before use.
It can describe ladder rungs in words or a rough text sketch, but it cannot give you an editable ladder file. A 2024 university study found GPT 4 failed to produce correct ladder diagrams even for simple tasks.
Ask for Structured Text or a rung by rung description instead. Then build and test the rungs yourself in your own software.
AI tools speed up drafting and documentation, but they do not take responsibility for a running machine. Someone still has to understand the process, the hazards and the commissioning work.
The engineers who gain most are those who combine strong basics with AI skills. Learning to review and test AI code is becoming part of the job.
A study comparing GPT 4, Claude 3 and Gemini 1.5 found no clear winner on control logic tasks. Results depend heavily on the prompt and the language you ask for.
Vendor copilots inside TIA Portal or FactoryTalk Design Studio know their own instruction sets better. General chatbots remain handy for learning and vendor neutral drafts.
Using ChatGPT for PLC programming is safe only after the same review, simulation and witnessed testing you apply to human written code. Never download an untested AI draft to a running machine.
Safety instrumented functions need certified hardware and a full IEC 61511 lifecycle. AI may help with documentation there, but not with unverified logic.
It is a generative AI assistant for engineering that Siemens presented at Hannover Messe 2024. It works inside TIA Portal and can generate and explain SCL code.
It can also help create first WinCC Unified screens and search Siemens manuals in plain language. Like any AI tool, its output still needs careful review and simulation testing before download.
Related Articles
- AI in PLC, SCADA and DCS
- PLC Structured Text Programming
- IEC 61131 3 Programming Languages
- Ladder Logic for Beginners
- Edge AI vs Cloud AI in Industrial Automation
External References
- Exploring LLM Support for Generating IEC 61131 Graphic Language Programs, University of Porto
- Can ChatGPT Be Used for Control System Programming, Control.com
- Programmable Logic Controller, Wikipedia
What We Learn Today
- ChatGPT for PLC programming is strong at Structured Text drafts, comments and explanations, but weak at real ladder diagrams and plant specific details.
- Good prompts name the platform, give the real tag list, state NO or NC wiring and fail safe rules, and ask for test cases.
- Every AI draft needs desk review, simulation, recorded test cases and witnessed FAT before it reaches a machine, and never in unverified safety logic.

