An AI Agent Programmed a Siemens S7-1500 Through an MCP Bridge — Here's the SCL and the Race Conditions It Caught
Description and use
An LLM agent generated a conveyor‑sorting control program for a Siemens S7‑1500 using an MCP bridge and TIA Portal, ensuring deterministic outputs and full simulation verification.
Problem
Automate the creation of a conveyor‑sorting control program for a Siemens S7‑1500 using an LLM agent and an MCP bridge, ensuring correct engineering decisions, deterministic outputs, and full verification in simulation.
Outcome
The LLM agent built the verification environment first, then produced a fully deterministic SCL function block that met all engineering requirements, compiled without errors, and passed 14 automated test cases in simulation.
Workflow
- Check for existing CPU and add PLC_1
- Compile and start S7‑PLCSIM to confirm download/run
- Create FB_ConveyorSort and write state machine in SCL
- Create required UDTs
- Instantiate FB in OB1 with DB_ConveyorSort_1
- Compile and download program
- Deliver state transition table, 14 test cases, and race/boundary analysis
Evidence
We built an MCP server that drives Siemens TIA Portal V19 through the Openness API, pointed an LLM agent at it, and gave it a real engineering task: implement a conveyor‑sorting control program for an S7‑1500 (CPU 1511‑1 PN), verified in S7‑PLCSIM.
The whole loop: add CPU → compile → start simulator → create FB/UDTs → write SCL → compile → download → verify.
It built the verification environment first. Good sign.
Section 0 writes every output to a deterministic value at the top of the cycle (requirement #6).
- Record date: 2026-10-12T15:41:18.303Z