EasyManua.ls Logo

Solo MINI - Converting Float Data Type to Sfxt(32-17) Data Type

Solo MINI
75 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SOLO Communication Manual - UART and USB
www.solomotorcontrollers.com
September 2021 - Revision V_1.0.1 Copyright © 2021, All right Reversed. SOLO motor controllers.
16
Converting float data type to Sfxt(32-17) data type :
If the DATA section of a packet to be sent to SOLO, contains a number in Fixed-Point format,
you can use the following two methods to convert your real world float number into a Sfxt(32-
17) data type depending on the sign of the float data and whether if it’s a positive value or a
negative value:
Condition1) If the float number is Positive:
1- Multiply the float number into 131072
2- Round down the result into the nearest integer value
3- convert this value to HEX
Condition2) If the float number is Negative:
1- Multiply the float number into 131072
2- Round down the result into the nearest integer value
3- Ignore the sign of the integer and convert this value to HEX (compute the Absolute value)
4- Subtract data from "0xFFFFFFFF"
Example 1_ positive float number:
Data to be sent : 4.2
Conversion:
1) 4.2 * 2^17 = 550,502.4
2) Round(550502.4) = 550502
3) Hex (550502) = 0x0086666
Example 2_ negative float number:
Data to be sent : -14.36
Conversion:
1) -14.36 * 2^17 = -1,882,193.92
2) Round(-1,882,193.92) = -1,882,193
3) Hex (abs (-1,882,193) )= 0x 001CB851
4) 0xFFFFFFFF - 0x001CB851 = 0xFFE3 47AE

Table of Contents

Related product manuals