Modbus Data types

FairCom Edge's "modbusDataType" property defines how to convert binary data types into JSON types

The Modbus data types are the values used in the "modbusDataType" property, which defines how to convert Modbus binary data types into JSON types.

 

Integer data types

Modbus integer types can be converted into JSON numbers. At the binary level, a JSON number is an array containing one or more of the ASCII characters (-0123456789.), including the period.

Integer data types
"modbusDataType" Description Data type Bit size Signed/unsigned Endian Swap bytes Device byte order Converted byte order
int8Signed Int8 signed integer 8 signed        
int8Unsigned Int8 unsigned integer 8 unsigned        
int16SignedAB Int16 signed big endian integer 16 signed big   AB AB
int16UnsignedAB Int16 unsigned big endian integer 16 unsigned big   AB AB
int16SignedBA Int16 signed little endian integer 16 signed little   BA AB
int16UnsignedBA Int16 unsigned little endian integer 16 unsigned little   BA AB
int32SignedABCD Int32 signed big endian integer 32 signed big   ABCD ABCD
int32UnsignedABCD Int32 unsigned big endian integer 32 unsigned big   ABCD ABCD
int32SignedDCBA Int32 signed little endian integer 32 signed little   DCBA ABCD
int32UnsignedDCBA Int32 unsigned little endian integer 32 unsigned little   DCBA ABCD
int32SignedBADC Int32 signed big endian byte swapped integer 32 signed big swap BADC ABCD
int32UnsignedBADC Int32 unsigned big endian byte swapped integer 32 unsigned big swap BADC ABCD
int32SignedCDAB Int32 signed little endian byte swapped integer 32 signed little swap CDAB ABCD
int32UnsignedCDAB Int32 unsigned little endian byte swapped integer 32 unsigned little swap CDAB ABCD
int64SignedABCDEFGH Int64 signed big endian integer 64 signed big   ABCDEFGH ABCDEFGH
int64UnsignedABCDEFGH Int64 unsigned big endian integer 64 unsigned big   ABCDEFGH ABCDEFGH
int64SignedBADCFEHG Int64 signed big endian byte swapped integer 64 signed big swap BADCFEHG ABCDEFGH
int64UnsignedBADCFEHG Int64 unsigned big endian byte swapped integer 64 unsigned big swap BADCFEHG ABCDEFGH
int64SignedCDABGHEF Int64 signed big endian word swapped integer 64 signed big   CDABGHEF ABCDEFGH
int64UnsignedCDABGHEF Int64 unsigned big endian word swapped integer 64 unsigned big   CDABGHEF ABCDEFGH
int64SignedDCBAHGFE Int64 signed big endian word & byte swapped integer 64 signed big swap DCBAHGFE ABCDEFGH
int64SignedUnsignedDCBAHGFE Int64 unsigned big endian word & byte swapped integer 64 unsigned big swap DCBAHGFE ABCDEFGH
int64SignedHGFEDCBA Int64 signed little endian integer 64 signed little   HGFEDCBA ABCDEFGH
int64UnsignedHGFEDCBA Int64 unsigned little endian integer 64 unsigned little   HGFEDCBA ABCDEFGH
int64SignedGHEFCDAB Int64 signed little endian byte swapped integer 64 signed little swap bytes GHEFCDAB ABCDEFGH
int64Unsigned GHEFCDAB Int64 unsigned little endian byte swapped integer 64 unsigned little swap bytes GHEFCDAB ABCDEFGH
int64SignedFEHGBADC Int64 signed little endian word swapped integer 64 signed little   FEHGBADC ABCDEFGH
int64UnsignedFEHGBADC Int64 unsigned little endian word swapped integer 64 unsigned little   FEHGBADC ABCDEFGH
int64SignedEFGHABCD Int64 signed little endian word & byte swapped integer 64 signed little swap bytes EFGHABCD ABCDEFGH
int64UnsignedEFGHABCD Int64 unsigned little endian word & byte swapped integer 64 unsigned little swap bytes EFGHABCD ABCDEFGH

 

IEEE float data types

Modbus float types can be converted to a JSON number.

IEEE float date types
Name for the binary data type of the source Description Data type Bit size Endian Swap bytes Device byte order Converted byte order
ieeeFloat32ABCD IEEE 32-bit float big endian IEEE float 32 big   ABCD ABCD
ieeeFloat32CDAB IEEE 32-bit float big endian word swapped IEEE float 32 big   CDAB ABCD
ieeeFloat32DCBA IEEE 32-bit float little endian IEEE float 32 little   DCBA ABCD
ieeeFloat32BADC IEEE 32-bit float little endian word swapped IEEE float 32 little   BADC ABCD
ieeeFloat64ABCDEFGH IEEE 64-bit float big endian IEEE float 64 big   ABCDEFGH ABCDEFGH
ieeeFloat64BADCFEHG IEEE 64-bit float big endian byte swapped IEEE float 64 big swap bytes BADCFEHG ABCDEFGH
ieeeFloat64CDABGHEF IEEE 64-bit float big endian word swapped IEEE float 64 big   CDABGHEF ABCDEFGH
ieeeFloat64DCBAHGFE IEEE 64-bit float big endian word & byte swapped IEEE float 64 big swap bytes DCBAHGFE ABCDEFGH
ieeeFloat64HGFEDCBA IEEE 64-bit float little endian IEEE float 64 little   HGFEDCBA ABCDEFGH
ieeeFloat64GHEFCDAB IEEE 64-bit float little endian byte swapped IEEE float 64 little swap bytes GHEFCDAB ABCDEFGH
ieeeFloat64FEHGBADC IEEE 64-bit float little endian word swapped IEEE float 64 little   FEHGBADC ABCDEFGH
ieeeFloat64EFGHABCD IEEE 64-bit float little endian word & byte swapped IEEE float 64 little swap bytes EFGHABCD ABCDEFGH

 

Bit data types

Modbus Bit types can be converted to a JSON true or false, a string, an integer, or any json value.

Boolean data types
Name for the binary data type of the source Description Data type Related Properties
bitBoolean reads a bit value at a bit position in a Modbus register and converts it to a JSON true or false value Boolean
bitStartPosition
bitBooleanZeroValue
bitString reads a bit value at a bit position in a Modbus register and converts it to a JSON string value string
bitStartPosition
bitStringZeroValue
bitStringOneValue
bitInt reads one or more bit values from a range of bit positions in a Modbus register and converts them to a 16-bit integer value integer
bitStartPosition
bitEndPosition
bitReverseOrder
bitIntSigned
bitLittleEndian
bitEnum reads one or more bit values from a range of bit positions in a Modbus register and converts them to an unsigned integer value, and uses it to look up a value in the enumerated list Any json
bitStartPosition
bitEndPosition
bitReverseOrder
bitIntSigned
bitLittleEndian
bitEnumValues

 

"bitBoolean"

Setting the "modbusDataType" property to "bitBoolean" causes the connector to read a bit value at a bit position in a Modbus register and convert it to a JSON true or false value. A bit value of 0 maps to false, and 1 maps to true. It assigns the JSON Boolean value to the property specified in "propertyPath".

The Boolean value assigned to a zero-bit or one-bit value is specified by the "bitBooleanZeroValue" property.

 

Example

{
  "propertyPath": "sos",
  "modbusDataAccess": "holdingregister",
  "modbusDataAddress": 1024,
  "modbusDataType": "bitBoolean",
  "bitBooleanZeroValue": false,
  "bitStartPosition": 0
}

 

"bitString"

Setting the "modbusDataType" property to "bitString" causes the connector to read a bit value at a bit position in a Modbus register and convert it to a JSON string value. It assigns the JSON string value to the property specified in "propertyPath".

The string values for the zero-bit and one-bit values are specified by the "bitStringZeroValue" and "bitStringOneValue" properties.

 

"bitString" configuration example

{
  "propertyPath": "batteryHealth",
  "modbusDataAccess": "holdingregister",
  "modbusDataAddress": 1024,
  "modbusDataType": "bitString",
  "bitStringZeroValue": "healthy",
  "bitStringOneValue": "unhealthy",
  "bitStartPosition": 1
}

 

"bitString" JSON output example when the bit is 1

{
  "batteryHealth": "unhealthy"
}

 

"bitInt"

Setting the "modbusDataType" property to "bitInt" causes the connector to read one or more bit values from a range of bit positions in a Modbus register and convert them to a 16-bit integer value. It places bit values into the integer starting from the rightmost bit to the leftmost. It assigns the JSON integer value to the property specified in "propertyPath".

The server retrieves bits from the address specified by "modbusDataAddress". The bits start from the offset specified by "bitStartPosition" and end at the offset defined by "bitEndPosition". The server converts these bits into an integer number before writing the value to the record. You can optionally use "bitIntSigned", "bitLittleEndian", and "bitReversedOrder" to control how the server interprets the bits when it converts them into an integer number.

The bit range is defined by the "bitStartPosition" and "bitEndPosition" properties.

The "bitReverseOrder" property tells the connector to put the bits in the integer in reverse order.

The "bitIntSigned" property tells the connector to treat the bits in the integer as a signed integer.

The "bitLittleEndian" property tells the connector to treat the bits in the integer in little-endian order.

Note

  • The bit range must be sixteen bits or less because larger integers span multiple Modbus registers.
  • The "bitReverseOrder" property tells the connector to put the bits in the integer in reverse order.
  • The "bitIntSigned" property tells the connector to treat the bits in the integer as a signed integer.
  • The "bitLittleEndian" property tells the connector to treat the bits in the integer in little-endian order.
  • When you set "modbusDataType" to "bitInt", omit or set the following properties to null. The server ignores values assigned to these properties.
    • "bitBooleanZeroValue"
    • "bitStringZeroValue"
    • "bitStringOneValue"
    • "bitEnumValues"

 

"bitInt" configuration example

{
  "propertyPath": "voltageLevel",
  "modbusDataAccess": "holdingregister",
  "modbusDataAddress": 1024,
  "modbusDataLen": 1,
  "modbusDataType": "bitInt",
  "bitStartPosition": 2,
  "bitEndPosition": 9,
  "bitReverseOrder": false,
  "bitIntSigned": false,
  "bitLittleEndian": false
}

 

"bitInt" JSON output example when the bit range value is 0000 0100

{
  "voltageLevel": 4
}

 

"bitEnum"

Setting the "modbusDataType" property to "bitEnum" causes the connector to read one or more bit values from a range of bit positions in a Modbus register. It converts them to an unsigned integer value and uses it to look up a value in the enumerated list. It assigns the JSON enumerated value to the property specified in "propertyPath".

The bit range is defined by the "bitStartPosition" and "bitEndPosition" properties. The enumerated values are defined by the "bitEnumValues" property. The "bitReverseOrder" property tells the connector to put the bits in the integer in reverse order. The "bitLittleEndian" property tells the connector to treat the bits in the integer in little-endian order, which applies only when there are nine or more bits in the integer.

The server retrieves bits from the address specified by "modbusDataAddress". The bits start from the offset specified by "bitStartPosition" and end at the offset defined by "bitEndPosition". The server converts these bits into an unsigned integer number, looks up the string in the "bitEnumValues" array, and writes the enumerated string value on the record. You can optionally use "bitIntSigned", "bitLittleEndian", and "bitReversedOrder" to control how the server interprets the bits when it converts them into an integer number.

Note 

  • When you set "modbusDataType" to "bitEnum", omit or set the following properties to null. The server ignores the values assigned to these properties.
    • "bitBooleanZeroValue"
    • "bitStringZeroValue"
    • "bitStringOneValue"
    • "bitIntSigned"

 

"bitEnum" configuration example

{
  "propertyPath": "batteryStatus",
  "modbusDataAccess": "holdingregister",
  "modbusDataAddress": 1024,
  "modbusDataLen": 1,
  "modbusDataType": "bitEnum",
  "bitStartPosition": 10,
  "bitEndPosition": 12,
  "bitReverseOrder": false,
  "bitLittleEndian": false,
  "bitEnumValues": [
    "0-low voltage error",
    "1-low voltage",
    "2-normal voltage",
    "3-high voltage",
    "4-high voltage error"
  ]
}

 

"bitEnum" JSON output example when the bit range value is 100

{
  "batteryStatus": "4-high voltage error"
}

 

"bitEnum" JSON output example when the bit range value is 111

If there is no element corresponding to the value at "bitEnumValues", null is considered.

{
  "batteryStatus": null
}