Integration setup

Integration setup

In this part, we will go through how to prepare a RoboDK station and setup the connection to the Simumatik system. First, we’ll create a new station in RoboDK that will be used for this tutorial. After the station is created, we’ll go through what needs to be prepared in the RoboDK station to enable a I/O connection between RoboDK and the Simumatik app. Finally, we connect the two softwares and makes some tests to confirm that everything works as intended.

RoboDK station creation

First create a new station by opening RoboDK and then load a robot from the online library; search for the UR3 robot, press the Download button and open the UR3.robot file once downloaded.

Next, for the robot axis data to automatically be exchanged to the robot in the Simumatik app, the Name property must be the same as in the RoboDK controller component in the Simumatik app. Proceed to rename the robot by double-clicking the robot icon in RoboDK and type the new name.

I/O setup

When the RoboDK station has been created, the appropiate robot has been loaded and the name property matches both platforms, you can technically connect to the Simumatik app run the simulation right away. However, to enable the use of I/O signals from RoboDK to the Simumatik app and vice versa, we have to prep a few things in the RoboDK station.

In the RoboDK station, right-click on the project, called in this case New Station (1), and choose the option Station parameters.

In this case, 1 byte for the inputs and 1 byte for the outputs are going to be created. Therefore, 16 variables (8 input bits and 8 output bits) need to be created by clicking the Add button. In the following screenshot, 2 inputs and 2 inputs variables are added as an example.

In RoboDK, bits cannot be directly mapped to a byte, so variables for the proper I/O bytes has to be created as well. These variables are the ones that will be exchanged with the Simumatik app, therefore, the Parameter name must be the same as the Value in the RoboDK controller component in the Simumatik app. For this tutorial we call them inputs and outputs.

In order to map these bits to their bytes variables, a python script is used. Download the python script found in the Tutorial: RoboDK station’s Assets and add it to your RoboDK station.

To view the script, right-click on it and select Edit Python script.

The code will convert the individual bits to the resulting decimal number and save it in the outputs variable. For the inputs variable, the opposite operation is performed.

				
					from robolink import *    # RoboDK API
from robodk import *      # Robot toolbox
import time

RDK = Robolink()

def InitParams():
    for param in ['in0','in1','in2','in3','in4','in5','in6','in7',
                  'out0','out1','out2','out3','out4','out5','out6','out7',
                  'inputs','outputs']:
        RDK.setParam(param, 0)

def ReadInputs():
    inputs = int(RDK.getParam('inputs'))
    RDK.setParam('in0', 1 if inputs & 1 else 0)
    RDK.setParam('in1', 1 if inputs & 2 else 0)
    RDK.setParam('in2', 1 if inputs & 4 else 0)
    RDK.setParam('in3', 1 if inputs & 8 else 0)
    RDK.setParam('in4', 1 if inputs & 16 else 0)
    RDK.setParam('in5', 1 if inputs & 32 else 0)
    RDK.setParam('in6', 1 if inputs & 64 else 0)
    RDK.setParam('in7', 1 if inputs & 128 else 0)

def WriteOutputs():
    outputs = 0
    outputs += RDK.getParam('out0') * 1
    outputs += RDK.getParam('out1') * 2
    outputs += RDK.getParam('out2') * 4
    outputs += RDK.getParam('out3') * 8
    outputs += RDK.getParam('out4') * 16
    outputs += RDK.getParam('out5') * 32
    outputs += RDK.getParam('out6') * 64
    outputs += RDK.getParam('out7') * 128
    RDK.setParam('outputs', outputs)

InitParams()
while True:
    ReadInputs()
    WriteOutputs()
    time.sleep(0.1)
				
			

Testing the connection

Now we’re ready to try out the integration between RoboDK and the Simumatik system.

Open the Simumatik app and load the system called Tutorial: RoboDK.

To enable the connection, have both the RoboDK station and the Simumatik system open and select the Connect Gateway icon.

If the connection worked, the virtual robot in Simumatik should start mimicking the virtual robot in RoboDK when you press the Play button in the Simumatik app.

While running the Simumatik app, you can try out the I/O signals. First run the python script in RoboDK, it will remain running in the background updating the values of every I/O signal. Create a program and add an instruction that sets an output signal to 1, for example out0 which is connected to the conveyor. Once created you can run the program and see if it works as intended.

Always check that the script is running when connecting RoboDK to Simumatik, otherwise, the I/O signals will not be updated.