Modbus Server
Accessing robot data through the MODBUS server
Created date: August 19th, 2015
Examples are valid for:
CB2 Software version: 1.6 and forward
CB3 Software version: All versions
e-Series Software version: All versions
Note that older or newer software versions may behave differently.
Purpose:
Give read and write access to data in the robot controller for other devices
How it works:
The robot controller acts as a Modbus TCP server (port 502), clients can establish connections to it and send standard MODBUS requests to it. The server is available at the IP address of the controller which can be found and modified in PolyScope (SETUP Robot → Setup NETWORK) For more information about MODBUS, see www.modbus.org specifications of MODBUS messages can be found at http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
Note:
Some Modbus device manufacturers use the terms Master (client) and Slave (server). Typically the external IO device is going to be a server and the robot is going to behave as the client (requesting and consuming messages from the server). Master=client and Slave=server. However, note that the UR controller can be both a server and a client
Functionality:
- Several clients can connect to the server at the same time
- The server can respond to the following function codes:
- 0x01: READ_COILS (read output bits)
- 0x02: READ_DISCRETE_INPUTS (read input bits)
- 0x03: READ_HOLDING_REGISTERS (read output registers)
- 0x04: READ_INPUT_REGISTERS (read input registers)
- 0x05: WRITE_SINGLE_COIL (write output bit)
- 0x06: WRITE_SINGLE_REGISTER(write output register)
- 0x0F: WRITE_MULTIPLE_COILS (write multiple output bits)
- 0x10: WRITE_MULTIPLE_REGISTERS (write multiple output registers)
- The server will send a response to all requests
- The server responds error messages with exception codes:
- 0x01: ILLEGAL_FUNCTION_CODE
- 0x02: ILLEGAL_DATA_ACCESS (if the request address is illegal)
- 0x03: ILLEGAL_DATA_VALUE (if the request data is invalid)
- The 16 bit ports can be read using the script function read_port_register(<address>), many of the ports, including 128 general purpose registers (address 128-256) (see the port map) can also be written to using write_port_register(<address>,<value>). You can use the script function integer_to_binary_list(<value>) to get the register value as a list of booleans (e.g.[True,False,.....]), or binary_list_to_integer(<list>) to go back, please refer to the URScript manual for details.
- Coils (digital ports) can be accessed using read_port_bit(<address>) and write_port_bit(<address>,<value>).
- Note that all values are unsigned, if you want to convert to signed integers, program "if (val > 32768): val = val - 65535".
- The MODBUS Server has 0-based addressing. Be aware that some other devices are 1-based (e.g. Anybus X-gateways), then just add one to the address on that device. (e.g. address 3 on the robot will be address 4 on the Anybus X-gateway)
Setup:
Setup the controller IP and your MODBUS client with static IP addresses in the same subnet, see Modbus TCP client set up
Port map 16bit register addresses:
- Use function codes 0x03: READ_HOLDING_REGISTERS, 0x04: READ_INPUT_REGISTERS, 0x06: WRITE_SINGLE_REGISTER, and 0x10: WRITE_MULTIPLE_REGISTERS to access the following addresses.
- Use the script functions read_port_register(<address>) and write_port_register(<address>, <value>) to read and write to those addresses on your robot from the running program.
Please note that some registers has been added and the list below has been marked what registers is avalable from what version.
Port map bit (Digital) addresses
-Use function codes 0x01: READ_COILS, 0x02: READ_DISCRETE_INPUTS, 0x05: WRITE_SINGLE_COIL, 0x0F: WRITE_MULTIPLE_COILS to access the following addresses.
-Use the script functions read_port_bit(<address>) and write_port_bit(<address>, <value>) to read and write to those addresses on your robot from the running program.
Important info for Server applications with Siemens clients(masters)
From UR Software version 1.7 and on:
Some MODBUS units use designated addresses for each function code, i.e. Siemens use: coils (generally addressed as 0xxxx), contacts (1xxxx), input registers (3xxxx), holding registers (4xxxx). To solve this issue, address "x" is reflected at 10000+"x", 20000+"x", 30000+"x" and 40000+"x" Address 0 is also reflected at address 9999, as some units have an addresses starting at 1
The value "Unit Identifier"/"Slave ID" is ignored in the MODBUS Server
DOWNLOAD table with register address below: