Skip to content
Blog
2026-09-22

ChatGPT for PLC programming: what works, what does not

Can ChatGPT write PLC code? Yes, as long as the task needs no knowledge of your project: explaining syntax, drafting a scaffold, sketching a state machine, summarising an unfamiliar block. The moment real symbol names, data types and libraries are involved, the result turns from helpful into rework, because the model simply does not know what exists in your project.

Browser chat against an assistant with project context

The same prompt, two environments. What differs is not the model, it is what the model is allowed to see:

Task ChatGPT in the browser Integrated assistant with project context
Explain a block Good, once you paste the code Good, reads the block from the project itself
Write a small FB in Structured Text Usable scaffold, identifiers guessed Fits the tag table and the data types
Convert STL to SCL Works for snippets Whole block including interface and comments
Refactor Only what you paste in Sees callers and cross references in the project
Find a fault Guesses without compiler output or live values Compiler messages and project state flow back
Safety logic Do not generate Do not generate

The last row is not a tool comparison, it is a rule: safety-related logic is not produced from a prompt, no matter who is asking.

What works

Everything that needs no project knowledge works surprisingly well in a browser chat. Having language concepts explained (edge detection, timers, indirect addressing, the REGION structure in SCL) belongs here, as does a first structure for a state machine, rewriting a nested IF cascade into a CASE state machine, or tidying up comments. A chat window also makes a decent sparring partner: "which states does a fault acknowledgement need so it restarts cleanly after a power failure?" returns a solid list you can work from.

The second strong case is reading. Paste an unfamiliar block, ask for an explanation, and you usually get a correct description of the logic. On existing plants that saves real hours, and since it writes nothing, it can break nothing.

Where it breaks down

The root problem never changes: the chat does not know your project. Five typical failure patterns follow from it.

  • Invented symbol names and data types. The code references tags that do not exist, or guesses at UDTs and library blocks. Plausible-looking code that falls apart on the first compile.
  • No project context. House standard, naming convention, blocks that already exist: none of it is known. You get correct IEC 61131-3 code that does not fit your plant.
  • Copy and paste as the import. Code out of the engineering environment, into the browser, back again, paste, retype the error message, back to the browser. Fine for one block, painful for twenty, and every switch between the two is a place to make a mistake.
  • No compile. The model never gets to see whether its proposal translates. It only corrects what you carry back by hand.
  • No tests. Nobody checks whether the block does the right thing. Yet that is exactly the difference between "it compiles" and "it works".

On top of that comes the approval question: copying plant code into a third-party chat window is simply not permitted in many companies. The ready-made custom GPTs in the store change nothing about that, they bring better prompts and the same blind spot.

How to use ChatGPT safely anyway

Three gates turn the browser chat into a proper tool:

  1. Compile gate. No generated block counts as finished before it has been compiled against the real project. Invented calls and wrong data types show up there immediately.
  2. Review. You read the proposal line by line, pull identifiers onto the house standard and check interlocks by hand. An AI proposal is a draft from a fast junior, not the outcome of an acceptance test.
  3. Unit tests. Before it goes live, at least one test case per operating mode and per fault case. Without a test, "looks good" is the only statement you can make about the code.

Two habits improve the output straight away: give the model the block's real declaration instead of describing it, and ask for the proposal in small units you can review one at a time. For the TIA Portal side of the same question, see the post ChatGPT for TIA Portal.

When an integrated assistant pays off

As long as you have the occasional syntax question, the browser is enough. The maths changes as soon as blocks are produced in series or a legacy stock is migrated. An assistant that reads the project removes the switching back and forth, stops inventing identifiers, shows every change as a diff before it is applied, and brings compile and tests into the same loop. The time saved sits less in faster typing than in the rework that no longer happens per block.

What integrated tools deliver, and where they stop too, is in the guide to AI in PLC programming. If you want to compare concretely, the tools are lined up with environment, model choice, local option and pricing in the comparison of AI tools for PLC programming.

Frequently asked questions

Can ChatGPT write PLC code?

For standard logic in Structured Text, yes, at the level of a scaffold. The model guesses symbol names and data types because it cannot see your project. Without a compile against the real project, such a block is not a result, it is a draft.

Which language works best?

Structured Text, called SCL at Siemens. Language models are text models, and ST is text. They read STL well too, which makes conversion to SCL one of the most reliable tasks. Ladder and FBD need a text representation, otherwise the model sees nothing.

May I paste plant code into a cloud chat window?

Your approval process decides that, not the tool. If project code may not leave the building, a local model on your own hardware is the only path that passes review. Settling the question up front is cheaper than explaining it afterwards.

Will ChatGPT replace PLC programmers?

No. It shifts the work: less boilerplate typing, more specifying, reviewing and testing. Plant knowledge, safety assessment and the responsibility for sign-off stay with people.

What is the difference to an integrated AI assistant?

Context, not the model. An integrated assistant reads tags, data types and existing blocks from the project, shows changes as a diff, and hangs compile and tests off the same workflow. The same model then delivers usable code on the first try far more often.