object, no Modbus exception will be immediately returned. However, the point will always reflect the “source port” status and object value. In other words, if such an out-of-range write attempt is performed, the unsuccessful “source port” network write can be observed by reading the current (unchanged) value of the point during a subsequent Modbus transaction.

13.1.1 Coil Mappings

The Modbus slave implementation provides read/write support for coils (0X references). Accessing coils does not reference any new physical data: coils are simply indexes into various bits of Modbus holding registers. What this means is that when a coil is accessed, that coil is resolved by the gateway into a specific holding register, and a specific bit within that holding register. The pattern of coil-to-register/bit relationships can be described as follows:

Coils 1...16 map to holding register #1, bit0...bit15 (bit0=LSB, bit15=MSB) Coils 17...32 map to holding register #2, bit0...bit15, and so on.

Arithmetically, the coil-to-register/bit relationship can be described as follows: For any given coil, the holding register in which that coil resides can be determined by:

coil + 15

…Equation 1

holding register =

16

 

Where the bracket symbols “ ” indicate the “floor” function, which means that any fractional result (or “remainder”) is to be discarded, with only the integer value being retained.

Also, for any given coil, the targeted bit in the holding register in which that coil resides can be determined by:

bit = (coil −1) % 16

…Equation 2

Where “coil” [1…65535], “bit” [0…15], and “%” is the modulus operator, which means that any fractional result (or “remainder”) is to be retained, with the integer value being discarded (i.e. it is the opposite of the “floor” function).

From these equations, it can be seen that the largest holding register number that can be accessed via this coil-to-register mapping method is 4096 (which contains coil 65535).

For clarity, let’s use Equation 1 and Equation 2 in a calculation example. Say, for instance, that we are going to read coil #34. Using Equation 1, we can determine that coil #34 resides in holding register #3, as 3.0625= 3 r1= 3. Then, using Equation 2, we can determine that the bit within holding register #3 that coil #34 targets is (34-1)%16 = 1, as 33%16 = mod(3 r1) = 1. Therefore, reading coil #34 will return the value of holding register #3, bit #1.

45