How To Use Modbus With Mir Robots
How To Use Modbus With Mir Robots
Date: 10/2020
Document version: 1.3
Valid for: All MiR robots
Valid for software version: N/A
Valid for hardware version: N/A
Modbus is a software communication tool that is used to communicate between MiR robots
and other devices. You can enable or disable it as needed.
This article explains what Modbus is, how it can be utilized, and how to set up Modbus on
your MiR robots.
To enable the Modbus feature on the robot, go to System > Settings > Features and enable
Modbus. Select Save changes at the bottom of the page.
Purpose of Modbus
Modbus TCP can be used to communicate between MiR robots and other devices to achieve
the following purposes:
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 1
• To control the status of the robot, such as Pause/Continue, Cancel current mission, Clear
mission queue, and Clear error message.
• To get basic information from the robot, such as its status, power percentage, and error
messages.
• To read and write registers in the robot.
• To trigger a mission.
In a typical case, the PLC (master/client) establishes a connection with the robot
(slave/server). The robot waits for an incoming connection from the PLC. Once a connection
is established, the robot responds to the queries from the PLC until the PLC closes the
connection.
Several masters/clients can connect to the robot at the same time. Each connection is
threaded.
The data is cached to avoid a high-frequency load of requests on the API while providing a
response to any request.
Function code
The server can respond to function codes described in Table 1.1.
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 2
Table 1.1.
Modbus function codes for MiR robots .
Function Code Definition
In the MiR robot, the content of coils and discrete inputs are matched with each other, as
are the input registers and holding registers. So you can get the same data from them, but
you can only send information to coils and holding registers.
Error codes
Modbus can respond with the error codes (called exception codes) described in Table 1.2 if
the user sends a wrong signal to Modbus.
Table 1.2.
Modbus exception codes.
Exception
code (hex Name Definition
code)
1 (01 hex) Illegal The function code received in the query is not an allowable
Function action for the slave. It could also indicate that the slave is
in the wrong state to process a request of this type, for
example, because it is unconfigured and is being asked to
return register values. If a Poll Program Complete
command was issued, this code indicates that no program
function preceded it.
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 3
Exception
code (hex Name Definition
code)
2 (02 hex) Illegal Data The data address received in the query is not an allowable
Address address for the slave. Specifically, the combination of
reference number and transfer length is invalid. For a
controller with 100 registers, a request with offset 96 and
length 4 would succeed, a request with offset 96 and
length 5 will generate exception 02.
3 (03 hex) Illegal Data A value contained in the query data field is not an
Value allowable value for the slave. This indicates a fault in the
structure of remainder of a complex request, such as that
the implied length is incorrect. It specifically does NOT
mean that a data item submitted for storage in a register
has a value outside the expectation of the application
program since the MODBUS protocol is unaware of the
significance of any particular value of any particular
register.
4 (04 hex) Slave Device An unrecoverable error occurred while the slave was
Failure attempting to perform the requested action.
7 (07 hex) Negative The slave cannot perform the program function received
Acknowledge in the query. This code is returned for an unsuccessful
programming request using function code 13 or 14
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 4
Exception
code (hex Name Definition
code)
8 (08 hex) Memory Specialized use in conjunction with function codes 20 and
Parity Error 21 and reference type 6 to indicate that the extended file
area failed to pass a consistency check. The slave
attempted to read extended memory or record a file but
detected a parity error in memory. The master can retry
the request, but service may be required on the slave
device.
Data model
The data model is described with the following points:
• Addressing
• The Modbus address that the robot uses can be found in the tables under Modbus data
addresses reference on the next page.
• The Modbus server has 0-based addressing. Be aware that some other devices are 1-
based, for example, Anybus X-gateways. When using a 1-based device, add one to the
address on that device, for example, address 3 on the robot will be address 4 on the
Anybus X-gateway.
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 5
• Read/write scheme
• Status messages: Read only.
• Registers: Read and write.
• Mission triggers: Write available. Reading always return 0 if triggers have been set.
• Action commands: Write available. Reading always returns 0.
• Integer register
• MiR robots save the integer in 32 bits, but the Modbus communications are 16 bits
encoded. To accomodate this, In the Modbus server, two addresses are combined to
represent one integer value in the robot. MiR Modbus uses big endian encoding as
default configuration. This method is applied to all the integer registers and integer
values of the robot’s information.
• Floating register
• MiR Modbus usees IEEE 754 ISO standard to encode floating point values.
Action commands
Table 1.3.
Action commands you can use with MiR robots.
Data
Title Description Permission Address
type
Pause robot Address of the coil used to trigger the W Bool [00002]
Pause action on the robot
Clear error Address of the coil used to clear the W Bool [00005]
errors on the robot
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 6
Data
Title Description Permission Address
type
Mission triggers
Table 1.4.
Mission triggers you can use with MiR robots.
Data
Title Description Permission Address
type
Status messages
Table 1.5.
Statuses you can read from MiR robots.
Data
Title Description Permission Address
type
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 7
Data
Title Description Permission Address
type
Registers
Table 1.6.
Registers you can get/set on MiR robots.
Data
Title Description Permission Address
type
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 8
After you have turned on the Modbus feature and created a mission, go to System >
Triggers > Create trigger to create a new trigger. The coil ID can be assigned to any integer
between 1001 and 2000. After the trigger is created, the robot will trigger the mission once
you set the coil to True via Modbus.
If the mission uses variables for any parameters, you must set the variable
value when you create the trigger.
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 9
Code Definition
The following tables describe the ID values for the robot's modes and states.
8 Docked
9 Docking
10 Emergency/Protective
stop
11 Manual control
12 Error
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 10
Document history
Version Date Description
1.0 2019-12-03 First edition.
1.1 2020-09-15 Added robot states 10-12.
How to guide (en) 10/2020 - v.1.3 ©Copyright 2020: Mobile Industrial Robots A/S. 11