SOLO Communication Manual - UART and USB
www.solomotorcontrollers.com
September 2021 - Revision V_1.0.1 Copyright © 2021, All right Reversed. SOLO motor controllers.
17
Converting 32 bits Hex data to signed INT32 format:
If you want to convert a DATA part of a packet read from SOLO into the real world Int32 format,
based on the sign of the DATA you will fact the following two conditions for the conversion:
Condition1) If the data read from SOLO is less than or equal to 0x7FFFFFFF(Hex) or
2147483647 (decimal), This means the data is positive
When the data is positive, we can treat it like a normal unsigned value, so you can just directly
convert the Hex value to decimal with known methods.
Condition2) If the data read from SOLO is greater than 0x7FFFFFFF(Hex) or
2147483647(decimal), This means the data is negative, so the conversion will be as :
1) Subtract the data from 0xFFFFFFFF and then add a 0x1 to it (add 1 to it)
2) Convert the result of step “1” into Decimal format
3) Multiply the result of step 3 to “-1”
Example 1_ positive Numbers:
Data read from SOLO is “0x0003F393”
- The data is smaller than 0x7FFFFFFF so it becomes : Dec (0x0003F393) = +258963
Example 2_ negative Numbers:
Data read from SOLO is “0xFFFCA8AD”
- The data is bigger than 0x7FFFFFFF so we will have:
1. (0xFFFFFFFF - 0xFFFCA8AD ) + 1 = 0x00035753
2. Dec(0x00035753) = 218963
3. 218963 * -1 = -218963