UR MODBUS Slave Setup - 20579
MODBUS Slave Setup
Example is valid for:
CB2 Software version: 1.8.16941
CB3 Software version: 3.1.19293
Note that older or newer software versions may behave differently.
This example can be used for both CB2 and for CB3
Using Modbus slave addresses.
When running the UR on MODBUS, we recommend using the UR as MODBUS SLAVE. Both the Trio and the Proface can operate as MODBUS Master. When running the UR with both a Proface and Trio on the same application, the Proface should be the master to both the Trio and UR. In this case you will have some code in ladder/Proface script to copy memory between the UR and Trio. When running without a Proface, the Trio can then be the master and the UR the slave.
To implement UR as MODBUS Slave simply set the Robot’s IP address as needed on the UR’s set-up screen. UR registers 128-255 are general purpose registers that can be used for data transfer (i.e. consider the limit of communications to be 128 registers). The commands on the UR are read_port_register(address) and write_port_register(address,value).
In an example case we set-up a thread in the UR with a simple 2 way-point program and documented expected transfer speeds (i.e. approx 10Hz) with over 30 registers. The thread simply uses the UR Assignment command to read a MODBUS value into the program’s memory space. For example under installation -> variables, create a new variable called, pick_pos. In the program thread on the UR the assignment command will look like pick_pos:=read_port_register(155). Remember to add a ”sync()” function into the thread to insure proper scheduling on the UR’s CPU. This is a simple to implement solution that works with the robots existing firmware.
There might be circumstances in which it is essential to be able to set specific slave addresses (slave number, slave ID) for the Modbus signals that you have set up by e.g. following the the guide here. Since the slave address is not always needed, it is set to a default value of 255. In case you need the slave address for some signal to be set differently follow either of the methods below, depending on your comfort level.
Using the MODBUS Client setup screen on Polyscope
- Add the Modbus signal to your installation, specifying its IP address, signal address, signal type and name. When this is done, the signal connection will use default slave address 255. As an example you might add an output signal named "out1" with IP address "154.140.1.12" and signal address "203".
- Check the "Show advanced options" checkbox and edit the MODBUS Slave Address field to set your slave address.
Using the URScript language to change the slave address. Use either the above method or the below method. Using both together is redundant.
- Make a new empty robot program.
- Select the Advanced tab from the Structure menu.
- Press "Script Code", and select the Command tab.
- In the text field, enter the script command "modbus_add_signal()", which takes arguments as described in the script manual found under Download. When using the script command to add Modbus signals, you have the opportunity to specify a custom slave address. If e.g. you want to change the slave address of your signal to 25, enter 25 as the second argument to the command. All other arguments must then match exactly the values you set up under step 1.
- Push the "Play" button to run this little program that you just made.
- Now the signal will instead use the specified slave address as opposed to the value of 255 which was used when the signal was initially set up.
- In case you have more than one signal, you want to change the slave address of, you should add multiple script command lines in the small program, one for each signal to be changed.
NOTE:
Each time a robot program is run, the Modbus signals are reset. This means that if you have followed the steps above in order to change a slave address, and a program is then started, each signal will then again use the default slave address value of 255.
Therefore, it is important that you add the same script command lines as presented above to the very beginning of all robot programs in which you use Modbus signals which need a certain slave address value.
global var_1 = read_port_register (register address)
write_port_register(register input, register address)