← Resources
AI·8 min read·

Why ChatGPT writes ladder logic that does not run

General models are good at the shape of PLC code and bad at the parts that matter. Here is what they get wrong, and what has to sit around them.

By the LADX engineering team, first published 23 August 2026

Short answer

It can write PLC code that looks correct and frequently does not compile. General models are strong on structure and weak on the four things that decide whether PLC code works: dialect consistency, timer semantics, scan order and addressing. None of those are visible by reading, and all of them are visible to a compiler, which is why a validation loop matters more than a better prompt.

A loop: the model writes code, the checks run over it, the engineer reads it with what they found, and Auto-fix sends the errors back to the model on request
The loop that makes it usable

Ask a general-purpose model for a motor start/stop circuit and you will get something that looks entirely correct: a start contact, a seal-in branch, a stop contact in series, a coil. Tag names that make sense. Comments that read well.

Paste it into Studio 5000 and there is a reasonable chance it does not compile. Paste it into a running line and there is a smaller but non-zero chance of something worse.

The gap is not that models are stupid about PLCs. It is that the things they are weak at happen to be exactly the things that decide whether PLC code works.

What they get right

Structure, mostly. The overall shape of a rung, the idea of a seal-in, the convention that stop buttons are wired normally closed. There is a great deal of automation writing on the internet and models have read it.

ChatGPT Did My PLC Programming Homework and I Got an A+...Really?, from Tim WilbornePrivacyWatch on YouTube

What they get wrong

  • Dialect drift. Rockwell's XIC and Siemens' normally-open contact do the same job, and a model will happily mix the two vocabularies inside one answer because both appeared in its training data.
  • Timer semantics. TON, TOF and RTO differ in when they reset, and a retentive timer used where a non-retentive one belongs produces a machine that behaves correctly for exactly one cycle.
  • Scan order. Models write ladder as though it were a list of statements evaluated instantly. The one-scan lag on a backward reference is invisible in text and only appears when the thing runs.
  • Confident addressing. %I0.0, I:1/0 and Local:1:I.Data[0] are three different platforms' ways of saying roughly the same thing, and a model asked for one will sometimes produce another.
None of these are visible by reading. All of them are visible to a compiler.

The fix is not a better prompt

It is a loop. Generate, then compile the result with a real IEC 61131-3 compiler, then run a static checker over it, and if either complains, hand the errors back to the model and ask again.

This is not a new idea. The research literature has converged on it, with published work showing that feedback-driven pipelines dramatically outperform single-shot generation for structured text. It is just rarely built, because it needs actual compiler infrastructure rather than an API key.

The useful side effect: once the loop exists, a small free model becomes genuinely useful, because it is allowed to be wrong on the first attempt. Most of the quality comes from the checking rather than from the model.

What still needs you

A compiler proves the code is valid. It does not prove the code is right. Whether the guard should break the seal-in or only stop the motor, whether that timer should be five seconds or fifty, whether this interlock is sufficient for the hazard. None of that is a syntax question, and none of it should be delegated.

The honest description of what a tool like this does is: it removes the typing and the syntax errors, and leaves the engineering.

Running the code narrows the gap a little further. In LADX a Structured Text answer that compiles carries a Run on LADV button that opens it on a virtual PLC in the browser, where a seal-in that never releases, or a timer that never resets, shows up in seconds rather than at the machine.

For which tools are worth using and how to test them before trusting their output, see the best AI for PLC programming in 2026.

Sources and further reading

Common questions

Is it safe to use ChatGPT for PLC programming?
For drafting and explanation, yes. For anything that reaches a controller, only with review by a competent engineer. A model cannot verify that an interlock is sufficient for a hazard, and no amount of prompting changes that. Treat generated code as a first draft, not a deliverable.
Why does AI-generated ladder logic fail to compile?
Most often because the model mixes vendor dialects within one answer, having learned from both. It will use Rockwell mnemonics with Siemens addressing, or invent an instruction that exists on neither platform. A compiler catches this instantly; reading it does not.

Keep reading