Introduction

Content

Conclusion

Overview

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.

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.

 

PLC 8IO OPCUA

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.

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.

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. ‘opc.tcp://192.168.0.1:4840′.

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 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.

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.