Machine-written PLC documentation is only useful if every statement traces to the rung that makes it true. How we generate program docs, how 137 of them survived grading by three independent Controls Engineers, and what generation still cannot capture.
Nobody documents PLC programs, and everybody pays for it. The program grows for fifteen years under a dozen hands, the comments describe the machine as it was two rebuilds ago, and the real documentation is whatever the most senior Controls Engineer remembers. Then that person leaves, and the plant discovers the price of the gap all at once.
Writing documentation by hand never survives contact with production priorities, which makes it a natural thing to want a machine to do. It is also a place where AI-generated text can do real damage, because wrong documentation is worse than none. Someone troubleshooting at 2 a.m. will trust the document, and a document that misstates an interlock sends them down the wrong path with a line stopped. So the interesting question is not whether AI can write PLC documentation. It obviously can produce something shaped like it. The question is whether the result is accurate at the level where accuracy matters, which is the rung.
Why Program Docs Rot
The reasons are structural, not cultural. Documentation lives outside the program, so nothing forces it to change when the logic changes. The person making an emergency change at the panel is the least likely person to update a Word file afterward. And the knowledge that matters most, why the logic is shaped the way it is, is precisely the part that never gets written down anywhere.
The cost of that gap is not abstract. On one site, a sortation lane had been decommissioned in the warehouse host weeks earlier and the belts were still running, because the host bit gates routing and has no relationship to the conveyor motors. Two systems that sound like the same sentence in a meeting. Nothing in writing anywhere connected the two, so the layering had to be rediscovered against the logic, live, before anyone would touch it. That session is decommissioned in the host, still running on the floor.
Any fix that depends on people developing better documentation habits has been tried for forty years. The fix that can hold is generating the documentation from the program itself, so the source of truth is the logic and the document is a view of it.
What "Accurate" Has to Mean
A summary that says "this routine controls the infeed conveyor" is not documentation, it is a caption. Useful program documentation states what conditions start and stop the motion, what interlocks gate it, what faults latch and how they clear, and where each of those lives in the program. Every one of those statements is checkable against a specific rung, which means every one of them can be wrong in a specific, findable way.
That is the standard we hold the output to: rung-accurate. Each claim traces to the rung that makes it true. Not approximately right, not right in spirit. Right in a way a Controls Engineer can verify by opening the routine at the cited location.
Wrong documentation is a trap with your company's logo on it. If a machine writes the document, the machine has to be held to the standard of the person who would have signed it.
How the Generation Works
The architecture matters more than the model. Nexus parses the project file deterministically first: every rung, tag, instruction, UDT, and cross-reference, exact and complete. We validated that layer on 4,386 real PLC project files from operating plants with zero parser errors. The language model then writes over that parsed representation and is constrained to it. It is not recalling what ladder logic usually looks like. It is describing this program, with citations back into it. The argument for why that split is necessary is in can AI read PLC code.
Two consequences follow, and they are the ones that make generated docs different in kind from hand-written ones.
It reads the layer people cannot open. The logic that decides behavior is often sealed inside OEM add-on instructions rather than the routine an engineer opens first. When a site wanted to know how a conveyor reports its OEE state, the answer sat inside three vendor instruction bodies among 148 in the export, and the rule separating blocked from faulted was a single alarm-code threshold that nothing on the screen expresses. The document that came out of that session was a one-page operator reference: three reachable states with their codes, a fault table naming the signal behind each alarm, an explicit note that the safety stop path gets read rather than defeated, and a four-step triage list. That is what generated documentation should look like, and the full session is reading an OEE state machine out of a vendor instruction body.
Documenting is a form of review. Reading logic carefully to describe it surfaces things nobody asked about. That same pass turned up three unrelated defects: an idle branch skipping the error-code check every sibling branch performs, a timer enable assignment immediately overwritten so it does nothing, and one routine block missing an inversion its siblings all have, which makes that block treat a blocked condition differently from the rest of the line. None of those were the question. All three are cited to the line that contains them. A hand-written document produced under deadline finds none of that, because the person writing it is summarizing what they already believe the program does.
Because the document is generated from the program, regenerating it after a change is cheap, which is the property hand-written docs never had.
The Grading
Claims like this deserve hostile review, so we arranged some. We had the generated program documents graded by three independent Controls Engineers, people whose job is exactly the knowledge being tested, with no stake in the answer coming out well. The grading standard was the one above: rung accuracy, checked against the actual program.
The result was 137 of 137 documents graded rung-accurate. We publish that number because it is the only kind of evidence this category should accept. A demo on a synthetic project proves the demo works. Production programs, written by many hands over many years, full of the workarounds and oddities real machines accumulate, are the test that counts.
What Generation Does Not Capture
Three limits are worth stating plainly, because a document that overclaims is the failure mode this whole approach exists to avoid.
The rung says what the logic does, not why. On a merge investigation, the fix that eventually mattered was a starvation timeout raised from 150 milliseconds to 1000 because normal carton gaps were tripping an override. A generated document would have stated the original value correctly and cited it. It could not have told you the value was wrong, because the reason lives in the physical gaps between cartons on that specific line. That investigation is eliminating the code on a merge releasing in slugs.
Documentation describes the program, not the plant. An export can prove a jam block is declared and never driven by any instruction call. It cannot prove the zone is physically dead, and confusing those two claims is how a cleanup becomes an outage.
Site vocabulary is not in the logic. On one line, roughly half the operator-facing abbreviations had no confirmed expansion for that site. The correct behavior is to flag them as unconfirmed and tell the reader to ask a site expert, not to invent plausible expansions that read well. A person still finishes the last mile on wording.
Where This Leaves the Engineer
Generation takes the large share of documentation work that is mechanical transcription of the program and makes it close to free, so the scarce human knowledge can go where only it can go. It also means the day the senior engineer retires, the program itself is no longer undocumented, and what walks out the door is judgment rather than the only existing map of the logic. That is the same problem we study under knowledge and memory, and the decay pattern behind it is in how operational knowledge decays.
That is a narrower promise than "AI documents your plant." It is also one we can prove, rung by rung.