Changes

115 bytes removed ,  10:18, 8 December 2017
Line 203: Line 203:       −
These are examples of converting an eight-bit two's complement number to decimal. To do this, you first check if the number is negative or positive by looking at the sign bit. If it is positive, simply convert it to decimal. If it is negative, make it positive by inverting the bits and adding one. Then, convert the result to decimal. The negative of this number is the value of the original binary.
+
To change the '''sing''' of a binary number you must invert it add 1 to it. In the case of signal strength, you don't need both register values to do so, only the second one (register 4), which is, in our example, 65477. When converted to binary it's: '''65447 → 1111 1111 1100 0101'''. Next, we'll to invert it and add 1:
   −
    Interpret 11011011 as a two's complement binary number, and give its decimal equivalent.
+
 
        First, note that the number is negative, since it starts with a 1.
+
[[File:Configuration examples modbus negative binary.png]]
        Change the sign to get the magnitude of the number.
+
 
 +
 
 +
The value we got is '''0000 0000 0011 1011'''. When converted to decimal it becomes '''59''', so the final value is '''- 59'''