PLC and Ladder Logic Generation: Verifiable Evaluation Approaches
PLC and Ladder Logic Generation: Verifiable Evaluation Approaches
Programmable Logic Controller programming is one of the most operationally consequential tasks in industrial automation. A ladder logic program that fails silently can halt a production line, damage equipment, or create unsafe conditions. When AI systems generate PLC code, the evaluation question is not whether the output looks plausible. The question is whether the logic is functionally correct under the full range of input conditions. This post describes how to build verifiable evaluation approaches for PLC and ladder logic generation, where frontier models fail, and what a rigorous eval pipeline requires.
Answer Capsule: Verifiable evaluation of PLC and ladder logic generation requires three components: a structured task specification with defined I/O maps and timing constraints, a simulation-based verifier that executes the generated logic against a scan-cycle model, and an expert-authored rubric for structural and safety properties that simulation cannot check. Aggregate pass/fail rates are insufficient; failure-mode analysis by rung class reveals where models break down.
Why PLC and Ladder Logic Generation Resists Generic Evaluation
Ladder logic is a graphical programming language standardised under IEC 61131-3. Its semantics are defined by the PLC scan cycle: inputs are read, the program is evaluated left-to-right and top-to-bottom across rungs, and outputs are written. This execution model is deterministic but stateful. A rung that appears syntactically correct can produce wrong output when coil latching, timer accumulation, or counter overflow interacts with a specific input sequence.
Generic evaluation approaches fail here for three reasons. First, most LLM benchmarks treat code generation as a static text-matching or unit-test problem. Ladder logic correctness is a temporal property: the program must produce the right output across a sequence of scan cycles, not just at one moment. Second, the domain vocabulary is narrow and specialist. Training corpora contain very little IEC 61131-3 structured text or ladder logic notation relative to Python or C. Third, the consequences of subtle errors are asymmetric. A latched output coil that never de-energises is a safety hazard, not a style issue.
For more on why verifiable rewards are difficult to construct for tasks that resist automatic grading, see the Chiron Data Labs analysis of tasks that resist automatic grading.
Verifiable Evaluation Approaches: The Three-Layer Stack
A complete verifiable evaluation approach for PLC and ladder logic generation requires three distinct layers. Each layer catches a different failure class. No single layer is sufficient alone.
Layer 1: Simulation-Based Functional Verification
The primary verifier executes the generated ladder logic against a scan-cycle simulator with a defined input sequence. The verifier checks that outputs match the expected truth table across every step of the sequence.
The protocol is as follows:
Define the I/O map: input bits, output coils, internal memory bits, timers, and counters with their data types and address ranges.
Specify the input sequence as a time-ordered list of scan-cycle states. Each state is a vector of input bit values.
Specify the expected output vector for each scan cycle in the sequence.
Parse the generated ladder logic into a rung graph. Reject malformed programs at this stage and record the parse error class.
Execute the rung graph against the scan-cycle simulator. Record the output vector at each step.
Compare actual vs. expected output vectors. Compute the fraction of scan cycles where all outputs match exactly.
Partial credit is possible but must be defined in advance. A program that is correct for 18 of 20 scan cycles but fails on the two cycles involving timer expiry has a different failure profile than one that is wrong from cycle one. Both matter; they matter differently.
Layer 2: Static Analysis for Safety and Structural Properties
Simulation verifies functional correctness on the specified input sequence. It cannot verify properties that depend on inputs outside that sequence, nor structural properties that are independent of execution. Static analysis covers these.
Key static checks for ladder logic evaluation tasks:
Duplicate output coils: Multiple rungs writing to the same output coil. The last rung wins in most PLC implementations, but this is almost always a logic error.
Unlatched outputs: An output coil that can be set (energised) but has no rung that can de-energise it, or vice versa.
Unreachable rungs: Rungs with contact conditions that are structurally impossible given the I/O map.
Timer and counter misuse: Timers used without a reset rung, or counter preset values inconsistent with the task specification.
Undeclared addresses: References to I/O addresses not defined in the task I/O map.
Each of these checks is binary and automatable. They should be run before simulation and reported separately. A program that passes simulation but has a duplicate output coil has a latent defect that will surface under a different input sequence.
Layer 3: Expert Rubric for Non-Automatable Properties
Some properties of industrial ladder logic cannot be verified by simulation or static analysis. They require practitioner judgment. These include: whether the program structure follows industrial conventions (for example, safety interlocks placed before output rungs), whether the logic is maintainable and legible to a controls engineer, and whether the approach to a given control problem matches accepted practice in the relevant industry sector.
Expert rubrics for these properties must be anchored to observable rung-level features, not holistic impressions. For rubric design principles that apply across expert domains, see the Chiron Data Labs post on rubric design, criteria, weights, and anchors.
Illustrative Example: A Motor Start-Stop Sequence Eval Task
Illustrative example (numbers and details are constructed to demonstrate the method, not drawn from a specific deployment):
Task specification: Generate IEC 61131-3 ladder logic for a three-wire motor start-stop circuit with the following requirements. Inputs: I0.0 (normally open start pushbutton), I0.1 (normally closed stop pushbutton), I0.2 (normally closed overload relay). Output: Q0.0 (motor contactor coil). Behaviour: pressing start energises the contactor; the contactor seals in via a parallel contact on Q0.0; pressing stop or overload trip de-energises the contactor.
I/O map: three input bits, one output bit, no timers or counters.
Input sequence for simulation (10 scan cycles):
Cycles 1-2: all inputs at rest (I0.1 and I0.2 high, I0.0 low). Expected Q0.0 = 0.
Cycle 3: I0.0 momentarily high. Expected Q0.0 = 1.
Cycles 4-6: I0.0 returns low. Expected Q0.0 = 1 (seal-in).
Cycle 7: I0.1 momentarily low (stop pressed). Expected Q0.0 = 0.
Cycles 8-10: all inputs at rest. Expected Q0.0 = 0.
A model that generates the start rung without the seal-in contact on Q0.0 will pass cycles 1-3 and fail cycle 4. This is a distinct failure mode from a model that omits the normally closed contacts for stop and overload, which will pass cycles 1-6 and fail cycle 7. Simulation with a step-by-step input sequence separates these two failure classes. Aggregate pass/fail on the full sequence does not.
Static analysis on this task checks: is Q0.0 the only output coil? Is I0.2 used as a normally closed contact (not normally open)? Are there any undeclared addresses?
Expert rubric: is the seal-in contact placed in parallel with the start contact on the same rung (standard practice) rather than on a separate rung (functional but non-standard)?
Common Failure Modes in PLC and Ladder Logic Generation Evals
The following failure modes appear repeatedly when evaluating frontier models on ladder logic tasks. Each is detectable and has a specific fix in eval design.
1. Contact polarity inversion. Models generate normally open contacts where normally closed contacts are required, or vice versa. Detection: static analysis of contact type against I/O map annotations. Fix: annotate each I/O address in the task spec with its default state and required contact type; include at least two scan cycles where the distinction matters.
2. Missing seal-in logic. Models generate momentary output activation without the latching rung needed for maintained operation. Detection: simulation with a multi-cycle input sequence where the trigger input returns to rest. Fix: always include post-trigger scan cycles in the input sequence.
3. Timer preset and base unit errors. Models specify timer preset values in the wrong unit (seconds vs. milliseconds vs. scan cycles) or omit the timer reset rung. Detection: simulation against a sequence long enough to observe timer expiry; static check for reset rungs. Fix: require the task spec to state timer base unit explicitly and include timer expiry in the input sequence.
4. Structured text leakage. Models trained on mixed IEC 61131-3 corpora generate structured text or function block code when ladder logic is requested. Detection: parser rejection at Layer 1. Fix: specify the target representation unambiguously in the task prompt; record parser rejection as a distinct failure class, not a simulation failure.
5. Hallucinated I/O addresses. Models reference addresses outside the defined I/O map. Detection: static analysis. Fix: include an explicit I/O map in the task spec and flag any undeclared address as an automatic failure.
6. Eval contamination via training exposure. Standard motor start-stop circuits appear in PLC textbooks and are likely in training corpora. Models may reproduce a memorised circuit rather than reasoning from the specification. Detection: vary the I/O addresses, contact polarities, and behavioural requirements from canonical examples. Measure pass@k across multiple prompt variants; low variance at k=1 with high variance across prompt variants suggests retrieval rather than reasoning. For a broader treatment of difficulty calibration and task tiers, see difficulty ladders and graded task tiers.
Where This Approach Breaks Down
Simulation-based verification is only as good as the input sequence. A sequence that does not cover edge cases, such as simultaneous conflicting inputs, power-cycle restart behaviour, or counter rollover, will not detect failures in those conditions. Constructing complete input sequences for complex programs with multiple interlocks and timers is itself a specialist task requiring practitioner authorship.
Static analysis catches structural defects but cannot verify intent. A program can be structurally clean and functionally wrong if the logic addresses the wrong problem.
Expert rubrics introduce inter-rater variability. Two controls engineers may disagree on whether a particular rung structure is acceptable practice. Rubric calibration with gold-standard examples and explicit anchor descriptions reduces but does not eliminate this variability. The Chiron Data Labs post on preference pairs in technical domains addresses how to handle cases where ground truth is contested.
Finally, difficulty drifts. A task that frontier models fail today may be solved reliably in six months. Pass@k scores are model-specific and date-specific. Eval sets require periodic recalibration against current model families.
Frequently Asked Questions
What simulation environment is appropriate for verifying generated ladder logic?
Any environment that implements the IEC 61131-3 scan-cycle execution model is suitable. Open-source PLC simulation libraries exist for Python. The requirement is deterministic execution of rung evaluation order and correct handling of coil state across scan cycles. The specific tool matters less than whether it faithfully implements the target PLC's execution semantics, including edge cases such as coil evaluation order when multiple rungs write the same address.
How many input-sequence steps are needed for a reliable eval?
The minimum is one scan cycle per distinct behavioural state the specification requires, plus at least one transition between each adjacent pair of states. For a simple start-stop circuit with three states (off, starting, running, stopping), a minimum sequence is eight to twelve scan cycles. For programs with timers or counters, the sequence must be long enough to observe at least one full timer or counter cycle. Sequences shorter than this will miss the most common failure modes.
Can LLM-as-judge replace simulation for ladder logic evals?
No. LLM-as-judge agreement with expert judgment on ladder logic correctness has not been established, and the failure modes that matter most, such as missing seal-in logic or timer unit errors, are exactly the failure modes that LLM judges are likely to miss because they require scan-cycle-level reasoning. Use LLM-as-judge only for rubric dimensions that are explicitly structural or stylistic, never for functional correctness.
How should difficulty be calibrated across a ladder logic eval set?
Measure pass@k (the probability that at least one of k independently sampled completions is correct) against two or more frontier models. Tasks where pass@1 exceeds 0.8 across all tested models are too easy for post-training signal. Tasks where pass@k at k=10 is zero for all tested models may be under-specified or have verifier bugs. The target range for training tasks is pass@1 between 0.1 and 0.5, with pass@k at k=5 above 0.3. For evals, harder tasks with lower pass@k are appropriate. See also the discussion of RLVR beyond math and code for how verifiable rewards apply to engineering domains.
What makes a ladder logic task resistant to contamination?
Tasks are contamination-resistant when the specific combination of I/O configuration, behavioural requirements, and timing constraints does not appear in publicly available PLC training materials. This requires expert authorship of novel scenarios, not adaptation of textbook examples. For a framework on authoring tasks that are original and verifiable from specification to rubric, see the expert task authoring playbook.
What This Means in Practice
Evaluating PLC and ladder logic generation is not a text-similarity problem. It is a functional verification problem with a temporal dimension, a static analysis dimension, and a practitioner judgment dimension. Each dimension catches failure modes the others miss. Treating any one layer as sufficient will produce eval results that do not predict real-world model behaviour on industrial control tasks.
The eval set itself must be authored by practitioners who can construct non-canonical scenarios, write complete input sequences, and calibrate difficulty empirically against current models. Generic annotation cannot substitute for that expertise.
If you are building evals or post-training data pipelines for PLC, ladder logic, or adjacent industrial automation domains, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
Programmable Logic Controller programming is one of the most operationally consequential tasks in industrial automation. A ladder logic program that fails silently can halt a production line, damage equipment, or create unsafe conditions. When AI systems generate PLC code, the evaluation question is not whether the output looks plausible. The question is whether the logic is functionally correct under the full range of input conditions. This post describes how to build verifiable evaluation approaches for PLC and ladder logic generation, where frontier models fail, and what a rigorous eval pipeline requires.
Answer Capsule: Verifiable evaluation of PLC and ladder logic generation requires three components: a structured task specification with defined I/O maps and timing constraints, a simulation-based verifier that executes the generated logic against a scan-cycle model, and an expert-authored rubric for structural and safety properties that simulation cannot check. Aggregate pass/fail rates are insufficient; failure-mode analysis by rung class reveals where models break down.
Why PLC and Ladder Logic Generation Resists Generic Evaluation
Ladder logic is a graphical programming language standardised under IEC 61131-3. Its semantics are defined by the PLC scan cycle: inputs are read, the program is evaluated left-to-right and top-to-bottom across rungs, and outputs are written. This execution model is deterministic but stateful. A rung that appears syntactically correct can produce wrong output when coil latching, timer accumulation, or counter overflow interacts with a specific input sequence.
Generic evaluation approaches fail here for three reasons. First, most LLM benchmarks treat code generation as a static text-matching or unit-test problem. Ladder logic correctness is a temporal property: the program must produce the right output across a sequence of scan cycles, not just at one moment. Second, the domain vocabulary is narrow and specialist. Training corpora contain very little IEC 61131-3 structured text or ladder logic notation relative to Python or C. Third, the consequences of subtle errors are asymmetric. A latched output coil that never de-energises is a safety hazard, not a style issue.
For more on why verifiable rewards are difficult to construct for tasks that resist automatic grading, see the Chiron Data Labs analysis of tasks that resist automatic grading.
Verifiable Evaluation Approaches: The Three-Layer Stack
A complete verifiable evaluation approach for PLC and ladder logic generation requires three distinct layers. Each layer catches a different failure class. No single layer is sufficient alone.
Layer 1: Simulation-Based Functional Verification
The primary verifier executes the generated ladder logic against a scan-cycle simulator with a defined input sequence. The verifier checks that outputs match the expected truth table across every step of the sequence.
The protocol is as follows:
Define the I/O map: input bits, output coils, internal memory bits, timers, and counters with their data types and address ranges.
Specify the input sequence as a time-ordered list of scan-cycle states. Each state is a vector of input bit values.
Specify the expected output vector for each scan cycle in the sequence.
Parse the generated ladder logic into a rung graph. Reject malformed programs at this stage and record the parse error class.
Execute the rung graph against the scan-cycle simulator. Record the output vector at each step.
Compare actual vs. expected output vectors. Compute the fraction of scan cycles where all outputs match exactly.
Partial credit is possible but must be defined in advance. A program that is correct for 18 of 20 scan cycles but fails on the two cycles involving timer expiry has a different failure profile than one that is wrong from cycle one. Both matter; they matter differently.
Layer 2: Static Analysis for Safety and Structural Properties
Simulation verifies functional correctness on the specified input sequence. It cannot verify properties that depend on inputs outside that sequence, nor structural properties that are independent of execution. Static analysis covers these.
Key static checks for ladder logic evaluation tasks:
Duplicate output coils: Multiple rungs writing to the same output coil. The last rung wins in most PLC implementations, but this is almost always a logic error.
Unlatched outputs: An output coil that can be set (energised) but has no rung that can de-energise it, or vice versa.
Unreachable rungs: Rungs with contact conditions that are structurally impossible given the I/O map.
Timer and counter misuse: Timers used without a reset rung, or counter preset values inconsistent with the task specification.
Undeclared addresses: References to I/O addresses not defined in the task I/O map.
Each of these checks is binary and automatable. They should be run before simulation and reported separately. A program that passes simulation but has a duplicate output coil has a latent defect that will surface under a different input sequence.
Layer 3: Expert Rubric for Non-Automatable Properties
Some properties of industrial ladder logic cannot be verified by simulation or static analysis. They require practitioner judgment. These include: whether the program structure follows industrial conventions (for example, safety interlocks placed before output rungs), whether the logic is maintainable and legible to a controls engineer, and whether the approach to a given control problem matches accepted practice in the relevant industry sector.
Expert rubrics for these properties must be anchored to observable rung-level features, not holistic impressions. For rubric design principles that apply across expert domains, see the Chiron Data Labs post on rubric design, criteria, weights, and anchors.
Illustrative Example: A Motor Start-Stop Sequence Eval Task
Illustrative example (numbers and details are constructed to demonstrate the method, not drawn from a specific deployment):
Task specification: Generate IEC 61131-3 ladder logic for a three-wire motor start-stop circuit with the following requirements. Inputs: I0.0 (normally open start pushbutton), I0.1 (normally closed stop pushbutton), I0.2 (normally closed overload relay). Output: Q0.0 (motor contactor coil). Behaviour: pressing start energises the contactor; the contactor seals in via a parallel contact on Q0.0; pressing stop or overload trip de-energises the contactor.
I/O map: three input bits, one output bit, no timers or counters.
Input sequence for simulation (10 scan cycles):
Cycles 1-2: all inputs at rest (I0.1 and I0.2 high, I0.0 low). Expected Q0.0 = 0.
Cycle 3: I0.0 momentarily high. Expected Q0.0 = 1.
Cycles 4-6: I0.0 returns low. Expected Q0.0 = 1 (seal-in).
Cycle 7: I0.1 momentarily low (stop pressed). Expected Q0.0 = 0.
Cycles 8-10: all inputs at rest. Expected Q0.0 = 0.
A model that generates the start rung without the seal-in contact on Q0.0 will pass cycles 1-3 and fail cycle 4. This is a distinct failure mode from a model that omits the normally closed contacts for stop and overload, which will pass cycles 1-6 and fail cycle 7. Simulation with a step-by-step input sequence separates these two failure classes. Aggregate pass/fail on the full sequence does not.
Static analysis on this task checks: is Q0.0 the only output coil? Is I0.2 used as a normally closed contact (not normally open)? Are there any undeclared addresses?
Expert rubric: is the seal-in contact placed in parallel with the start contact on the same rung (standard practice) rather than on a separate rung (functional but non-standard)?
Common Failure Modes in PLC and Ladder Logic Generation Evals
The following failure modes appear repeatedly when evaluating frontier models on ladder logic tasks. Each is detectable and has a specific fix in eval design.
1. Contact polarity inversion. Models generate normally open contacts where normally closed contacts are required, or vice versa. Detection: static analysis of contact type against I/O map annotations. Fix: annotate each I/O address in the task spec with its default state and required contact type; include at least two scan cycles where the distinction matters.
2. Missing seal-in logic. Models generate momentary output activation without the latching rung needed for maintained operation. Detection: simulation with a multi-cycle input sequence where the trigger input returns to rest. Fix: always include post-trigger scan cycles in the input sequence.
3. Timer preset and base unit errors. Models specify timer preset values in the wrong unit (seconds vs. milliseconds vs. scan cycles) or omit the timer reset rung. Detection: simulation against a sequence long enough to observe timer expiry; static check for reset rungs. Fix: require the task spec to state timer base unit explicitly and include timer expiry in the input sequence.
4. Structured text leakage. Models trained on mixed IEC 61131-3 corpora generate structured text or function block code when ladder logic is requested. Detection: parser rejection at Layer 1. Fix: specify the target representation unambiguously in the task prompt; record parser rejection as a distinct failure class, not a simulation failure.
5. Hallucinated I/O addresses. Models reference addresses outside the defined I/O map. Detection: static analysis. Fix: include an explicit I/O map in the task spec and flag any undeclared address as an automatic failure.
6. Eval contamination via training exposure. Standard motor start-stop circuits appear in PLC textbooks and are likely in training corpora. Models may reproduce a memorised circuit rather than reasoning from the specification. Detection: vary the I/O addresses, contact polarities, and behavioural requirements from canonical examples. Measure pass@k across multiple prompt variants; low variance at k=1 with high variance across prompt variants suggests retrieval rather than reasoning. For a broader treatment of difficulty calibration and task tiers, see difficulty ladders and graded task tiers.
Where This Approach Breaks Down
Simulation-based verification is only as good as the input sequence. A sequence that does not cover edge cases, such as simultaneous conflicting inputs, power-cycle restart behaviour, or counter rollover, will not detect failures in those conditions. Constructing complete input sequences for complex programs with multiple interlocks and timers is itself a specialist task requiring practitioner authorship.
Static analysis catches structural defects but cannot verify intent. A program can be structurally clean and functionally wrong if the logic addresses the wrong problem.
Expert rubrics introduce inter-rater variability. Two controls engineers may disagree on whether a particular rung structure is acceptable practice. Rubric calibration with gold-standard examples and explicit anchor descriptions reduces but does not eliminate this variability. The Chiron Data Labs post on preference pairs in technical domains addresses how to handle cases where ground truth is contested.
Finally, difficulty drifts. A task that frontier models fail today may be solved reliably in six months. Pass@k scores are model-specific and date-specific. Eval sets require periodic recalibration against current model families.
Frequently Asked Questions
What simulation environment is appropriate for verifying generated ladder logic?
Any environment that implements the IEC 61131-3 scan-cycle execution model is suitable. Open-source PLC simulation libraries exist for Python. The requirement is deterministic execution of rung evaluation order and correct handling of coil state across scan cycles. The specific tool matters less than whether it faithfully implements the target PLC's execution semantics, including edge cases such as coil evaluation order when multiple rungs write the same address.
How many input-sequence steps are needed for a reliable eval?
The minimum is one scan cycle per distinct behavioural state the specification requires, plus at least one transition between each adjacent pair of states. For a simple start-stop circuit with three states (off, starting, running, stopping), a minimum sequence is eight to twelve scan cycles. For programs with timers or counters, the sequence must be long enough to observe at least one full timer or counter cycle. Sequences shorter than this will miss the most common failure modes.
Can LLM-as-judge replace simulation for ladder logic evals?
No. LLM-as-judge agreement with expert judgment on ladder logic correctness has not been established, and the failure modes that matter most, such as missing seal-in logic or timer unit errors, are exactly the failure modes that LLM judges are likely to miss because they require scan-cycle-level reasoning. Use LLM-as-judge only for rubric dimensions that are explicitly structural or stylistic, never for functional correctness.
How should difficulty be calibrated across a ladder logic eval set?
Measure pass@k (the probability that at least one of k independently sampled completions is correct) against two or more frontier models. Tasks where pass@1 exceeds 0.8 across all tested models are too easy for post-training signal. Tasks where pass@k at k=10 is zero for all tested models may be under-specified or have verifier bugs. The target range for training tasks is pass@1 between 0.1 and 0.5, with pass@k at k=5 above 0.3. For evals, harder tasks with lower pass@k are appropriate. See also the discussion of RLVR beyond math and code for how verifiable rewards apply to engineering domains.
What makes a ladder logic task resistant to contamination?
Tasks are contamination-resistant when the specific combination of I/O configuration, behavioural requirements, and timing constraints does not appear in publicly available PLC training materials. This requires expert authorship of novel scenarios, not adaptation of textbook examples. For a framework on authoring tasks that are original and verifiable from specification to rubric, see the expert task authoring playbook.
What This Means in Practice
Evaluating PLC and ladder logic generation is not a text-similarity problem. It is a functional verification problem with a temporal dimension, a static analysis dimension, and a practitioner judgment dimension. Each dimension catches failure modes the others miss. Treating any one layer as sufficient will produce eval results that do not predict real-world model behaviour on industrial control tasks.
The eval set itself must be authored by practitioners who can construct non-canonical scenarios, write complete input sequences, and calibrate difficulty empirically against current models. Generic annotation cannot substitute for that expertise.
If you are building evals or post-training data pipelines for PLC, ladder logic, or adjacent industrial automation domains, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.