> For the complete documentation index, see [llms.txt](https://doc.realvirtual.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.realvirtual.io/components-and-scripts/interfaces/plcsim-advanced.md).

# PLCSIM Advanced (Pro)

Connecting virtual Siemens PLCs with realvirtual.io

{% hint style="warning" %}
This Interface is only available in realvirtual.io Professional
{% endhint %}

### Introduction

PLCCSIM-Advanced is a virtual PLC from Siemens. PLCCSIM-Advanced can be used to simulate S7-1500 PLCs. If you use PLCSim-Advanced no real PLC is needed.

> PLCCSIM-Advanced will work in a multi-threaded mode by starting a parallel .exe command line programm. The PLCCSIM-Advanced interface will only work in Windows environments.

Please check the Siemens Website for more information about PLCCSIM-Advanced:\
<https://w3.siemens.com/mcms/automation-software/de/tia-portal-software/step7-tia-portal/simatic-step7-options/s7-plcsim-advanced/seiten/default.aspx>

Here is a short Youtube Tutorial showing you the interface in action:

{% embed url="<https://youtu.be/BZtHKd0lCiY>" %}

{% hint style="info" %}
**realvirtual CONNECT talks to PLCSIM Advanced without a coupler.** If you use realvirtual WEB through realvirtual CONNECT, you do not need this interface, the coupler process or the shared-memory bridge at all: CONNECT drives the Siemens simulation API directly in its own process. It addresses tags **symbolically**, browses the instance's tag list, works with optimized data blocks and over Softbus, and needs neither PUT/GET nor absolute addresses. See [Supported Protocols — PLCSIM Advanced](https://realvirtual.io/doc/web/connect/interfaces/protocols/) in the CONNECT documentation. The Unity interface described below stays unchanged and is the right choice when the simulation runs in the Unity Editor or a Unity build.
{% endhint %}

### Interface configuration <a href="#interface-configuration" id="interface-configuration"></a>

For using the PLCSim-Advanced Interface, you need to add an interface to your scene by selecting *Tools > realvirtual> Add Component > Interface > PLCSIMAdvanced* or you add the Script SharedMemoryInterface to an empty Gameobject.

{% hint style="danger" %}
For working in a Unity Build, this interface requires `Allow unsafe Code` to be turned on in Player Settings.

<img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-72f996aae52438f9e537d227442f5316277e4e7f%2Fplcsimadvanced-unsafecode.png?alt=media" alt="" data-size="original">
{% endhint %}

{% hint style="info" %}
**New in Version 6.0.7**: The PLCSim Advanced Interface now features an automated setup system that streamlines the configuration process. The entire setup now takes 40-70 seconds with real-time progress indicators and automatic detection of Siemens DLLs.
{% endhint %}

### Automated Setup Process

As a prerequisite, you need to have PLCSIM-Advanced installed on your computer. Starting with version 6.0.7, the setup process has been greatly simplified with a single-click automated setup system.

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-9ee7dbb1e713a404851d002f432a88bdd0ba67b5%2Fplcsimadvanced-automated-setup.png?alt=media" alt="Automated setup interface showing dynamic status indicators and single-button setup"><figcaption><p>PLCSim Advanced automated setup interface with real-time progress indicators</p></figcaption></figure>

The automated setup performs two steps automatically:

1. **Auto-detect Siemens DLL**: The system automatically searches for the Siemens.Simatic.Simulation.Runtime.Api.x86.dll in four common installation paths. API 3.0 is checked first and preferred over API 2.0:

   * C:/Program Files (x86)/Common Files/Siemens/PLCSIMADV/API/3.0/ (checked first)
   * C:/Program Files (x86)/Common Files/Siemens/PLCSIMADV/API/2.0/
   * C:/Program Files/Common Files/Siemens/PLCSIMADV/API/3.0/
   * C:/Program Files/Common Files/Siemens/PLCSIMADV/API/2.0/

   The detected path is used as an installation check only — the DLL is no longer copied anywhere.
2. **Download PLCSimAdvancedCoupler.exe**: If not already present, the system automatically downloads the required coupler executable from the realvirtual repository.

{% hint style="warning" %}
**Delete an old Siemens DLL from StreamingAssets.** Earlier versions copied *Siemens.Simatic.Simulation.Runtime.Api.x86.dll* into the StreamingAssets folder as a third setup step. The coupler now loads the PLCSIM Advanced API that is actually installed on the machine, and a copy next to the executable shadows it — typically with the message "PLCSIMAdvanced Runtime Not available". If the file is still in your StreamingAssets folder, delete it. The interface writes a warning to the console when it finds it.
{% endhint %}

The **InfoBox** at the top of the inspector provides real-time feedback during setup:

* **⚠ Warning**: Indicates setup is required or incomplete
* **ℹ Progress**: Shows current operation in progress with detailed status
* **✓ Complete**: Confirms setup is finished and ready to use

Simply click the **"Setup PLCSim Advanced Interface"** button to start the automated setup process. The system will display progress for each step, and the entire process typically completes in 40-70 seconds.

### Connection Configuration

After setup is complete, configure the connection parameters:

<div align="center"><figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-9b0595f0e319bfa2506d64fe6219c3fbdbccf34f%2Fplcsimadvanced.png?alt=media" alt=""><figcaption><p>PLCSIM Advanced Interface connection settings</p></figcaption></figure></div>

For connecting you need to define the PLCCSIM-Advanced *Instance Name* as well as the synchronization cycle in Ms under *Sync Cycle Ms*:

If you select *Pause With Unity*, PLCCSIM-Advanced will pause as long as Unity is paused.

*DebugMode* turns on a special debug mode, where all signals are also displayed in the command line prompt. This might take quite a time during the simulation start. Please turn this off for productive use.

*If HMIOnly* is turned on, only variables which are marked as HMI variables in the PLC project itself are imported.

You are now able to import the Signals of PLCSim-Advanced by selecting *Import Signals*. All PLCSignals will be created automatically as sub-objects under the interface.

After importing the Signals you can start the simulation. The signals will be exchanged between Unity and PLCCSIM-Advanced automatically.

### Signal Import Filter

{% hint style="info" %}
This feature was added in realvirtual **6.3.6** (Professional).
{% endhint %}

Large PLC programs often contain many thousand signals, but a simulation usually needs only a small part of them. Every imported signal becomes a GameObject below the interface, so importing all of them makes entering play mode noticeably slower. With the signal import filter you decide which signals are imported at all.

Turn on **Use Signal Filter** to activate the filter:

* **Import Include Filters** – A list of regular expressions. A signal is imported when its name matches at least one of the patterns. An empty list imports all signals.
* **Import Exclude Filters** – A list of regular expressions. A signal matching any of these patterns is never imported. The exclude patterns are applied after the include patterns.
* **Filter Ignore Case** – Matches the patterns without regarding upper and lower case.
* **Signals Imported** / **Signals Filtered** – Show how many signals the last import created and how many were skipped.

Filtered signals are skipped before the GameObject is created, so they exist neither in the scene nor in the cyclic signal exchange.

Typical patterns:

| Pattern           | Matches                                       |
| ----------------- | --------------------------------------------- |
| `^HMI_`           | all signals starting with `HMI_`              |
| `Conveyor.*Speed` | `Conveyor1Speed`, `Conveyor_12_Speed`, …      |
| `^Axis[0-9]+_`    | `Axis1_Pos`, `Axis12_Speed`, …                |
| `^Diag_`          | as an exclude pattern: all diagnostic signals |

If a scene was already imported without a filter, define the filter and use **Delete Signals Not Matching Filter** to remove the signals which are no longer needed. Signals referenced by drives, sensors or scripts lose their connection when they are deleted, so the button asks for confirmation.

### Importing Data Block Tags

{% hint style="info" %}
This feature was added in realvirtual **6.3.6** (Professional) and requires PLCSimAdvancedCoupler.exe **6.1.11** or newer. Run **Setup PLCSim Advanced Interface** once to get the matching coupler.
{% endhint %}

By default the interface exchanges the process image only — inputs and outputs. Many TIA projects keep the values a simulation needs in global data blocks instead: setpoints, recipes, status words or a dedicated HMI interface DB. Those tags are imported on demand.

Enter the exact data block names in **Import Data Blocks**:

* Use the block name as it appears in TIA Portal, without quotation marks and **without wildcards**. Siemens only accepts exact names.
* A name that does not exist in the PLC program is ignored silently by PLCSIM Advanced. The coupler window therefore prints how many tags each requested block contributed — a block with `0 entries` is almost always a typo or a wrong upper/lower case spelling.
* **Data Block Tags Imported** shows how many data block tags the last import created.
* Names containing `;`, `"` or `\` cannot be passed to the coupler and are rejected with an error message.

Leave the list empty to keep the previous behaviour: only inputs and outputs are exchanged.

#### Direction: the signal type decides

The PLC cannot tell whether your simulation reads a data block tag or writes it, so the signal component below the interface decides — exactly like the [S7 TCP/IP interface](/components-and-scripts/interfaces/s7-tcp.md) handles DB addresses:

| Component on the tag's GameObject                            | Meaning                                                                                     |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| **PLCOutput…** (PLCOutputBool, PLCOutputInt, PLCOutputFloat) | The simulation **reads** the tag from the PLC. This is the default for newly imported tags. |
| **PLCInput…** (PLCInputBool, PLCInputInt, PLCInputFloat)     | The simulation **writes** the tag into the PLC.                                             |

To turn a tag into one the simulation writes, remove the **PLCOutput…** component from its GameObject and add the matching **PLCInput…** component instead. Keep the GameObject name unchanged — it is the PLC tag name. The new direction takes effect with the next import, which also happens automatically every time you enter play mode.

{% hint style="warning" %}
Change the direction in edit mode only. The direction of the running exchange is frozen at import time, so swapping a component while the simulation runs has no effect until the next import.

If the data type of a tag changed in TIA Portal (for example INT to REAL), the old signal component is still on the GameObject. The import reports such a tag with an error and skips it — delete the outdated component on that GameObject and import again.
{% endhint %}

#### Writing and reading the same tag

A tag the simulation writes is not read back while it is written: the value from Unity wins, and PLC writes through the API take effect at the cycle control point. Do not write a tag from the PLC program and from the simulation at the same time; decide per tag which side owns it.

#### Limits

* **Tag list size**: PLCSIM Advanced reserves memory for up to 500 000 tag list entries, and **every array and structure element counts**. Importing whole data blocks with large arrays can exceed this and makes the API report `NotEnoughMemory` (-43). The coupler then falls back to HMI-visible tags only and says so in its window. Import fewer blocks, or mark the needed tags as *Accessible from HMI* in TIA Portal and turn on **HMI Only**, which applies to data block tags as well.
* **Supported types**: BOOL, BYTE, WORD, DWORD, INT, DINT and REAL. Whole structures and arrays cannot be accessed by the API, so only their primitive elements are imported. 64-bit types (LINT, LREAL, LWORD) are not transported for data block tags, because they cannot be written safely through the 4-byte exchange slot.
* **Failsafe data blocks**: Variables in F-DBs and F-I/O DBs can only be changed while safety mode is deactivated (SIMATIC Safety — Configuring and Programming, chapter 10.7.4). Writing them from the simulation has no effect during safety operation.

{% hint style="warning" %}
Importing more than 2000 signals writes a warning to the console. Scenes with many thousand signal GameObjects take significantly longer to enter play mode — use the filter to keep the number of imported signals low.
{% endhint %}

{% hint style="info" %}
A separate .EXE file *PLCSimAdvancedCoupler.EXE* needs to be started for the PLCCSIM-Advanced Interface. This is due to the fact, that the Siemens DLLs can’t compile under Unity. For this the separate *PLCSimAdvancedCoupler.EXE* is creating a Shared Memory Interface to exchange the Signals between Unity and *PLCSimAdvancedCoupler.EXE*. The EXE itself is exchanging the values with PLCSim-Advanced. This is just for your information, as *PLCSimAdvancedCoupler.EXE* is part of the asset delivery and is copied automatically to the StreamingAssets folder and will be started automatically during Simulation startup or for the import of signals.
{% endhint %}

### Compatibility and Automatic Recovery

#### Input write permissions

The interface and **PLCSimAdvancedCoupler.exe** must use matching shared-memory protocol versions. The updated interface requires **protocol 1** and refuses to start an older coupler. Update both files together. An incompatible download is rejected and the existing executable is retained.

The other direction is covered as well: a coupler **6.1.12 or newer** also serves interfaces of realvirtual versions before 6.3.6. It notices within a few seconds that such an interface publishes no write permissions and then exchanges the inputs exactly as the earlier couplers did, so the public download link can always carry the current coupler without breaking older installations. The coupler window reports this as *Legacy client detected*; the per-input write permissions described below need the current interface.

Only imported inputs with **Active** enabled are written to the PLC. Excluded or inactive inputs are left untouched; disabling an input does not reset its value in the PLC. Writes start after the interface has transferred a complete set of values and permissions. Importing signals or rebuilding the connection does not by itself enable input writes.

#### Usage example

Import the required PLC tags, then assign the generated signal to your simulation component. For example, a simulated sensor can supply an input during initialization and subsequent physics updates:

```csharp
using realvirtual;
using UnityEngine;

public class SimulatedSensor : MonoBehaviour
{
    public PLCInputBool SensorInput;
    public bool Occupied;

    private void Awake()
    {
        SensorInput.Value = Occupied;
    }

    private void FixedUpdate()
    {
        SensorInput.Value = Occupied;
    }
}
```

Assign the signal before entering Play mode. Use **Import Include Filters** to select only the inputs your model supplies. Set **Active** to false to stop writing an individual input after the next interface update. PLC outputs remain readable.

Siemens also supplies a Visual Studio co-simulation example under [Entry 109739660: S7-PLCSIM Advanced Getting Started](https://support.industry.siemens.com/cs/ww/en/view/109739660). It demonstrates API-based sensor updates; it is not a dedicated Safety test example.

For F-inputs, explicitly identify the channel and its value-status signal from your TIA project. The interface does not identify Safety tags automatically or set them to true. Any simulated channel fault must use the appropriate channel/value-status combination. These semantics and the distinction between F-input simulation and modifying F-DBs are described in [Siemens: Testing the Safety program with S7-PLCSIM/S7-PLCSIM Advanced](https://docs.tia.siemens.cloud/r/en-us/v20/simatic-safety-configuring-and-programming/compiling-and-commissioning-a-safety-program/testing-the-safety-program/testing-the-safety-program-with-s7-plcsim/s7-plcsim-advanced).

The write-permission correction addresses general input handling. A project-specific Safety failure has not been reproduced.

{% hint style="info" %}
This behavior was improved in realvirtual **6.3.5** (Professional).
{% endhint %}

The coupler is tolerant of the installed PLCSIM Advanced version. It automatically loads with a compatible API version, so the same build connects whether you run an older PLCSIM Advanced installation or a current V8 runtime — no manual DLL selection is required for the connection to succeed.

When you download a changed program from TIA Portal onto the running PLC, the interface no longer stops. Signal exchange is paused while the download is in progress, and the interface automatically reconnects and re-imports the (possibly changed) signals once the download has finished.

For diagnostics the coupler writes a **coupler.log** next to *PLCSimAdvancedCoupler.exe*. It records the loaded API version, the running Runtime Manager version and any communication errors — send this file if you ever need support. The previous run is preserved as **coupler.prev.log**.

### Which interface?

realvirtual offers three ways to work with PLCSIM Advanced:

* **PLCSIM Advanced (this page)** – the coupler interface. The Siemens API runs in the separate coupler process, so a problem in the Siemens library cannot end Unity. It stays fully supported for existing and new projects.
* [**PLCSIM Advanced Native (Pro)**](/components-and-scripts/interfaces/plcsim-advanced-native.md) – preview of an in-process interface that uses the native Siemens runtime API without a coupler process or download. The Siemens backend of its plugin is not included yet.
* [**realvirtual CONNECT**](https://realvirtual.io/doc/web/connect/interfaces/protocols/) – for realvirtual WEB, without Unity.

Never connect the coupler interface and the native interface to the same PLCSIM Advanced instance at the same time.

\
© 2025 realvirtual GmbH [https://realvirtual.io](https://realvirtual.io/) - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.realvirtual.io/components-and-scripts/interfaces/plcsim-advanced.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
