Modbus Register and Digital I/O - 19252
Utilize Modbus register to read from and write to digital I/Os
Modbus Register and Digital I/O
Example is valid for: All versions
CB3 Software version: 3.1.17779 and above
e-Series Software version: 5.1
Note that older or newer software versions may behave differently.
This is a example for using modbus registers to read from digital inputs and write to digital outputs of the control box.
Introduction
All Universal Robots features an internal Modbus server. This is a guide on how to configure the Modbus client to read and write to the internal registers in the Modbus server.
Modbus Addresses
Digital input and output registers are located on the addresses listed below. The full list of port map 16bit registers are located here Modbus server -16377.
Address |
Pre 3.0 |
3.0 |
3.1 |
R |
W |
|
0 |
X |
X |
X |
X |
|
Inputs, bits 0-15 [BBBBBBBBTTxxxxxx] x=undef, T=tool, B=box |
1 |
X |
X |
X |
X |
X |
Outputs, bits 0-15 [BBBBBBBBTTxxxxxx] x=undef, T=tool, B=box |
Modbus Client IO Setup
Modbus Registers can be accessed by the robot internally using the Modbus client.
1. The Modbus client is located in the installation tab.
2. Internal IP for Modbus server is 127.0.0.1.
3. Input and output registers are added by clicking the “+” button on the right hand side of the GUI
4. Set Modbus address signal to 0 for register input. Example below show that when digital inputs 4 and 5 are activated, the Modbus register will convert the binary into an integer
5. Set Modbus address signal to 1 for register output. When integer values are set to the Modbus register, the digital output values are reflected accordingly.
Converting integer to binary list
Data from Modbus server is an integer. Data can be converted to a list of binary with the use of the functions below. After conversion individual IO channel can be accessed.
binary_list_to_integer()
- Function to convert a list of binary into an integer
integer_to_binary_list()
- Function to convert an integer into a list of binaries
Example code
Reading input registers and converting to binary
Robot Program
ASSIGN List_A =integer_to_binary(digital_inputs)
ASSIGN Input_4=List_A[4]
ASSIGN Input_5=List_A[5]
Converting a list of binary values and setting the output register.
Robot Program
ASSIGN List_B = [True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]
SET digital_outputs = binary_list_to_integer(List_B)
BeforeStartSequence
ASSIGN List_A = [True]
ASSIGN List_B = [False, True, False, True, True, True]
Robot Program
ASSIGN List_A =integer_to_binary(digital_inputs)
WAIT 0.5
SET digital_outputs = binary_list_to_integer(List_B)
WAIT 0.5