Emulation

Overview and Key Concepts

The Emulation tool creates a link between FlexSim and external PLCs or clients/servers that communicate with PLCs. This tool can create multiple connections and define variables for each of those connections. This tool supports two protocols, OPC DA and Modbus.

The Emulation tool is accessed from the Toolbox.

The Connections Tab

The Connections tab has the following properties:

- Adds a new connection.

- Removes the connection.

The following four connection types are available:

Connection Description
OPC DA A connection to a local or remote OPC server using the Data Access (DA) protocol.
Modbus TCP/IPv4 A connection to a modbus client or server over ethernet using TCP/IPv4.
Modbus TCP/IPv6 A connection to a modbus client or server over ethernet using TCP/IPv6.
Modbus RTU A connection to a modbus slave or master using a serial (RS-232 or RS-485) port.
OPC UA A connection to a local or remote OPC server using the UA (unified architecture) protocol.

Each connection's properties will be explained below.

OPC DA

OPC DA connections can be real, meaning FlexSim will communicate through a physical ethernet port on the computer, or they can be virtual, meaning a software program emulates a TCP connection.

  • Name - The name of the connection. Used for identifying the connection in FlexSim.
  • Active - If checked, a connection will be created to connect FlexSim to an OPC server. This occurs when the model starts running.
  • Address - The ip address of the connection. Use localhost to create a connection with a server on this computer or specify the ip address in the form of 190.123.10.1.
  • Change Interval - The time interval, in model time units, for FlexSim to poll the server for changes.
  • Server - The server to connect to.
  • Browse - Click the browse button to display a list of possible servers to connect to at the defined address.
  • Asynchronous Write - If checked, writing data to the server will cause FlexSim to wait until the write operation is complete before continuing execution.
  • User Name - Used for server authentication if a user name is required to connect to the OPC server.
  • Password - Used for server authentication if a password is required to connect to the OPC server.

Modbus TCP/IPv4 and IPv6

The properties for IPv4 and IPv6 are identical. The only change is in which protocol is used in setting up the connection. Modbus TCP connections can be real, meaning FlexSim will communicate through a physical ethernet port on the computer, or they can be virtual, meaning a software program emulates a TCP connection.

  • Name - The name of the connection. Used for identifying the connection in FlexSim.
  • Active - If checked, a connection will be created to connect FlexSim to the Modbus Client or Server through an ethernet port. This occurs on model reset for server connections and when the model starts running for client connections.
  • Address - The ip address of the connection. Use localhost to create a connection with a virtual client or server or specify the ip address in the form of 190.123.10.1.
  • Client / Server - Specify if the connection is a Client or Server. Server connections allow other modbus devices/applications to connect to FlexSim.
  • Change Interval - The time interval, in model time units, for FlexSim to poll the server for changes. This is not used for Server connections.
  • Multi-Register - Specify the endianness of the connection or the order of byte transmission.
  • Port - The port of the connection.

Modbus RTU

Modbus RTU connections can be real, meaning FlexSim will communicate through a physical serial port on the computer, or they can be virtual, meaning a software program emulates a serial port.

  • Name - The name of the connection. Used for identifying the connection in FlexSim.
  • Active - If checked, a connection will be created to connect FlexSim to the Modbus Slave or Master through a serial port (virtual or real). This occurs on model reset for slave connections and when the model starts running for master connections.
  • Serial Port - The serial port to create the connection on.
  • Slave / Master - Specify if the connection is a Slave or Master. Slave connections allow other modbus devices/applications to connect to FlexSim.
  • Baud Rate - The baud rate of the connection. The baud rate defines the number of signaling events across the transmission per time.
  • Parity - Specify if the connection has a parity. This is a method for detecting errors in transmissions.
  • Slave ID - Define the Slave ID of the connection.
  • Multi-Register - Specify the endianness of the connection or the order of byte transmission.
  • Stop Bits - Specify the number of stop bits or bits at the end of each character in the transmission.
  • Data Bits - Specify the number of data bits each character in the transmission can be.
  • Change Interval - The time interval, in model time units, for FlexSim to poll the slave for changes. This is only available for master connections.

OPC UA

OPC UA connections can be real, meaning FlexSim will communicate through a physical ethernet port on the computer, or they can be virtual, meaning a software program emulates a TCP connection.

  • Name - The name of the connection. Used for identifying the connection in FlexSim.
  • Active - If checked, a connection will be created to connect FlexSim to an OPC server. This occurs when the model starts running.
  • Discovery Server - The ip address of the discovery server. Use localhost to discover servers on this computer, or specify the ip address in the form of 190.123.10.1. Use a suffix such as :51510 to define a non-default TCP port number to communicate over. Once basic values are entered, you can press the Browse button to browse for specific end point URLs to connect to.
  • End Point URL - The specific URL defining the server and protocol to connect to. You can auto-fill this field using the Browse button.
  • Security Policy - Defines the set of security algorithms and key length to use when communicating with the server.
    • None - No security is applied.
    • Basic128Rsa15 - Uses an Aes 128 symmetric encryption algorithm, a SHA1 key hash, and RSA-PKCS15 asymmetric signature algorithm. Note that this policy is no longer considered secure, since SHA-1 was broken in 2017.
    • Basic256 - Uses an Aes 256 symmetric encryption algorithm, a SHA1 key hash, and RSA-PKCS15 asymmetric signature algorithm. Note that this policy is no longer considered secure, since SHA-1 was broken in 2017.
    • Basic256Sha256 - Uses an Aes 256 symmetric encryption algorithm, a SHA2-256 key hash, and RSA-PKCS15 asymmetric signature algorithm.
  • Message Security Mode - Defines the message security mode.
    • None - No security is applied.
    • Sign - Messages are signed but not encrypted.
    • Sign&Encrypt - Messages are signed and encrypted.
  • User Identity - Define how, or if, the client user will be identified. you can define the connection as anonymous, or enter a User Name and Password.
  • Check Configuration - Press this button to check that the entered settings correctly connect to the target UA server.

The Variables Tab

The Variables tab has the following properties:

Icon Description
Adds a variable.
Duplicates the selected variable.
Removes the selected variable.
Moves the selected variable up in the list.
Moves the selected variable down in the list.

Variables List

Displays a list of variables. The list may be filtered by connection using the drop down button above the list.

There are two types of variables that can be added, Sensors (PLC Inputs) and Controls (PLC Outputs).

Sensors (PLC Inputs)

Sensors are used to write data to the PLC or server. If you read from a sensor, the value returned will be the local value stored in FlexSim. If the sensor's connection is active, then changing its value will cause that value to be written to the PLC or server. If the connection is inactive, the value will only be changed locally.

Controls (PLC Outputs)

Controls are used to read data from the PLC or server. A control can only be changed if the control's connection is inactive. This allows your internal ladder logic to act as the PLC and make changes to controls which can start/stop motors, etc. If you attempt to change a control's value when its connection is active, an exception will be thrown.

When you read from a control, the returned value depends on how the control is setup. If the control is set to Subscribe to Changes or Poll for External Changes (depending on the connection type). In these cases, the server will notify FlexSim of the changed value (subscribing) or FlexSim will ask for changes using events (polling). If you later try and read the value from the control, the returned value will be the cached value from the last time FlexSim read the value. If Subscribe to Changes or Poll for External Changes is not checked, reading a control's value will reach out to the PLC or server and read the value synchronously (FlexSim will wait until it receives the value back before the simulation will continue).

The properties for controls and sensors is described below.

OPC DA Tag

Properties for OPC Tag variables are very similar between the Sensor and Control. These properties are described below.

  • Name - The name of the variable. Used for identifying the variable in FlexSim.
  • Connection - The connection this variable is associated with.
  • Tag ID - The path of the tag on the server. Click on the Browse button to display a list of the server's available tags.
  • Associated Object - Links this variable with an object in the model. The associated object defines which Write Events are available for sensors. In the pick options for Write Events and Actions, current is the associated object.
  • Write Events - If the sensor has an associated object, events on that object can be listened to. Click on the to add a new event.
    • Event - The event to listen to.
    • Write Value - The value to write to the sensor (and server if the connection is active).
  • Subscribe to Changes - Subscribes to changes on the server. FlexSim will be notified when the value changes.
    • % Deadband - When subscribing to analog changes, the % deadband can filter out small changes to the control's value (noise).
    • Actions - When subscribing to changes, a change notification will be sent to FlexSim when the control's value changes. Actions allow you to define what happens with that notification based upon the new value. Each action is evaluated from the top down until the new value matches the Value field or it hits a Default. The Action will then be fired and no further actions will be tested. Click on the to add a new action.
    • Value - The value to match.
    • Action - Actions to take when the new value matches the Value.

Modbus Register

Properties for Modbus Register variables are very similar between the Sensor and Control. These properties are described below.

  • Name - The name of the variable. Used for identifying the variable in FlexSim.
  • Connection - The connection this variable is associated with.
  • Register Type - The type of register. This can be Coil, Discrete Input, Holding Register, Input Register. For holding and Input register, the data type drop down button defines what data type the register is.
  • Register # - Define the register's address (0 - 9999).
  • Initial Value - The initial value of the register. This is only available for Server or Slave type connections that store their own data.
  • Associated Object - Links this variable with an object in the model. The associated object defines which Write Events are available for sensors. In the pick options for Write Events and Actions, current is the associated object.
  • Write Events - If the sensor has an associated object, events on that object can be listened to. Click on the to add a new event.
    • Event - The event to listen to.
    • Write Value - The value to write to the sensor (and server if the connection is active).
  • Poll for External Changes - Polls the slave or server for changes to the control's value. This is only available for master and client type connections.
    • Actions - When polling for changes, a FlexSim event will be created based upon the connection's Change Interval. When the event fires it will read values from the server. If the control's value has changed, the control's actions will be evaluated. Each action is evaluated from the top down until the new value matches the Value field or it hits a Default. The Action will then be fired and no further actions will be tested. Click on the to add a new action.
    • Value - The value to match.
    • Action - Actions to take when the new value matches the Value.

OPC UA Variable

Properties for OPC UA Variables are very similar between the Sensor and Control. These properties are described below.

  • Name - The name of the variable. Used for identifying the variable in FlexSim.
  • Connection - The connection this variable is associated with.
  • Display Name - The path of the variable on the server. Click on the Browse button to display and select from a list of the server's available tags.
  • Node ID - Displays the UA id string of the variable.
  • Description - Displays the UA description of the variable.
  • Associated Object - Links this variable with an object in the model. The associated object defines which Write Events are available for sensors. In the pick options for Write Events and Actions, current is the associated object.
  • Write Events - If the sensor has an associated object, events on that object can be listened to. Click on the to add a new event.
    • Event - The event to listen to.
    • Write Value - The value to write to the sensor (and server if the connection is active).
  • Subscribe to Changes - Subscribes to changes on the server. FlexSim will be notified when the value changes.
    • Sampling Interval [ms] - Defines how often the variable will be sampled from the serve to detect changes to the variable.
    • Actions - When subscribing to changes, a change notification will be sent to FlexSim when the control's value changes. Actions allow you to define what happens with that notification based upon the new value. Each action is evaluated from the top down until the new value matches the Value field or it hits a Default. The Action will then be fired and no further actions will be tested. Click on the to add a new action.
    • Value - The value to match.
    • Action - Actions to take when the new value matches the Value.