Modbus

MODBUS is an application layer messaging protocol for client/server communication between devices connected on different types of buses or networks.

modbus communication

There are several variants of the protocol. AspenTech Inmation OT DataFabric supports Modbus TCP and Modbus RTU (Remote Terminal Unit) over TCP.

For more details on Modbus in general please refer to Modbus Technical Resources at modbus.org

The configuration of Modbus datasources is described in detail in the Modbus Datasource Object Guide.

Accessing Modbus Data

To access data using a Modbus datasource, it is necessary to create and configure a corresponding IO-Item Modbus object in the I/O Model.

1 To create a new IO-Item, right-click on the Datasource Modbus object in the I/O Model and select Admin  New to open the Create Object wizard.

2 In the Available Objects list, select External Interfaces > IO-Item Modbus.

3 In the Property Compounds list, select Common compound and enter an Object Name for the new IO-Item.

4 . Then enter the Item ID, following this schema:

MB.<Item Type code>:<Reference>

For this, first refer to the vendor’s specification of the Modbus device regarding Item Type and Reference. Then use the following table to find the Item Type Code corresponding to the Item Type.
The first reference number is 1, and it may be padded with zeros.
See a note below about specifying a byte order.

Table 1. The Modbus Data Model
Item Type Item Type Code Object Type Type of Access Comments

Coils / Discrete Output

0

Single bit

Read-Write

This type of data can be altered by an application program.

Discrete Input

1

Single bit

Read-Only

This type of data can be provided by an I/O system.

Input Registers

3

16-bit word

Read-Only

This type of data can be provided by an I/O system

Holding Registers / Output Registers

4

16-bit word

Read-Write

This type of data can be altered by an application program.

5 Next, go to the Modbus Item Type section.

6 Select the appropriate Data Type property for this IO-Item from the dropdown list.

7 In the Elements number property set the number of elements of the Data Type or the length of a string. For a value higher than 1 this will lead to an array output for any Data Type but 'String'.

8 Click Create to create the IO-Item in the I/O model.

Specifying byte order

The byte order can be specified in the ItemID property by appending .boDDDD, where D on the i-th position is a digit specifying the position of the i-th byte in the data sent to or received from a modbus device. It is applicable for all data types supported by the Modbus datasource but bits.

Modbus stores data in the Big-Endian format, however many clients run on a Little-Endian CPUs. Many vendors are trying to provide data in a convenient format. However there is a room of an interpretation of the convenience. So, sometimes one has to adjust the byte order. By default the order of registers is preserved, but the bytes within a register are swapped. This is how popular modbus clients work by default. E.g., the number 168496141 (hex: 0A 0B 0C 0D) on the Little-Endian platform is represented as hex: OD 0C 0B 0A. So, it will be sent as hex: 0C 0D 0A 0B` to the modbus device. It correspond to the byte order ".bo21".

The byte order can consist of up to 8 first different digits, starting with 1. If there are more characters in the definition then the definition is truncated. If the length of the byte order does not fit an integer number of times the length of the requested data, then the tail stays intact. E.g. for the string "abcde" if the byte order is ".bo321", then the value will be "cbade".