Modbus - 32 bit numbers

Converting Modbus 16 bit numbers to 32 bit numbers

Often the Vendor documentation does not report the byte order in which registers are served or the order in which words must be combined to form 32 bit numbers. For this reason FieldServer provides 4 functions to convert Modbus 16 bit numbers to 32 bit numbers.

2.i16-1.i32

2.i16-1.i32-s

2.i16-1.i32-sw

2.i16-1.i32-sb

Each of these functions takes 2x 16 bits numbers to form a 32 bit number. Each processes the bytes in a different order.

Practical Tip: The easiest way to determine which function to use is to experiment. Look at the values in the FieldServer Data Arrays. If the values are obviously wrong try the other move functions. (Don’t forget that some numbers may be scaled so the number you see in the Data Array may 10x or 100x too big / small).

Example:

In the move below if

DA_B01_REG[21] == 1 and

DA_B01_REG[22] == 2

Then

DA_B01_INT32[21] == 131073

Explanation

1 + 65536* 2 = 131073

Or In Hexadecimal

0x0001 + 0x0002 * 0x10000 = 0x20001

Moves

Source_Data_Array ,Source_Offset ,Target_Data_Array ,Target_Offset ,Length ,Function

DA_B01_REG,21,DA_B01_INT32,21,2,2.i16-1.i32

By the way, the length is 2 because the move must process two values from the source.

Example:

DA_B01_REG[21] == 1 and

DA_B01_REG[22] == 2

 

  Function In Use Value found in DA_B01_INT32[21]
  2.i16-1.i32 131073
  2.i16-1.i32s 16777728
  2.i16-1.i32-sw 65538
  2.i16-1.i32-sb 33554688

 

Contact Us

Contact us via phone (+1 866-383-1657) or leave a detailed message below for sales, support, or any other needs

*Required Field
*Required Field
I'd like to receive the newsletter. *Check email for confirmation.
*Required Field
8:00am - 12:00pm 12:00pm - 5:00pm