Changes

Line 162: Line 162:  
[[File:Configuration examples modbus higher uptime example.png]]
 
[[File:Configuration examples modbus higher uptime example.png]]
   −
When the value climbs over 65535 the counter resets and the value held by the first register increases by 1. So one way to interpret the results would be to multiply the value in the first register by 65536 (2<sup>16</sup>) and add the value of the second register: '''%MW1 * 65536 + %MW2'''. Which, following from the example above, would add up to '''1 * 65536 + 3067 = 68602 s''' or '''19 hours 3 minutes 23 seconds'''.  
+
When the value climbs over 65535 the counter resets and the value held by the first register increases by 1. So one way to interpret the results would be to multiply the value in the first register by 65536 (2<sup>16</sup>) and add the value of the second register: '''%MW1 * 65536 + %MW2'''. Which, following from the example above, would add up to '''1 * 65536 + 3067 = 68603 s''' or '''19 hours 3 minutes 23 seconds'''.  
    
However, while this works when calculating uptime values, it will not work for all parameters. The correct way to calculate the final values would be to first convert them to '''binary'''. As mentioned earlier in this chapter, a register holds 16 bits of information. 16 bits of information can be represented by a 16-digit long binary number. Following from the example above, the first register's value of 1 converted to binary would be '''0000 0000 0000 0001''' and the second register's value of 3067 would be '''0000 1011 1111 1011'''. You can easily convert numbers from one system to another using any online conversion tool:
 
However, while this works when calculating uptime values, it will not work for all parameters. The correct way to calculate the final values would be to first convert them to '''binary'''. As mentioned earlier in this chapter, a register holds 16 bits of information. 16 bits of information can be represented by a 16-digit long binary number. Following from the example above, the first register's value of 1 converted to binary would be '''0000 0000 0000 0001''' and the second register's value of 3067 would be '''0000 1011 1111 1011'''. You can easily convert numbers from one system to another using any online conversion tool:
Line 168: Line 168:  
[[File:Configuration examples modbus decimal to binary.png]]
 
[[File:Configuration examples modbus decimal to binary.png]]
   −
The zeros at the beginning are added to represent the fact that the numbers are expressed in a 16-bit format. The next step is to add the two values, but not in the traditional sense. Instead, the value of the second register should act as an extension of the value of the first register, i.e., '''0000 0000 0000 0001 + 0000 1011 1111 1011 = 0000 0000 0000 0001 0000 1011 1111 1011'''
+
The zeros at the beginning are added to represent the fact that the numbers are expressed in a 16-bit format. The next step is to add the two values, but not in the traditional sense. Instead, the value of the second register should act as an extension of the value of the first register, i.e., '''0000 0000 0000 0001 + 0000 1011 1111 1011 = 0000 0000 0000 0001 0000 1011 1111 1011'''. What happens here is that in this sum the first register's value of 1 shouldn't be considered as 1, but instead as '''65536 (2<sup>16</sup>)''' , which is the value of the 17th digit of a 32-bit long binary number. If you convert this value back to decimal, you will see that we get the same answer:
 +
 
 +
[[File:Configuration examples modbus binary to decimal.png]]

Navigation menu