This tool allows to view and convert floating data type to fixed-point data type or vice-versa.
The creation of this tool was triggered by my developments on Field Oriented Control (FOC) for stock hoverboards BLDC motors. The heart of the hoverboard electronic circuit is an STM32F103RCT6 micro-controller with quite some capabilities however, it lacks the presence of a hardware Floating Point Unit (FPU). The lack of this FPU made impossible the development of an FOC controller with floating point data types. Thus, full controller was developed in fixed point for more efficient calculations (check my other repo for details).
A fixed point number format maps a real number onto an integer number by applying a fixed scaling to it. If for example you have real value 3.1415 and a fixed scaling of 100, the resulting integer value would be 3.1415 * 100 = 314. Reconstructing the real number from this value means applying the reverse operation: 314 / 100 = 3.14.
In practice the scaling values used are powers of 2 since multiplication and division by such values can be done by shift operations and shift operations are very efficient on most processor architectures. The advantage of fixed point numbers is that using them, under a certain set of rules, they allow for high performance math operations on processors that lack a hardware Floating Point Unit (FPU). So, one of the main purposes of fixed point data representation is to be able to perform calculations efficiently without the need for expensive floating point conversions.
More details on fixed point data types can be found here:
- Go to FixedPointViewer\exe and run 'FPViewer_setup.exe'
- Follow the installation steps.
- Two SW components will be installed on your computer: the Matlab Runtime and the application itself. You will need both to run the application.
- Once the installation is finished open the FPViewer app
- Enjoy!
The tool usage is quite straight forward. The tool works by:
- Setting the fixed-point parameters in top-right
- Then insert the correspondig float or fixed-point data to be converted
- Finally, the data will be graphically displayed for better visualization
The parameters are in the form (Sign, Word, Fraction):
- Sign: 1 (default) | 0 ► Sign specified as a boolean. A value of 1, indicates a signed data type. A value of 0 indicates an unsigned data type.
- Word length: 16 (default) | scalar integer ► Word length, in bits, specified as a scalar integer.
- Fraction length: 4 (default) | scalar integer ► Fraction length, in bits, specified as a scalar integer.
The tool offers 2 examples:
- Example 1: illustrates how to view and update a 2D surface map.
- Example 2: illustrates how to view and update a 1D map.