Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › industrial automation

How an AI Agent Built and Tested Siemens S7-1500 SCL Through an MCP Bridge

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes—an AI agent can program a Siemens S7-1500 in TIA Portal, but the important achievement is not code generation alone. In an October 12, 2026 experiment, a WorkBuddy agent used the TiaLink MCP server and Siemens Openness API to prepare a TIA Portal V19 project, launch S7-PLCSIM, create a reusable conveyor-sorting function block and data types, write SCL, compile and download it, and run the result in simulation. The workflow also produced 14 automated test cases and a race-and-boundary analysis before treating the program as complete.

This article explains what that workflow actually proved, how the SCL state machine was structured, which edge cases it found, and where simulation stops short of commissioning a real machine.

As an Amazon Associate I earn from qualifying purchases.

What the AI agent did in TIA Portal

The experiment connected an AI agent to TIA Portal V19 through two layers. TiaLink supplied the MCP bridge, exposing engineering actions as tools the agent could call. Siemens Openness API provided programmatic access to the TIA Portal project. Together, they let the agent perform project operations instead of merely returning text that a human would have to paste into an editor.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Prepared the hardware. It checked for an S7-1500 CPU 1511-1 PN and added that CPU when the project did not already contain it.
  2. Started the simulator. S7-PLCSIM was launched so the generated program had a controller target before code generation was considered finished.
  3. Created reusable data structures. The agent added a conveyor-sort function block and user-defined data types (UDTs), using an instance data block rather than duplicated networks or copied logic.
  4. Wrote and compiled SCL. The block was generated in Structured Control Language, compiled in TIA Portal, and checked for errors.
  5. Downloaded and ran the program. The compiled project was downloaded to the simulated CPU and executed in S7-PLCSIM.
  6. Tested behavior. The deliverables included 14 automated test cases, a state-transition document, and an analysis of races and boundary conditions.

That sequence matters because the environment was created before the control logic was treated as valid. A text-only answer can look plausible while targeting the wrong CPU, using unavailable instructions, or leaving the project impossible to compile. The bridge made those failures visible in the engineering toolchain.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

What an MCP bridge contributes

Model Context Protocol (MCP) is a way to expose tools and structured context to an AI model. In this case, the TiaLink MCP server acted as the connection between the agent and TIA Portal. The agent could ask for project state, invoke an engineering operation, inspect the result, and decide what to do next.

The bridge is not a PLC runtime and it does not make generated logic safe by itself. It is an automation layer around engineering software. Siemens Openness remains the component that changes the TIA Portal project; TIA Portal remains responsible for compiling and downloading; S7-PLCSIM remains the simulated controller. Keeping those roles separate makes failures easier to diagnose.

For readers asking whether an AI can “program” an S7-1500, the precise answer is: it can automate many project and coding actions when the required APIs, licenses, versions, and permissions are available. A human still has to define the machine requirements, approve the design, review generated artifacts, and validate the physical system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the conveyor-sorter SCL was organized

The reported block, FB_ConveyorSort, used an integer state machine. State numbers were deliberately kept identical to the written specification, so an HMI, alarm list, test script, and technician looking at a trace could refer to the same state number. This is a practical debugging convention: changing a state label in one artifact but not another creates needless translation errors.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Inputs, outputs and retained status

The interface separated physical inputs, commanded outputs, and internal status variables. Inputs represented conditions such as the entry photo-eye, position or arrival sensing, quality information, cylinder end sensors, reset, and stop. Outputs represented conveyor and cylinder commands. Internal variables held the current state, timer instances, edge or latch flags, quality status, and fault information.

An instance DB stored the block’s state for each conveyor sorter. That allows the same FB to be reused for multiple stations without copying its logic and gives each instance an independent set of timers and latches.

IEC timers and explicit transitions

IEC timer instances handled waiting periods and timeout supervision. The state machine changed state only on explicit transition conditions, rather than relying on an output remaining true from a previous scan. Siemens’ STEP 7 documentation for S7-1500 SCL covers these timers, control-flow instructions, runtime control, diagnostics, symbolic addressing, PLC data types, and IEC counters.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Deterministic outputs every scan

One of the strongest design rules was to assign every output a defined value on every PLC scan. The block first sets commands to safe defaults, then enables only the outputs required by the active state and interlocks. If a previous state extended a cylinder but the current state does not, the extension command is explicitly turned off instead of surviving accidentally.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

This pattern also makes single-step simulation meaningful. A trace shows what the current state requests, not a mixture of the current state and stale commands from an earlier scan.

Illustrative SCL pattern

The following is a representative pattern showing the design principles; it is not a verbatim listing of the experiment’s project. The state constants, signals and timer presets must be replaced with the names and requirements of a particular machine.

FUNCTION_BLOCK FB_ConveyorSort
VAR_INPUT
    EntrySensor       : BOOL;
    PartAtSort        : BOOL;
    QualityAtEntry    : BOOL;
    CylinderA_Retract : BOOL;
    CylinderA_Extend  : BOOL;
    CylinderB_Retract : BOOL;
    CylinderB_Extend  : BOOL;
    Reset             : BOOL;
    Stop              : BOOL;
    SafetyOK          : BOOL;
END_VAR
VAR_OUTPUT
    ConveyorRun       : BOOL;
    CylinderA_Command : BOOL;
    CylinderB_Command : BOOL;
    Fault             : BOOL;
    StateNumber       : INT;
END_VAR
VAR
    State             : INT;
    EntryLatched      : BOOL;
    QualityLatched    : BOOL;
    FaultLatched      : BOOL;
    ArrivalTimer      : TON;
END_VAR
BEGIN
    // Defaults are written on every scan.
    ConveyorRun       := FALSE;
    CylinderA_Command := FALSE;
    CylinderB_Command := FALSE;

    IF NOT SafetyOK THEN
        FaultLatched := TRUE;
    END_IF;

    IF Reset AND SafetyOK THEN
        FaultLatched := FALSE;
    END_IF;

    Fault := FaultLatched;
    StateNumber := State;

    CASE State OF
        0: // Idle
            IF EntrySensor AND NOT EntryLatched THEN
                EntryLatched := TRUE;
                QualityLatched := QualityAtEntry;
                State := 10;
            END_IF;
        10: // Transport and supervise arrival
            ConveyorRun := NOT FaultLatched AND NOT Stop;
            // Start/use an IEC timer and define an explicit timeout transition.
        20: // Sort
            // Permit only one cylinder and require the opposite cylinder retracted.
        30: // Clear and return
            IF NOT EntrySensor THEN
                EntryLatched := FALSE;
                State := 0;
            END_IF;
    END_CASE;
END_FUNCTION_BLOCK

A production implementation must complete every transition, timer call, fault path and sensor plausibility check. The value of the pattern is its discipline: defaults first, one state owner, latched decisions where timing requires them, and explicit recovery.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The race conditions the test plan exposed

Entry de-duplication versus a stuck photo-eye

The entry sensor was de-duplicated by latching the detection until the part left the sensor. Without that latch, a single part can be counted repeatedly while the photo-eye remains blocked for several scans. The opposite failure is also important: if the photo-eye never clears, the latch never re-arms and subsequent parts are missed.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Therefore, de-duplication is not a complete solution on its own. The process must guarantee enough spacing for the sensor to clear, or the program needs a separate stuck-sensor timeout and fault policy. That policy should identify the blocked sensor, stop or inhibit new parts as required, and provide a defined reset path.

When to latch the quality result

The experiment latched the quality result at entry, not at the downstream sort station. This avoids a timing race in which the quality signal changes near the moment the position sensor reports arrival. If quality is sampled only at the sorter, network delay, sensor latency or a changing inspection result can associate one part’s result with another part.

Entry latching is a process-timing choice, not a universal rule. Commissioning must confirm that the quality signal is valid when the entry event occurs and remains associated with that physical part. If the inspection completes later, the design needs a handshake, a queue or another explicit association mechanism rather than an optimistic sample.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Arrival and timeout on the same scan

A state that waits for a part to arrive usually also runs a timeout. On the exact scan when the arrival signal becomes true and the timer reaches its limit, both conditions can be true. The program must define which event wins. Giving arrival priority may accept a part at the boundary; giving timeout priority may fault it. Either choice can be correct for a particular process, but leaving the priority implicit produces nondeterministic expectations in tests and troubleshooting.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Two cylinders requested together

The reported logic interlocked the two cylinders so simultaneous extension commands were blocked. It also required the opposite cylinder’s retracted-end sensor before permitting an extension. This protects against a contradictory command caused by a state-transition error, a stale signal, or an unexpected manual request.

Sensor plausibility matters as much as command interlocking. If a cylinder’s extended and retracted end sensors are asserted at the same time, the condition is physically implausible and should produce a diagnostic fault rather than allowing the state machine to continue as if the feedback were trustworthy.

Emergency-stop and safety boundaries

The experiment treated emergency stop as a safety-circuit status input. It did not claim that ordinary PLC code could replace a safety function. A standard S7-1500 program can respond to a safety-status signal by stopping commands or entering a fault state, but the safety function itself may require appropriate safety hardware, wiring, validation and a safety-rated controller architecture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What was verified—and what was not

The agent demonstrated that the project could be assembled, compiled, downloaded and exercised in S7-PLCSIM. The test artifacts demonstrated repeatable software behavior for the modeled inputs and transitions. Siemens describes the S7-1500 as a high-performance PLC family integrated with TIA Portal for configuration, programming, diagnostics and maintenance, with PROFINET and Industrial Ethernet/OPC UA connectivity. Its CPUs are the central processing units of the SIMATIC S7-1500 system.

Simulation is still a separate layer from a machine. The experiment did not bench-test real pneumatics, sensor chatter, network jitter, safety relays or emergency-stop circuitry. S7-PLCSIM cannot reproduce every mechanical delay, valve failure, wiring fault or electromagnetic disturbance. A successful simulated run is evidence that the software model behaves as designed under its modeled conditions; it is not a production-commissioning result.

How to reproduce the verification-first workflow

  1. Write the specification first. Define numbered states, permitted transitions, inputs, outputs, timeout behavior, reset behavior and fault responses. Keep the numbers stable across the HMI, alarms and tests.
  2. Prepare a disposable project. Use TIA Portal V19 with the intended S7-1500 CPU type, and make a versioned backup before allowing an automated client to modify the project.
  3. Connect the bridge. Configure the TiaLink MCP server and Openness access with the least permissions needed. Confirm that the agent can inspect the project before granting write operations.
  4. Start S7-PLCSIM. Establish the simulated CPU target before generating code. If the selected device or firmware does not match, resolve that mismatch before debugging the state machine.
  5. Generate reusable artifacts. Create the FB, UDTs and instance DB. Keep physical inputs, commanded outputs and internal status separate so tests can drive and observe them independently.
  6. Implement scan-safe logic. Set every output to a defined default each scan, then apply state-specific commands and interlocks. Add explicit sensor plausibility, timeout, stop and reset paths.
  7. Compile before download. Treat compile diagnostics as a required gate. Do not proceed because the generated text “looks right.”
  8. Run transition tests. Exercise normal transport, accepted and rejected quality, reset, stop, timeout, stuck entry sensor, contradictory sensors, simultaneous cylinder requests and boundary timing.
  9. Review the artifacts manually. A controls engineer should inspect the SCL, state diagram, test results, diagnostic messages and safety assumptions before any connection to real equipment.

AI-assisted and conventional PLC engineering compared

Evaluation axis AI-agent workflow in the experiment Conventional text-first workflow
Environment setup Checked or added the CPU, started S7-PLCSIM and operated on a real TIA Portal project before execution. Often begins with manually creating the device and importing or typing code; setup quality depends on the engineer.
TIA Portal compatibility Used TiaLink plus Openness with TIA Portal V19; compatibility depends on installed versions and permissions. Engineer works directly in the installed TIA Portal version.
Simulator support Downloaded and ran the generated program in S7-PLCSIM. Simulation is available, but test preparation and stimulus usually remain manual unless separately automated.
Scan determinism Explicit per-scan output defaults and state transitions were part of the generated design. Must be enforced by the engineer; copied networks can accidentally retain commands.
Test coverage Produced 14 automated cases plus a state-transition document. Coverage varies widely with the team’s test process.
Race analysis Called out sensor de-duplication, quality-latch timing and arrival-versus-timeout boundaries. Requires deliberate review; it is easy to omit from a code-only review.
Safety boundary Kept emergency-stop logic as a safety-status response and did not claim ordinary code was a safety function. Responsibility rests with the engineering and safety team.
Human approval Still required for requirements, generated artifacts, test interpretation and physical commissioning. Required throughout, with fewer automated drafting steps.

Practical limits before using generated code on equipment

  • Version and license matching: TIA Portal, Openness, the MCP server, the CPU catalog entry and PLCSIM must be compatible. A workflow that succeeds in V19 is not automatically portable to another major version.
  • Permission control: Keep write access restricted and work from a recoverable project copy. An agent that can add devices or download code can also make consequential changes quickly.
  • Traceability: Store the generated SCL, UDT definitions, state specification, test inputs and test outputs together. State numbers are useful only when these artifacts stay synchronized.
  • Physical timing: Replace assumed sensor and actuator timing with measured values during commissioning. Network and pneumatic delays can invalidate a simulation-only timeout.
  • Fault recovery: Specify what an operator sees, what must be cleared, and whether a reset is manual or automatic. A latched fault without a clear recovery procedure is not a finished control design.
  • Safety validation: Have the responsible safety engineer validate emergency-stop circuits, interlocks, risk reduction and the applicable standards. Do not convert a software input into a claim of safety integrity.

Bottom line

The S7-1500 experiment shows a credible use for AI in PLC engineering: automate project setup, generate structured SCL, compile it in the target environment, and force the design through repeatable simulation tests. Its most valuable contribution was verification-first thinking. The agent exposed races around sensor latching, quality timing, timeout boundaries and contradictory actuator feedback that a code-only answer could miss.

That result supports AI as an engineering assistant, not as an unsupervised machine designer. A simulated CPU can confirm software transitions; only disciplined review, safety engineering and physical commissioning can establish that a real conveyor and its protective functions are ready to run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

industrial automationMCPPLC programmingS7-PLCSIMSCLSiemens S7-1500state machinesTIA Portal

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.