Skip to main content

Modbus data types

FairCom Edge's "modbusDataType" action returns the Modbus data type which defines how to convert binary data types into JSON types

Abstract

The Modbus data types are the values used in the modbusDataType property which defines how to convert Modbus 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.

Table 1. Integer data types

"modbusDataType"

Description

Data type

Bit size

Signed/unsigned

Endian

Swap bytes

Device byte order

Converted byte order

int8Signed

integer

8

signed

int8Unsigned

integer

8

unsigned

int16Signed

Int16 signed big endian

integer

16

signed

big

AB

AB

int16Unsigned

Int16 unsigned big endian

integer

16

unsigned

big

AB

AB

int16SignedSwap

Int16 signed little endian

integer

16

signed

little

BA

AB

int16UnsignedSwap

Int16 unsigned little endian

integer

16

unsigened

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

int64Signed

Int64 signed big endian

integer

64

signed

big

ABCDEFGH

ABCDEFGH

int64Unsigned

Int64 unsigned big endian

integer

64

unsigned

big

ABCDEFGH

ABCDEFGH

int64SignedLittleEndian

Int64 signed little endian

integer

64

signed

little

HGFEDCBA

ABCDEFGH

int64UnsignedLittleEndian

Int64 unsigned little endian

integer

64

unsigned

little

HGFEDCBA

ABCDEFGH



IEEE float data types

Modbus float types can be converted to a JSON number.

Table 2. 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

ieeeFloat32

IEEE 32-bit float little endian

IEEE float

32

little

DCBA

ABCD

ieeeFloat32Swap

IEEE 32-bit float little endian byte swapped

IEEE float

32

little

swap

BADC

ABCD

ieeeFloat64

IEEE 64-bit float little endian

IEEE float

64

little

HGFEDCBA

ABCDEFGH

ieeeFloat64Swap

IEEE 64-bit float big endian byte swapped

IEEE float

64

big

swap

BADCFEHG

ABCDEFGH



Boolean data types

Modbus Boolean types can be converted to a JSON true or false.

Table 3. Boolean date types

Name for the binary data type of the source

Description

Data type

Bit size

Signed/unsigned

boolean

converts any size of register to false when all bits are zero; otherwise, true

Boolean

any

zero = false

booleanZeroTrue

converts any size of register to true when all bits are zero; otherwise, false

Boolean

any

zero = true



Date-time data types

Modbus date-time data type parts can be combined from different registers to create a JSON string containing and ISO 8601 time (yyyy-mm-ddThh:mm:ss.nnn).

Viable date-time formats:
  • Date time with milliseconds (yyyy-mm-ddThh:mm:ss.nnn)

  • Date time without milliseconds (yyyy-mm-ddThh:mm:ss)

  • Date time without seconds (yyyy-mm-ddThh:mm)

  • Date time without minutes (yyyy-mm-ddThh:mm)

  • Date without time (yyyy-mm-dd)

  • Date with only year and month (yyyy-mm)

  • Date with only year (yyyy)

Table 4. Date-time data types

Name of the binary data type of the source

Description

Data type

Bit size

datetimeSchneiderUp

Date time used by Schneider Electric with different formats for 16-bit and 32-bit registers

ULP DateTime

16 or 32

utc

ASCII string representing a UTC time - works in JSON without conversion

ASCII string

8

year

separate register combined with other registers to create a datetime

unsigned integer

any

month

separate register combined with other registers to create a datetime

unsigned integer

any

day

separate register combined with other registers to create a datetime

unsigned integer

any

hours

separate register combined with other registers to create a datetime

unsigned integer

any

minutes

separate register combined with other registers to create a datetime

unsigned integer

any

seconds

separate register combined with other registers to create a datetime

unsigned integer

any

milliseconds

separate register combined with other registers to create a datetime

unsigned integer

any



String data types

The Modbus string types can be converted to JSON strings that consist of UTF-8 characters.

Table 5. String data types

Name of data type in the binary source

Description

Data type

Bit size

Swap bytes

Device byte order

Converted byte order

ascii8

8-bit ASCII Latin character set to UTF-8

ASCII Latin string

8

ascii16AB

16-bit bit endian ASCII Latin character set to UTF-8

ASCII Latin string

16

AB

AB

ascii16BA

16-bit little endian ASCII Latin character set to UTF-8

ASCII Latin string

16

swap

BA

AB

ascii32ABCD

32-bit big endian ASCII Latin character set to UTF-8

ASCII Latin string

32

ABCD

ABCD

ascii32DCBA

32-bit little endian ASCII Latin character set to UTF-8

ASCII Latin string

32

DCBA

ABCD

ascii32BADC

32-bit big endian byte swapped ASCII Latin character set to UTF-8

ASCII Latin string

32

swap

BADC

ABCD

ascii32CDAB

32-bit little endian byte swapped ASCII Latin character set to UTF-8

ASCII Latin string

32

swap

CDAB

ABCD

utf8

No conversion

UTF-8 string

8

ucs2AB

16-bit big endian unicode UCS-2 to UTF-8

UTF-2 string

16

AB

AB

ucs2BA

16-bit little endian unicode UCS-2 to UTF-8

UTF-2 string

16

swap

BA

AB



Resources