RoboDk integration

This chapter will allow you to enable the communication between the Simuamtik Gateway and RobotStudio, including robot axis data and I/O signals.

The first step is to create a new project by opening RoboDK and then load a robot by clicking the World icon button and picking the previously mentioned robot by clicking on the Download button.

alt text

Next, we can proceed to rename the robot by double-clicking in the robot icon and typing the new name. In this example, it has been called "Robot".

alt text

Warning

The Name property must be the same as in Simumatik's robot_controller component, being "Robot" the default one

Tip

Robot axis data is automatically exchanged. The following steps are only needed for the I/O signals.

Next, let’s create the different I/O variables. To do so, you can right-click on the project, called in this case New Station (1), and choose the option Station parameters.

alt text

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.

alt text

Note

There must be as many variables as individual bit for the selected I/O bytes

In RoboDK, bits can not be directly map every to a byte, so variables for the proper I/O bytes must be created. These variables are the ones that will be exchanged with Simumatik.

alt text

Warning

The Name property must be the same as in Simumatik's robot_controller component, being "inputs" and "outputs" the default ones.

Tip

You can have as many I/O bytes as you want.

In order to map these bits to their bytes variables, a Python script is used. Therefore, the next step is to create a new script in by left-clicking the Python button in the main bar as shown below.

alt text

Once created, right-click it and click on Edit Python script. This will open a lateral window on the right side with an example code.

alt text

Now let’s remove all the code, and then write-down the code of the screenshot below. This 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
RDK = Robolink()

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

    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)

Warning

Use the same names in the script as the variables declared in the previous steps. If you use more bytes, more logic will need to be added to the script.

Finally, double-click on the Python script, called by default Prog1 to start it. It will now remain running in the background updating the values of every I/O signal. Always check that the script is running when connecting RoboDK to Simumatik, otherwise, the I/O signals will not be updated.

Warning

If your Simumatik system is not working as expected, double check that the script is running. Otherwise, the bits will not be updated.