Simulation
The OPC-Server offers to simulate process-values. In this case no communication to the ADS-device (like PLC) is done instead simulated values are send to OPC-client.
Different simulation templates like sinus, ramp, random etc. are available to be configured with detailed behaviour (amplitude, start /stop values).
The feature "Simulation" ist available in OPC Server version V4.0.x.x.
OPC-Server version V4.1.x.x offers a multiple more performant access to TwinCAT-devices, the simulation-mode is under construction and not supported today.
The OPC-Server offers
- simulation of all process values
- simulation of some specific process values
It is not possible to combine both simulated and real-process values.
Sample
The complete sample contains both, the PLC project and the definition of OPC-simulation.
1. Step: Configuration of simulation-templates for TwinCAT OPC Server
Start TwinCAT-OPC-Configurator "Start - All Programs - TwinCAT System - TwinCAT - TwinCAT OPC Configurator"

Navigate to "Simulations", right click and select menu "New".

For "Name" please enter a name for this simulation template.
This name must be OPC conform, no special characters allowed.

With "OK" you get into the dialog to configure in details your new "Simulations Signal".

Following settings can be done :
Signal Type | Req./Opt. | Description |
---|---|---|
|
|
|
0 : ReadCount | Optional |
|
1 : WriteCount | Optional |
|
2 : Random | Optional |
|
3 : Ramp | Optional |
|
4 : Sine | Optional |
|
5 : Square | Optional |
|
6 : Triangle | Optional |
|
7 : Stepp | Optional |
|
|
|
|
Disable | Optional | Disables this signal. OPC-Server will ignore this signal. |
2. Step: Check and save configuration
Save new configuration by selecting menue "File - Save As...".
After successfully creating and saving of new OPC-configuration file the next dialog offers to activate this new configuration.

Select "OK" to activate the configuration. With next startup the OPC-Server will work with new settings.

![]() | In case of opc server offers old previous configuration to opc-clients but a new configuration was activated this means, that OPC-server was not restarted to load fresh configuration. |
3. Step: Link of PLC-Variable with Alarm-Type
With previous steps we defined a "simulation-template" with detailed information about simulation behaviour.
Now we define, which PLC variable should be handled like a simluation.
This link is configured in PLC-Control as and additional information for IEC1131-variable declaration.
Take care on following settings :
Add a comment behind PLC-variable declaration. This comment will be interpreted by the opc-server and links this plc-variable to a previous defined simulation-template.
The simulation-template with the unique Simulation-ID was configured in step 1.
![]() | Today just global PLC-variables can be linked to Simulation-Templates. Elements of structures or arrays can not be configured as an simulated variable. Future versions of OPC-Server will not have this limitation. |
Sample :
- PLC-Variable of Typ LREAL dblMemAlarmCounter is a OPC variable linked to simulation template 6.
The OPC-Server will not access this PLC variable, but instead give simulated values back to OPC-client.
The syntax is important:
dblMemAlarmCounter : LREAL; (* ~
(OPC : 1 :
available for OPC-clients)
(OPC_PROP[6006] : 1 :
OPC_PROP_SIMU_ENABLE)
(OPC_PROP[6007] : 6 :
OPC_PROP_SIMU_ID)
*)
Each time compiling the PLC-project the PLC-Control will create the file <PLC-projectname>.tpy. This XML based file contains information about PLC-variables and their link to simulation templates.
The OPC server will analyze this information of the TPY file., so configure the OPC-Server to know the file <PLC-projectname>.tpy Details