Connecting with external controllers


Automation Interfaces handle the communication between real or virtual automation controllers and For each type of communication, a special interface is required. The interfaces currently available are for Siemens S7 (S7-300,400,1200,1500,Sinumerik, Simotion), TwinCAT, TwinCATHMI, Simit, PLCSim-Advanced (the virtual Siemens S7 1500 PLC), RobotDK, MQTT, Modbus Server, Simulink, FMI, ABB RobotStudio, UniversalRobots, EthernetIP, MQTT and OPCUA. New interfaces are continously added.

All interfaces are using standard PLCInput and PLCOutput objects (like PLCInputFloat or PLCOutputBool) for storing signal values. The Interface itself handles the real-time values of the signals. Some interfaces provide the ability to import all signals automatically and to create the suitable PLCInput or PLCOutput objects in the hierarchy automatically. Sometimes the signals can be imported by communication with the controller itself, or sometimes a signal list used for programming the automation controller can be exported and used. Imported signals can be automatically connected to signal objects by the (SignalManager).

The Signals are connected to the input and output properties of the Behavior Models.

This Youtube tutorial explains the relation between Signals and Behavior Models:

The following Signal types are supported by all Interfaces. In most cases the PLC itself can support more data types. For example Signed Int and Unsigned Int, are all transferred to the corresponding base type in

Signal TypeDescription


A PLC Input which is a boolean value (true/false)


A PLC Input which is an integer value (can be also a Byte, UInt, SInt ... on the PLC-Side)


A PLC Input which is a float value (can be also double, single on the PLC-Side)


A text (string) PLC Input. This datatype is only supported by TwinCATADS and MQTT interface


A PLC Output which is a boolean value (true/false)


A PLC Output which is an integer value (can be also a Byte, UInt, SInt ... on the PLC-Side)


A PLC Output which is an integer value (can be also a Byte, UInt, SInt ... on the PLC-Side)


A text (string) PLC Output. This datatype is only supported by TwinCATADS and MQTT interface

Check Signal status and connections to Behavior models

You can check all signals in the Hierarchy view of your model:

PLCInputs are shown in red and PLCOutputs are shown in green. All signals which have not been connected to behavior models (this means all signals, which are currently not controlling the model or are not getting any information from the model) are shown in brackets.

It is possible to check on the Signal component itself the connected Behavior models in the section Signal Connection Info:

Forcing (overriding) signals

Signals can be forced to a certain value. By doing this, all connected components receive the forced value and not the value of the current input or output. Signals can be forced by setting Settings>Override in the Signal to true. The value is now defined by the Value you define in Value Override. Forced signals are always displayed in italic letters.

For boolean values you can force them just by clicking on the value. This will force the value and toggle between true and false. For unforcing the value back again you need to click on the exclamation mark.

Connecting Signals

To connect two signals you can use Connect Signals. The two signals must be of same datatype but it does not matters if they are input or output.

In this example an InputFloat is connected to an Output Float. The signal value of the connected signal is transfered to the current signal.

Signal Events

Signals in Behaviour Models

Usually Signals should be used by Behavior Models which are defined by a script. In the Behaviour model references are used to identify the signals which are attached to the Behavior Model. Here is a simple example of a Behavior Model which can be attached to a Sensor:

  //! The Sensor_Standard component is providing the Sensor behavior and connection to the PLC inputs and outputs.
  public class Sensor_Standard : BehaviorInterface
      [Header("Settings")] public bool NormallyClosed = false;  //!< Defines if sensor signal is *true* if occupied (*NormallyClosed=false*) of if signal is *false* if occupied (*NormallyClosed=true*)
      [Header("Interface Connection")] public PLCInputBool Occupied; //! Boolean PLC input for the Sensor signal.

      private Sensor Sensor;
      // Use this for initialization
      void Start()
          Sensor = GetComponent<Sensor>();

      // Update is called once per frame
      void Update()
          bool occupied = false;
          // Set Behavior Outputs
          if (NormallyClosed)
              occupied = !Sensor.Occupied;
              occupied = Sensor.Occupied;

          // Set external PLC Outputs
          if (Occupied != null)
              Occupied.Value = occupied;


The public variable public PLCInputBool Occupied acts as referene to the Input Signal. Because the Sensor Behavior Model is attached to a GameObject with the Sensor base model also attached to it can get a reference to the sensor. In the Update cycle the Behavior Model is transferring the status between the Signals and the Sensor base object itself. Behavior Models give you the flexibility to program different behaviors and to still use the same base objects.

You can see the relations in this picture:

Unity Events and Signals

You can receive Unity Events as soon as a signal is changed. To do so you can select in the Unity Editor a method on each signal which should be called once the signal is changing it's status:

The method which is called receives as a parameter the Signal. The method must be defined like this:

public void SignalChangedEditor(Signal signal)
         Debug.Log("Signal Changed Editor " + signal.ToString());

Subscribing for Signal changed events in a method

Another alternative is to subscribe to the Signal changed events in a method. You want see anything in the Unity Editor if you do so. The subscription is done each time Unity is starting the simulation. Here is an example:

void Start()
        // Register Event During Runtime
        var com = GetComponent<PLCInputBool>();
        com.SignalChanged += SignalChangedRuntime;

    public void SignalChangedRuntime(Signal signal)
        Debug.Log("Signal Changed Runtime " + signal.ToString());

Please check the Class Reference for more information about the properties and methods of this component. © 2022 in2Sight GmbH - 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.

Last updated