Modbus Registry Mapping

Modbus Registry Mapping

Modbus registry mapping is the process of assigning registry specific details to parameters defined in the Modbus protocol, enabling a device to communicate and collect data.

In Zoho IoT, Modbus registry mappings are configured when adding a datapoint for a peripheral type device product. These mappings work in tandem with edge applications, which allow you to remotely push peripheral device settings from the Zoho IoT application to a gateway device.

Consider the EN8400N energy meter by Elmeasure as an example. This device communicates with a gateway using the Modbus protocol and measures parameters such as Watts, Voltage, Current, and Frequency. To retrieve data for each parameter, the corresponding register addresses and data types must be correctly configured on the gateway. For instance, the Total Current parameter requires address 40149 with the data type Float.

Configuration Details for Modbus Registry Mapping

Modbus registry mapping requires a set of specific values for each parameter to ensure the gateway retrieves accurate data from the peripheral device. These values are provided by the device manufacturer in the product's datasheet and must be configured precisely for the communication to function correctly. The key values required for configuring Modbus registry mapping are the Address, Register Type, Data Type, Multiplier, Offset, Endianness, and Access Direction.

Address

The register address is a unique numerical identifier assigned to each parameter in the device. It tells the gateway exactly where to read or write a specific value in the device's memory. For example, the Total Current parameter on the EN8400N energy meter is located at address 40149.

Register Type

The register type defines the category of the Modbus register being accessed. Modbus organizes data into four register types: Coil, Discrete Input, Input Register, and Holding Register. Coils and Discrete Inputs hold single-bit values (on/off states), while Input Registers and Holding Registers hold 16-bit numerical values. The register type determines how the gateway reads or writes data to the device.

The register type of a parameter can be identified directly from its address value, as each type occupies a distinct numerical range. For example, the address 40149 indicates it is a holding register.
  1. Coil (Read/Write) : 00001 to 09999

  2. Discrete Input (Read Only) : 10001 to 19999

  3. Input Register (Read Only) : 30001 to 39999

  4. Holding Register (Read/Write) : 40001 to 49999

Data Type

The data type specifies the format in which the parameter value is stored in the register. Available data types include
  • Signed Integer 16

  • Signed Integer 32

  • Signed Integer 64

  • Unsigned Integer 16

  • Unsigned Integer 32

  • Unsigned Integer 64

  • Float 32

  • Double 64

  • Unsigned Integer 8 MSB

  • Unsigned Integer 8 LSB

  • Signed Integer 8 MSB 

  • Signed Integer 8 LSB 
Selecting the correct data type is critical, as an incorrect type will cause the gateway to misinterpret the raw bytes retrieved from the device, resulting in inaccurate readings.

Multiplier

The multiplier is a scaling factor applied to the raw value read from the register. Manufacturers often store values in scaled form to fit within register size limits.

For example, a raw value of 2150 with a multiplier of 0.1 would yield an actual reading of 215.0. This allows precise decimal values to be stored as integers in the register.

By default, the multiplier value is always 1 unless specified by the manufacturer.

Offset

The offset is a fixed value added to or subtracted from the scaled register value after the multiplier is applied. It is used to shift the value into the correct range.

For instance, a temperature sensor might store values starting from zero, while the actual temperature requires an offset to reflect the correct reading.

By offset, the multiplier value is always 0 unless specified by the manufacturer.

Endianness

Endianness defines the byte order in which multi-byte values are stored and transmitted. Configuring the correct endianness is essential for multi-register parameters, as an incorrect setting will cause the bytes to be assembled in the wrong order, producing corrupted values.

  1. Big Endian (AB) : Stores a 16-bit value with the most significant byte first. The byte order follows the natural sequence, where A is the high byte and B is the low byte.

  2. Little Endian (BA) : Stores a 16-bit value with the least significant byte first, reversing the byte order so that B comes before A.

  3. Big Endian (ABCD) : Stores a 32-bit value with the most significant byte first, following the natural sequence from A (highest) to D (lowest).

  4. Mid-Big Endian (BADC) : Stores a 32-bit value where the bytes within each 16-bit word are swapped, but the words themselves remain in big endian order.

  5. Mid-Little Endian (CDAB) : Stores a 32-bit value where the two 16-bit words are swapped compared to big endian, but the byte order within each word is preserved.

  6. Little Endian (DCBA) : Stores a 32-bit value with the least significant byte first, fully reversing the byte order from D (lowest) to A (highest).

  7. Double Big Endian (ABCDEFGH) : Stores a 64-bit value with the most significant byte first, following the natural sequence from A through H.

  8. Double Little Endian (HGFEDCBA) : Stores a 64-bit value with the least significant byte first, fully reversing the byte order from H through A.

  9. Double Big Endian Byte Swap (BADCFEHG) : Stores a 64-bit value in big endian word order, but with the bytes within each 16-bit word swapped.

  10. Double Little Endian Byte Swap (GHEFCDAB) : Stores a 64-bit value in little endian word order, but with the bytes within each 16-bit word swapped.

Endianness values based on data type:

16-bit Data Types (AB / BA)

  • Int16

  • Uint16

32-bit Data Types (ABCD / BADC / CDAB / DCBA)

  • Int32

  • Uint32

  • Float

64-bit Data Types (ABCDEFGH / HGFEDCBA / BADCFEHG / GHEFCDAB)

  • Int64

  • Uint64

  • Double

The default endianness for most devices is Big Endian unless specified otherwise by the manufacturer.

Access Direction

The access direction specifies whether the gateway can read data from the register, write data to it, or both. A Read access means the gateway only retrieves the value from the device, which is typical for measurement parameters like Voltage or Current. A Write access allows the gateway to send commands or configuration values to the device. Read/Write access supports both operations.


Refer here for instructions on configuring Modbus Register Mapping in a Zoho IoT application.