Issue
How to read individual bits from a Modbus Holding Register that holds a 16-Bit Word and represent each Bit as a separate Digital point
Product Line
EcoStruxure Building Operation
Environment
- Building Operation Enterprise Server
- Building Operation Automation Server (AS, AS-P, AS-B)
- Modbus TCP/IP
- Modbus RTU (RS485)
Cause
There is a requirement for a Modbus Holding Register that is a 16-bit unsigned value, each bit represents a digital state in the Modbus device and to replicate this as 16 separate digital states in EBO. The 16-bit unsigned value is an integer with a range of 0 to 65,535 and needs to be converted into 16 digital values.
Resolution
Use a Modbus Digital Input point for each bit required. Each object will be configured to read the same Modbus register address, but with a different bitmask value applied prior to evaluating the value.
For example: Read Modbus Holding Register 40123 with a value of 32769 (16-bit unsigned) and decode bits 0, 8, and 15 as three separate Digital points
Since the actual Value of 32769 being read at address 40123 is shown in Binary as 1000000000000001 it can be seen that Bit 0 and Bit 15 should return TRUE while Bit 8 should return FALSE
Configure each point as follows:
- Modbus Digital Input Point 40123 bit 0
- Register number 123
- Register type 16 bit unsigned
- Read function code 03
- Bit mask - enable only Bit 0
- Modbus Digital Input Point 40123 bit 8
- Register number 123
- Register type 16 bit unsigned
- Read function code 03
- Bit mask - enable only Bit 8
- Modbus Digital Input Point 40123 bit 15
- Register number 123
- Register type 16 bit unsigned
- Read function code 03
- Bit mask - enable only Bit 15
Additional information can be found in the EcoStruxure Building Operation - Technical Reference Guide - Search for Bitmask.
If you need to break this bit information out for programming this can be done with a FB application and just binding the full 16 bits to the FB as shown here.