PLCSIM Advanced
PLCSIM Advanced

S7-PLCSIM Advanced and Its API: Turning Your Siemens PLC into Software

In modern automation projects, you’re often blocked not by your own code, but by hardware: panels aren’t wired yet, CPUs are on backorder, or the machine is still a pile of steel in a workshop. That’s where simulation becomes a superpower.

For Siemens TIA Portal users, that simulation tool is S7-PLCSIM — and especially S7-PLCSIM Advanced, which takes your PLC from a box of electronics to a software-defined controller that can be automated, scripted, and connected just like the real thing.

This article walks through:

  • What PLCSIM and PLCSIM Advanced are
  • Why PLCSIM Advanced matters for serious projects
  • How its API (C#/C++) lets you drive the simulated PLC like a service
  • Typical use cases and best practices

Links to Download

https://support.industry.siemens.com/cs/document/109963863/?lc=it-it


1. Classic PLCSIM vs PLCSIM Advanced

Siemens has essentially two generations of PLC simulation:

S7-PLCSIM (classic, built into TIA Portal)

This is the one most people see first:

  • Integrated directly into TIA Portal
  • Great for quick logic tests: you write a program, start PLCSIM, download, toggle a few bits
  • Communication is via a local “Softbus” only
  • No real Ethernet presence on the network
  • Limited ways to connect external tools (no official .NET API to drive it)

For simple “does my code compile and toggle bits correctly?” tasks, classic PLCSIM does the job.

S7-PLCSIM Advanced

S7-PLCSIM Advanced turns simulation into a proper software product:

  • Runs as its own runtime service with a Control Panel UI
  • Simulates S7-1500 / ET 200SP CPUs as PLC instances
  • Supports:
    • Local Softbus mode (PLCSIM)
    • TCP/IP via PLCSIM Virtual Ethernet Adapter (Single/Multiple Adapter)
  • Can participate in real network communication:
    • Modbus TCP, T-blocks, S7 communication, OPC UA server, Web server, etc.
  • Provides an API for .NET and C++ so external applications can:
    • Start/stop instances
    • Read/write tags
    • Control virtual time and synchronization

In other words: classic PLCSIM is a PLC simulator inside TIA Portal; PLCSIM Advanced is a PLC simulator that behaves like a real device and exposes a programmable interface.

Video:


2. Architecture: Runtime Manager and PLC Instances

S7-PLCSIM Advanced is built around a few core concepts:

Runtime Manager

The Runtime Manager is the “host” process that manages everything:

  • Keeps track of all registered PLC instances
  • Exposes an API endpoint for local/remote tools
  • Manages communication modes (Softbus or TCP/IP)

Your C# / C++ application doesn’t talk to the PLC directly; it first talks to the Runtime Manager, which then gives you an interface to a specific instance.

PLC Instances

Each simulated PLC is called an instance:

  • Has a unique ID and Name
  • Corresponds to a virtual S7-1500 / ET 200SP CPU
  • Has its own:
    • Program + hardware configuration (from TIA Portal)
    • IP address (if using TCP/IP)
    • Diagnostic buffer, LEDs, RUN/STOP state
    • Virtual memory card (files stored on disk)
  • Shows up in the Control Panel and is visible to the API

You can run multiple instances at the same time on one PC (depending on license and performance), which is ideal for multi-PLC systems.


3. Online Access and Communication Modes

PLCSIM Advanced supports different online access modes:

1. PLCSIM (Softbus)

  • Local, non-Ethernet software bus
  • Communication is limited to the same machine
  • No risk of accidentally talking to real hardware
  • Perfect for:
    • Early testing
    • Basic virtual commissioning inside a single PC
  • Your C# / C++ API client will happily work in this mode.

2. TCP/IP – PLCSIM Virtual Ethernet Adapter

For realistic network simulation, you can switch online access to TCP/IP:

  • Single Adapter
    • Virtual switch can see all frames (promiscuous mode) on a bound NIC
    • Good for lab networks / dedicated test segments
  • Multiple Adapter
    • Non-promiscuous, more IT-friendly
    • Better suited to corporate networks and VMs

In TCP/IP mode, a simulated PLC:

  • Has an IP address, subnet mask, gateway
  • Can serve as:
    • Modbus TCP client or server
    • OPC UA server
    • Web server
    • Communication partner for real HMIs, SCADA, other PLCs

Your API client still connects to the Runtime Manager, but the PLC itself “looks” like a hardware CPU on the network.


4. Virtual Time: Slowing Down or Fast-Forwarding the PLC

One of the coolest features is virtual time.

PLCSIM Advanced maintains:

  • A real time (the wall-clock time on your PC)
  • A virtual PLC time that your program sees (system time, timers, etc.)

You can apply a time scaling factor:

  • 1.0 → PLC runs in real time
  • > 1.0 → PLC runs faster than real time
  • < 1.0 → PLC runs slower than real time

Why this matters:

  • Fast-forward long batch processes or recipes to see end-states quickly
  • Slow down sequences for teaching, debugging or training
  • Synchronize a PLC with a co-simulation (e.g. 3D model) that advances in discrete time steps

The API exposes methods to:

  • Get/set the virtual system time
  • Get/set the time scale factor
  • Use synchronization modes (run to sync points and pause until the external simulator says “continue”)

This is exactly what you want for a digital twin or hardware-in-the-loop style environment.


5. The PLCSIM Advanced API in a Nutshell

The API is available for:

  • .NET (C#, VB.NET)
  • C++ (via COM-style interfaces)

On the .NET side, the key classes/interfaces are typically:

  • SimulationRuntimeManager (or similar)
    • Static/instance members to:
      • Check if the Runtime Manager is available
      • Get a list of registered instances
      • Create an interface to a specific instance
  • IInstance
    • Represents one PLC instance
    • Gives you control over:
      • Operating state (Off / On / Run / Stop)
      • PowerOn / PowerOff / Run / Stop
      • Virtual time
      • Tag read/write
      • Tag list status
      • Synchronization mode, etc.

Typical API workflow (C#)

  1. Check Runtime Manager availability if (!SimulationRuntimeManager.IsRuntimeManagerAvailable) { Console.WriteLine("Runtime Manager not available."); return; }
  2. Get list of instances var instances = SimulationRuntimeManager.RegisteredInstanceInfo; foreach (var info in instances) Console.WriteLine($"{info.ID}: {info.Name}");
  3. Create interface to one instance IInstance plc = SimulationRuntimeManager.CreateInterface(instanceId);
  4. Power on and run (optional — you can also power on from the UI) plc.PowerOn(60000); // timeout in ms plc.Run(60000);
  5. Update tag list plc.UpdateTagList(); // optionally wait for up-to-date status
  6. Read/write tags by name bool motorOn = plc.ReadBool("MotorOn"); plc.WriteBool("StartButton", true);
  7. Control virtual time var currentScale = plc.GetScaleFactor(); plc.SetScaleFactor(2.0); // run 2x faster than real-time
  8. Clean up plc.Dispose(); SimulationRuntimeManager.Shutdown();

The calls are synchronous with timeouts, and the API uses exceptions/error codes to report issues like:

  • Instance not running
  • Tag list not up-to-date
  • Communication problems with Runtime Manager

6. What You Can Build With the PLCSIM API

Once you can drive a simulated PLC from code, a lot of possibilities open up.

1. Custom “soft HMIs” or test panels

You can build small C#/WPF applications that:

  • Expose a few buttons and lamps (“Start”, “Stop”, “Alarm Reset”, “Motor Running”)
  • Read and write PLC tags via the API
  • Simulate operator panels or test jigs

This is perfect for:

  • Demonstrating your logic for customers
  • Creating focused test tools for specific machines
  • Training new engineers on how the logic behaves

(Which is basically what you just did with your Antomatix-branded WPF app.)

2. Automated test harnesses

For more serious testing, you can build automated test harnesses:

  • A C# test runner that:
    • Powers on the PLC instance
    • Sets inputs to known states
    • Waits for outputs / internal tags to reach expected values
    • Logs pass/fail results with timestamps
  • Integrates with:
    • CI/CD pipelines
    • Version-control hooks
    • Test report dashboards

This moves you towards unit testing for PLC code and supports regression testing when making changes.

3. Digital twins and co-simulation

Combine PLCSIM Advanced with:

  • A 3D engine (Unity, Unreal, realvirtual.io, etc.)
  • A physics model
  • Or a process simulation (Simulink, Modelica, SIMIT, etc.)

Using the API you can:

  • Synchronize virtual time between PLC and simulation
  • Step both simulators in lockstep:
    • Simulation: computes next machine state
    • PLC: evaluates logic and produces new outputs
  • Inject faults, watch interlocks, test sequences under edge conditions

This is the essence of a digital twin: one or more real PLC programs running against a realistic virtual machine.

4. Educational tools and training scenarios

You can develop educational applications that:

  • Walk students/technicians through step-by-step exercises
  • Automatically reset PLC states between tasks
  • Log what the user did and when
  • Simulate rarely occurring faults by forcing conditions in the virtual plant

Because you can fully control what the PLC “sees”, you can create safe but realistic training environments.


7. Best Practices and Gotchas

If you plan to use S7-PLCSIM Advanced and its API seriously, a few things are worth keeping in mind:

  1. Match versions and bitness
    • Make sure your API DLL version matches your installed PLCSIM Advanced version
    • Match x64/x86 between:
      • Your application
      • The API DLL (...Api.x64 vs ...Api.x86)
    • Target a recent .NET Framework (e.g. 4.8) if the Siemens DLL requires it.
  2. Keep Runtime Manager and app in the same user session
    • Don’t mix admin/non-admin between PLCSIM and your app
    • They need to see the same Runtime Manager instance.
  3. Treat simulation as “close to real”, not perfect
    • Some hardware-specific features and timing behaviour are simplified
    • Passing simulation does not guarantee a perfect real-world startup
    • But it will catch a huge amount of logic errors and integration issues early.
  4. Use Softbus first, TCP/IP later
    • Start with PLCSIM (Softbus) while you’re developing API tools; it keeps things simple and isolated
    • Switch to TCP/IP when you need to integrate HMIs, OPC UA, SCADA, etc.
  5. Be deliberate with virtual time
    • Don’t immediately set crazy scale factors (like 100x faster)
    • Increase step-by-step and watch for:
      • Cycle time warnings
      • Motion control overruns
    • For reproducible tests, explicitly set the virtual time at the start of each scenario.

8. Conclusion

S7-PLCSIM Advanced is much more than a “PLC emulator.” Combined with its API, it turns your Siemens PLC program into a component of a larger software system:

  • It can be started, stopped, and inspected automatically
  • It can plug into 3D simulations, IIoT platforms, and CI pipelines
  • It lets you test and demonstrate your automation without waiting for hardware

For anyone serious about Siemens-based automation — especially if you’re working on virtual commissioning, digital twins, or just want better test coverage — investing time into PLCSIM Advanced and its API is absolutely worth it.

By admin

Related Post

Leave a Reply