Manage Modbus® 32-Bit Numbers with VoBo 

Manage Modbus 32-Bit Numbers with VoBo-min

Modbus® is one of the most widely used industrial communication protocols for sensors, meters, and controllers. At its core, Modbus® works with 16-bit registers. But many real-world industrial values, such as flow rates, energy consumption, and pressures, cannot be represented in just 16 bits. Instead, many devices commonly use 32-bit integers or floating-point numbers. For use with Modbus®, these 32-bit numbers are split across two consecutive 16-bit registers. 

Constructing these 32-bit values is not always straightforward. It requires processing to combine and interpret the registers correctly, while taking into account the data types and endianness (byte and word order). This article explains how 32-bit Modbus® numbers are handled, why post-processing is necessary, and how VoBo endpoints make this easier in real IIoT applications. 

What Are 32-Bit Numbers in Modbus®? 

Since Modbus® only defines 16-bit registers, manufacturers who need to transmit numbers that cannot be represented by a 16-bit register will use two registers, a high word and a low word: 

  • A 16-bit register is the combination of two 8-bit bytes 
  • High word – the most significant 16-bit register 
  • Low word – the least significant 16-bit register 

These registers might represent: 

  • Signed or unsigned 32-bit integers 
  • IEEE-754 single-precision floating-point values (FP32) 
  • Hexadecimal or scaled engineering values 

Without proper handling, these numbers will appear as incorrect values. This requires additional data processing after the transmitted register data is decoded. 

Why Post-Decoder Processing Is Needed 

The Modbus® standard does not specify how multi-register values should be ordered, so manufacturers implement their own conventions. Unfortunately, this lack of standardization introduces several challenges: 

  • Register order between the two registers: Some devices use big-endian (high word first), while others use little-endian (low word first). 
  • Byte order within the registers: Within a 16-bit register, the order of the two 8-bit bytes can be big-endian (high byte first) or little-endian (low byte first). 
  • Data type interpretation: After combining the two registers, the 32-bit value must be interpreted correctly (integer vs floating point). 
  • Scaling and offset: Some devices apply multipliers or offsets, meaning the raw values must be adjusted to represent engineering units. 

If the byte and/or word order of a 32-bit number is not correct, the value of the combined registers will be incorrect and nonsensical. 

How VoBo Manages FP32 Data 

VoBo endpoints collect data from Modbus® RTU devices over serial RS-485 and transmit the register data over LoRaWAN®. While Modbus® communication is based on 16-bit registers, VoBo has the tools to ensure 32-bit data is correctly interpreted. 

1. Serial Monitor for Testing 

When reading FP32 data from a device that is unfamiliar or not well documented, it is highly recommended that the initial setup and configuration be done with the VoBo and Modbus® device in the office before deployment.  This allows the user to quickly make any changes to the configuration, saving time and effort. 

 The VoBo is connected to the Modbus® device through its RS-485 channel and to a computer with a USB to RS-232 configuration cable. Using a terminal emulator (such as Putty) or the VoBoConfig Tool GUI, you can configure the VoBo to read FP32 register groups and monitor the results, testing different byte and word swap settings until the correct value is seen in the serial monitor.   

The VoBo group configuration allows byte swap, word swap, and both byte and word swaps until the endianness of the Modbus® device registers is aligned with the VoBo. 

The FP32 value displayed in the serial monitor is used for confirming the 2 registers are ordered in little-endian format before transmitting, ensuring the post-decoder processing to generate the FP32 value is easily implemented. 

2. Payload Transmission 

The VoBo reads and transmits the register data to the LoRaWAN® network. Although the VoBo will combine the registers to display the FP32 number in the serial monitor for confirming the byte/word order, the individual registers are sent in the payload, requiring the user to combine and generate the FP32 number after decoding. 

3. Decoder and Utilities 

Volley Boast provides the payload decoder and support files for downloading through the Customer Portal.  

The VoBoDecoder download includes the Decoder.js file, which contains the JavaScript uplink decoder for all Volley Boast devices and revisions, and some commonly used utility functions.  

Of interest for this discussion is the utility function in the decoder that, after the payload is decoded, can be called to convert two Modbus® registers to a FP32 number.  If the two register groups displayed the FP32 number correctly when viewed in the serial monitor during testing, the utility function modbusToFloat_AB_CD_to_ABCD will correctly combine the registers to a FP32 number after decoding.   

4. VoBoAnalytics 

For VoBo edge processing, the optional VoBoAnalytics plugin can perform on-board analysis of Modbus® data collected by the VoBo. For Modbus® register data, the VoBo will convert the register(s) to a numerical value before analytics are run on the data, which includes constructing FP32 numbers before analysis. 

Steps to Read and Deliver FP32 Data 

Example: Monitoring the instantaneous flow rate of fluid using the VoBo HL-1 to read register data on a Modbus®-enabled flow meter. The instantaneous flow rate is a single-precision floating-point number represented by two consecutive 16-bit Modbus® registers starting at holding register address 101.  

Initial bench testing:  

  • The VoBo is connected to the flow meter in the office for testing and configured by connecting the VoBo to a computer through the USB-to-RS-232 configuration cable. 
  • The VoBo Modbus® general configuration parameters are set to correspond with the flow meter’s communication parameters   
  •  The VoBo Modbus® Group 1 is configured to read the two registers starting at address 101, and the number type is set to FP32.   
  • Group 1, register 1 reads address 101 on the flow meter 
  • Group 1, register 2 reads address 102 on the flow meter 
  • The VoBo register data is assigned a slot in the payload,  
  • Group 1, register 1 is assigned Slot 1 
  • Group 1, register 2 is assigned Slot 2 
  • After the VoBo is configured, the serial monitor mode is used to observe VoBo operations. Since the number type of the Modbus® group was set to FP32, when the VoBo reads that group, the FP32 number is calculated and displayed along with the register values.   
  • If the number is not correct, select or deselect the byte swap and/or word swap options in the VoBo configuration until the FP32 number displays correctly in the serial monitor.   
  • If the VoBo is successfully reading the Modbus® registers but no combination of byte and word swap will display a correct FP32 value, the register addresses may need to be offset by 1. 

When configuration and testing are complete and the correct FP32 number appears in the serial monitor for Group 1, the byte and word order for the two registers used to create the number is little-endian, so the method to combine the registers in post-processing is known. 

Post-processing: The VoBo transmits the payload data to the LoRaWAN® network. The payload is received by the LoRaWAN® network, and the registers are decoded by the VoBoDecoder at the LoRaWAN® network server or a connected application.   

In this example, Group 1, register 1 delivers the decoded value labeled modbusReg1 and Group 1, register 2 delivers the decoded value labeled modbusReg2. 

The utility function modbusToFloat_AB_CD_to_ABCD(modbusReg1, modbusReg2) will correctly combine the two registers into a FP32 number for the instantaneous flow rate.   

Conclusion 

Handling 32-bit numbers in Modbus® is unavoidable for industrial monitoring and adds complexity and the possibility for errors if not handled correctly. Manufacturers differ in number type formats and byte/word ordering, making testing before deployment a requirement. 

VoBo endpoints provide the tools for testing, decoding, and post-processing the construction of FP32 numbers. The VoBo platform ensures that your Modbus® data is accurate, consistent, and ready to use.