Introduction

Content

Conclusion

Overview

Components with third-party integration

To be able to connect Simumatik to an external device, such as a PLC or a robot controller, the Simumatik Gateway is used. There are components in the Component library that contains a communication driver that connects to the gateway and thus can interact with an external device.

In this tutorial we will use a component called PLC 8DIO. The component allows for 1 byte inputs (to the PLC from Simumatik) and 1 byte outputs (from PLC to Simumatik).

This tutorial will focus on the OPC_UA driver, for which the component initially is configured for. However the PLC component can be changed to other driver types to match your available PLC. This is done by selecting the corresponding driver_type and type the needed setup_params.

PLC 8DIO

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.

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 open the 2D Drawings view and take a look at the configuration of the system.

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.

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

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.

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.

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.

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. “url”:”opc.tcp://192.168.0.1:4840″.

To learn how to connect to your specific PLC and to set up the PLC Environment, see the vendor specific tutorials in our PLC learning path.

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.

If the Launcher is properly installed, the Gateway can be controlled with the Gateway button in the toolbar. Press the button when you want to connect. If it’s running, you will be connected immediately. If the gateway is not already started you will be asked if you want to start the gateway service.

If the connection is successful, the button will change status to Gateway connected.

More information can be found in the settings panel.

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.

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.

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.