Common Modbus Item Conversion

Common Modbus Item Conversion

Item Conversion

Modbus commonly supports the following conversion flags to convert the register data in the device to another type in the client application.

Item Conversion Flags and Descriptions

Flag

Description

Flag

Description

/

Append a '/' to the register or excstatus items followed by a bit number (starting at zero (0)) to access a single bit of a multi-bit data type.

.

A bit-width can be specified by appending a '.' followed by a number after the bit number specifier ('/').

B

Append a 'B' to the register to access the data as a True or False value. If the register contains a zero (0), the item value will be a zero (0).If the register contains a non-zero value, the item value will be a one (1).

B/0.n

Append a 'B' to a coil or input address, in conjunction with the '/' and '.' flags, to access consecutive addresses as an integer value. Starting conversion bit specified must be zero.
Example: 1001B/0.2 -- Access coils 1001 and 1002, combining the bit pattern into an integer.

C

Append a 'C' to the register to access the data as a single 8-bit character.

H

Append an ‘H’ to the register to access the data as a BCD value.

I

Append an 'I' to the register to access the data as a single 16-bit integer value.

L

Append an 'L' to the register to access the data as a single 32-bit integer value.

S

Append an 'S' to any of the above conversion flags (except 'B' and '/') to indicate the value is signed. Otherwise, all values will be treated as unsigned.

F

Append an ' F' to the register to access the data as a single 32-bit floating point value.

D

Append a 'D' to the register to access the data as a single 64-bit floating point value.

M

Append an 'M' to the register to access the data as a string (message).This must also be followed by a length specification in the form '[n]' where n is the number of characters in the string.

M1

Append an ‘M1’ to the register to access the data as a string (message).This is similar to the ‘M’ conversion flag, but the ‘M1’ conversion can be used to get a single character from a 16-bit register.

P

Append a 'P' to the register to access the data as a single 16-bit half-precision floating point value. The data is converted and provided to the client as 32-bit floating point. This conversion flag is not valid to use with 32 or 64 bit registers.

T

Append a 'T' to the register to convert the value read from a Julian date/time (seconds since Jan. 1, 1970) to a string. This implies that the register value that is read from the device is a Julian date/time stamp.

-

Append a '-' to the register to reverse the word and byte order specified in the register range properties. This applies only to the item with the '-'.

^

Append a '^' and a byte order code number to the register to apply a specific byte order to the incoming and outgoing values.

The following table describes the byte order code numbers:

For 4 byte values (single-precision floating point numbers and double words).

Code Number          Message Bytes          Assembled Order
1                               1 2 3 4                      1 2 3 4

2                               1 2 3 4                      2 1 4 3

3                               1 2 3 4                      3 4 1 2

4                               1 2 3 4                      4 3 2 1

For 8 byte values (double-precision floating point numbers).

Code Number         Message Bytes           Assembled Order
1                             1 2 3 4 5 6 7 8            1 2 3 4 5 6 7 8

2                             1 2 3 4 5 6 7 8            2 1 4 3 6 5 8 7

3                             1 2 3 4 5 6 7 8            3 4 1 2 7 8 5 6

4                             1 2 3 4 5 6 7 8            4 3 2 1 8 7 6 5

5                             1 2 3 4 5 6 7 8            5 6 7 8 1 2 3 4

6                             1 2 3 4 5 6 7 8            6 5 8 7 2 1 4 3

7                             1 2 3 4 5 6 7 8            7 8 5 6 3 4 1 2

8                             1 2 3 4 5 6 7 8           8 7 6 5 4 3 2 1

~

Append a '~' to the register to access the two's compliment of the data in the register.

!

Append a '!' to the register to perform a bit-wise NOT (all bits in the value are inverted) of the data in the register.

[n]

Append a '[n]' to the register to specify an array of registers of size n. This can be combined with all of the above conversion flags except '/', and is required for string conversions (flag 'M').

[nDS]

Append ‘[nDS]’ to a 16-bit register to specify an array of 16-bit registers of size n.  This will be a write only string of decimal values for each 16-bit register. The purpose of ‘[nDS]’ is to provide a Modbus write, where all the 16-bit registers are guaranteed to be in the same Modbus message. These decimal values are comma ‘,’ delimited. A minus sign ‘-’ is used to denote negative numbers, no sign should be used for positive numbers. ‘[nDS]’ may not be combined with any other conversions. OPC quality will be updated after the write succeeds or fails.

[nHS]

Append ‘[nHS]’ to a 16-bit register to specify an array of 16-bit registers of size n.  This will be a write only string of hexadecimal values for each 16-bit register. The purpose of ‘[nHS]’ is to provide a Modbus write, where all the 16-bit registers are guaranteed to be in the same Modbus message. These hexadecimal values are not delimited, so no commas or spaces are permitted between 16-bit register values.  There must be 4 hexadecimal characters for each 16-bit register, '0 to 9', 'A to F' or 'a to f'. ‘[nHS]’ may not be combined with any other conversions. OPC quality will be updated after the write succeeds or fails.

Examples

Item Name

Description

Item Name

Description

40001L

Access registers 40001 and 40002 as one 32-bit unsigned integer.

40001LS

Access registers 40001 and 40002 as one 32-bit signed integer.

40001[10]

Access registers 40001 through 40010 as an array of ten values.

40001L[10]

Access registers 40001 through 40020 as an array of ten 32-bit unsigned integers.

40001/0

Access bit 0 (the lowest bit) of register 40001.

40001/3.2

Access bits 3, 4 of register 40001.

40001F

Access registers 40001 and 40002 as one 32-bit single-precision floating point value.

40001F^2

Access registers 40001 and 40002 as one 32-bit single-precision floating point value and assemble the received data bytes in the following order: 2, 1, 4, 3.

40001M[6]

Access registers 40001 through 40003 as a string of 6 characters.

10001IS

Access 16 bits of memory as a two byte signed short integer starting at register 10001.

10001M[10]

Access registers 10001 through 10080 as a string of ten characters.

EXCSTATUS/1

Access bit 1 of the exception status byte.

EXCSTATUS/2.2

Access bits 2 and 3 of the exception status byte.

3001[10DS]

A write only decimal string for 10, 16-bit registers.  A valid value to write would be ‘1, 2, 3, 4,    5, -6, 7, 0, 122,14’.

3002[3HS]

A write only hexadecimal string for 3, 16-bit registers.  A valid value to write would be ‘1238BB0FCB41’.

Bit widths can be specified for all discrete and integer type registers. For discrete type registers, the bit starting number must be specified as zero (0) and up to 32 bits can be requested. For integer type registers, the bit starting number can be any number between zero (0) and the number of bits in the register. For integer type registers, a bit width cannot be specified that crosses a register boundary.

For assistance, please submit a ticket via our Support Portal, email autosol.support@autosoln.com or call 281.286.6017 to speak to a support team member.