ModSlaveSim help v3.04 - 3.2.4. Set 32/64-bit Values

Download manual: HTML

3.2.4. Set 32/64-bit Values

The official Modbus protocol (in both the original Modbus specification and the current Modbus specification) only allows 1-bit and 16-bit integer values to be transferred. Many manufacturers have extended the protocol to allow 32-bit and 64-bit values, and also to allow floating-point values. Fortunately, everyone seems to have used the IEEE format for floating-point numbers, but that is where the agreement ends. This panel allows you to configure ModSlaveSim to handle all implementations of 32/64-bit values that we know of.

  • Little Endian. Modbus is a "big-endian" protocol: that is, the more significant byte of a 16-bit value is sent before the less significant byte. It seems obvious that 32-bit and 64-bit values should also be transferred using big-endian order. However, some manufacturers have chosen to treat 32-bit and 64-bit values as being composed of 16-bit words, and transfer the words in little-endian order, i.e. they send the least significant 16-bits of 32-bit/64-bit values first. For example, the 32-bit value 0x12345678 would be transferred as 0x56 0x78 0x12 0x34. You should click the Little Endian checkbox to use this mixed ordering.

  • Word Registers. Each register in the Modbus protocol holds a single (16-bit) value. The simplest way to extend the protocol to handle 16-bit and 32-bit values is to allow registers that contain these larger values. However, some manufacturers have chosen to keep to the 16-bit register size, and use 2 registers to hold a 32-bit value, and 4 registers to hold a 64-bit value. For example, if a 32-bit value is stored at address 100, then register 100 would hold one half of the value and register 101 would hold the other half of the value. Some devices will actually allow you to access the halves of the value independently; others will only allow accesses that transfer the complete value (thus making address 101 in the example an invalid address). You should click the Holding/Input: Word Registers checkbox to use multiple registers to store large values, and leave the checkbox unchecked to use a single register to hold each value. Note that when you use the Holding/Input: Word Registers option, ModSlaveSim will only allow access to complete values, and you should add definitions only for the first register used for each value (in the above example, you should define register 100, but not register 101).

  • Word Count. Some Modbus requests (e.g function 3 Read Holding Registers, and function 16 Preset Multiple Registers) include a count of how many registers/values are to be transferred. There are three possible interpretations for this count:

    • The number of values to be transferred.

    • The number of 16-bit words to be transferred.

    • The number of registers to be transferred.

    In the official Modbus protocol, these three interpretations are equivalent, since all values and all registers are 16-bit. When 32-bit and 64-bit values and/or registers are allowed, the three interpretations become distinct. However, the third interpretation will be equivalent to one or other of the first two, depending on the Holding/Input: Word Registers setting, so ModSlaveSim only deals directly with the first two interpretations. You should click the Holding/Input: Word Count checkbox if the count is to be interpreted as the number of 16-bit words to be transferred (e.g. if transferring 4 * int32/16 = 8 words). You should leave the Holding/Input: Word Count checkbox unchecked if the count is to be interpreted as the number of values to be transferred (e.g. if transferring 4 * int32= 4 values).

These three options (Little-endian, Word-registers, and Word-count) allow 8 possible variations of 32/64-bit value handling. At least 5 of these variations have actually been used in devices, so you may need to carefully read documentation, or to experiment, to determine which variation a particular device uses.

Press Apply to apply any changes.