Modbus devices prefer to store integer numbers in their registers, but a machine often needs to deliver floating point numbers to the customer. Modbus devices typically use one of four techniques to represent a floating point number:
- Store an integer number in a register and let the customer divide it by a number, such as
7014divided by100to create70.14. - Store two integer numbers in two registers, such as
70and14, and let the customer append them to create70.14. - Same as #2 but the registers are in reverse order.
- Store the bytes of an IEEE Floating point number in multiple registers, and let the customer combine them, such as
0x428C47AErepresenting70.14.
FairCom's Modbus connector supports all four techniques when it collects data from registers and converts it into JSON numbers.
Dividing collected integers
The machine stores an integer number in a register and requires the customer to divide it by a number, such as 10, 100, or 1000, to create a floating-point number.
- FairCom's Modbus connector uses the following JSON configuration to convert the integer value
7014in register address2000into70.14.

{
"propertyPath": "temperature",
"modbusDataAddress": 2000,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 1,
"modbusRegisterType": "int16SignedAB",
"modbusConvertToFloat": "divideByInteger",
"modbusDivisor": 100
},- To configure the Modbus connector to convert an integer into a floating point number, add the
"modbusConvertToFloat": "divideByInteger"and"modbusDivisor": 100settings to the configuration. You can set"modbusDivisor"to10,100,1000,10000, or another integer number. The connector reads the value of the Modbus register, divides it by the integer number in the"modbusDivisor"property, and stores the result at the"propertyPath"location in the JSON document it generates.
Storing two separate integers
The machine stores two integer numbers in two registers to represent one floating point number.
- FairCom's Modbus connector uses the following JSON configuration to convert the integer value
70in the specified register and14in the next register into70.14. FairCom's Modbus connector always considers the decimal number as positive. So, if the value read is-14, for example, it will be converted to14.

{
"propertyPath": "temperature",
"modbusDataAddress": 2000,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 1,
"modbusRegisterType": "int16SignedAB",
"modbusDecimalDigits":2,
"modbusConvertToFloat": "appendAdjacentRegisters"
},- To configure the Modbus connector to convert integers in successive registers into a floating point number, add the
"modbusConvertToFloat": "appendAdjacentRegisters "setting to the configuration. The connector reads the value of the specified Modbus register and the next register and appends them with a decimal point between them. It stores the result at the"propertyPath"location in the JSON document it generates. - If you are using this configuration with a createOutput command, it is necessary to change
"modbusDecimalDigits"to properly convert the float number to two integers. The default value is2.
Storing two separate integers in reverse order
Store two integer numbers in two registers to represent one floating point number, but the fractional part is in the first register.
- FairCom's Modbus connector uses the following JSON configuration to convert the integer value
14in the specified register and70in the next register into70.14.

{
"propertyPath": "temperature",
"modbusDataAddress": 2000,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 1,
"modbusRegisterType": "int16SignedAB",
"modbusDecimalDigits":2,
"modbusConvertToFloat": "appendAdjacentRegistersReversed"
},- To configure the Modbus connector to convert integers in successive registers into a floating point number, add the
"modbusConvertToFloat": "appendAdjacentRegisters"setting to the configuration. The connector reads the value of the specified Modbus register and the next register and appends them with a decimal point between them. It stores the result at the"propertyPath"location in the JSON document it generates. - If you are using this configuration with a createOutput command, it is necessary to change
"modbusDecimalDigits"to properly convert the float number to two integers. The default value is2.
Storing the bytes of an IEEE floating point number
Store the bytes of an IEEE Floating point number in multiple registers.
- FairCom's Modbus connector uses the following JSON configuration to convert the IEEE bytes stored in two registers. For example, the first two bytes,
0x428C, can be stored in register2000, and the bytes0x47AEcan be stored in register2001. The connector reads the bytes in both registers, combines them into four bytes, and treats them as an IEEE floating point number representing70.14.

{
"propertyPath": "temperature",
"modbusDataAddress": 2000,
"modbusDataAccess": "holdingregister",
"modbusUnitId": 5,
"modbusDataLen": 2,
"modbusRegisterType": "ieeefloat32ABCD"
},- To configure the Modbus connector to convert the bytes of an IEEE floating point number in successive registers into a floating point number, add the
"modbusRegisterType": "ieeefloat32ABCD"setting to the configuration. You can assign any of the following values to"modbusRegisterType"to specify different byte orders and sizes of IEEE floating point numbers:
"ieeeFloat32ABCD" |
"ieeeFloat32CDAB" |
"ieeeFloat32DCBA" |
"ieeeFloat32BADC" |
"ieeeFloat64ABCDEFGH" |
"ieeeFloat64BADCFEHG" |
"ieeeFloat64CDABGHEF" |
"ieeeFloat64DCBAHGFE" |
"ieeeFloat64HGFEDCBA" |
"ieeeFloat64GHEFCDAB" |
"ieeeFloat64FEHGBADC" |
"ieeeFloat64EFGHABCD" |