Skip to content

Tutorial 1: Boolean logic

alt text


In this tutorial you will:

  • Integrate an OPCUA compatible PLC to control the station components.
  • Test different logic combinations between the components in the station.

Start by loading the tutorial system into the workspace, and then navigate through the components in the tree and the scene to explore them.

Components with third-party integration

Usually, automated system models include one or several special components, which can be connected to external devices, like PLCs or Robot controllers. The connection with third-party tools or devices is done through component drivers and the Gateway.


Check out the Third-party connection section of the Manual to learn how to set up different third-party software or hardware to connect them with Simumatik OEP using the OPCUA driver.

This and the following tutorials will make use of a component (PLC 8IO OPCUA) that uses an 'opcua_client' driver to interact with an OPCUA compatible PLC. This compact PLC model has been created by the Simumatik team to provide an example of such a device.

Simumatik OEP provides the tools to build components that can easily abstract the end-user from all the complicated stuff required to connect the model with the programmable controller - don't worry about that.

alt text


To be able to follow this tutorial, make sure you have already done the Basic tutorials.


This component has 8 electric input ports and 8 electric output ports that can be connected to other components as we have done in previous tutorials. The user just needs to decide a name for an input and output variable that will map all these signals to the PLC program. The variable names can be adjusted in the public variable panel. We will come back to this later.

alt text


Opening the component information panel will provide you with more information about the component itself and its public variables.

System description

The system includes one assembly with an electric box, a 24V DC power supply, a PLC, three buttons, and three lights.

Let's download the diagrams and take a look at the configuration of the system.

alt text

The 'PS01' power supply is feeding the 'PLC' and the three buttons with the output 'dc_p'. If you select the 'PS01' component and inspect the port selector, you will see them.

alt text

On the other hand, the 'PS01' ground output 'dc_n' is connected to the 'PLC' 'x2' input and the lights.

alt text

The rest of the connections are done to or from the 'PLC' inputs and outputs.

IO List

If you check the system assets again, you will see that there is another document called 'IO List'. If you download it you will see the next table.

alt text

The 'IO List' shows how the 'PLC' variables 'input' and 'output' are mapped to different ports and even the port connections. Since the 'PLC' has 8 input ports and 8 output ports, these variables have a size of a BYTE (8 bits), so each input and output port corresponds to a specific bit of each variable.

If we follow the IO List, we can see that the 'in_0' input port is mapped to the bit 0 of the variable 'inputs', 'in_1' to the bit 1, and so on... The same happens with the output ports, 'out_0' port is mapped to the bit 0 of the 'outputs' variable, 'out_1' to bit 1,...

This means that if the 'in_0' input electric port of the 'PLC' goes high (24V) the bit 0 on the 'PLC' variable 'inputs' will be TRUE, and if it goes low (0V) it will be FALSE. On the other hand, if the 'outputs' variable bit 0 is TRUE on the 'PLC', the 'out_0' port will be powered with 24V, and 0V if it is FALSE. So basically, we can handle all the 'PLC' IO ports using just two variables.

IO Mapping on the controller

In practice, the way to connect the 'PLC' component to a third-party PLC is declaring the IO variables with the same name as in the component and mapping each port according to the model, following the IO List or the connections. Then, download the program to the PLC and run it.


If you want specific instructions for your PLC programming software, take a look at the Third-party integration section.

The picture below shows an example of a PLC program that could match the actual system. The IO variables are declared in the PLC at address %MB0 and %MB1, and the additional variables are mapped to the used ports and the corresponding bit. This is done following the model, where the first input to the 'PLC' ('in_0') is connected to the pushbutton 'S01', etc.

alt text


The only mandatory variables in the PLC program are 'inputs' and 'outputs' in this case, the mapped variables can have any name as long as they are mapped according to the model. I.e. we could call the variable 'S01' anything else in the PLC program and it will still work as expected.

Connect to a controller

Apart from the input and output variable names, the most important variable in the 'PLC' component is the 'url'. This refers to the address in which the third-party PLC provides the OPUA server. In case you use a soft-PLC running on the same machine, the address will be the default URL: 'opc.tcp://localhost:4840'. However, if you want to connect to third-party software or hardware using a specific IP address, you may need to change the value and replace 'localhost' by the controller's IP address, e.g. 'opc.tcp://'.

alt text

Activate the Gateway

The connection to third-party software or hardware controllers is done using the Gateway. The Gateway allows some components loaded on the server to communicate with third-party software or hardware on your machine or network.

Click on the workspace menu button on the toolbar ('⁝') and open the Gateway tab.


If you are using the Gateway for the first time, the initial step is to download and install it.

If the Gateway is properly installed it will display the version and the status 'STANDBY'. Click on the switch and if everything is working as expected, it should become green and the status 'connected' should be displayed, as seen below.

alt text

The connection with the Gateway is now done, and as soon as the emulation is started, the gateway will be available for the components that require it, so they can communicate with third-party software or hardware devices.


Check out the Gateway section of the Manual to learn more about how the Gateway works.

Time to play!

Now you are ready to make a program for your PLC, download it, and then test it against the model.

If we want to switch the 'H01' light on when the 'S01' button is pressed, we could make a program like the one in the picture below.

alt text

If you download the program to your PLC and start the emulation (assuming the Gateway is connected), you should be able to switch on and off the 'H01' light when you press the 'S01' pushbutton.

alt text


If the PLC communication seems to be not working, check on the PLC component that the status variable says "RUNNING". If it displays "ERROR" or "STANDBY", the connection has not been properly established. More information about the state can be seen in the info property.

An example is shown below, where the variables are not named the same way in Simumatik and the PLC software. If you have any issue, please check that the PLC project has OPCUA enabled, that the URL is correct, and the I/O variables have the correct name and size.

alt text


To practice your programming skills, you could try to implement the following logic behaviors (separately):

  • 'H01' should be switched on while 'S01' and 'S03' but not 'S02' is pressed.
  • 'H02' should be switched on when 'S01' is pressed and switched off when 'S03' is pressed.
  • 'H01', 'H02', and 'H03' should switch on for 1 sec, one after each other and on a loop, while 'S02' is pressed.