2021-12-19 06:39 PM
I am using STM32F404 MCU
I have interacted MPU6050 with my MCU and now i want to put IMUs data into some Eular equations for my application
I have enabled FPU of Processor and using math.h library to code the equations
i have observed that its takes time for MCU to solve these equations
I want to know is their a way by which i can code the equation in such a way that that the computational time minimizes
2021-12-19 09:51 PM
If the math is too slow and you have plenty of rom space, you can use a table. You can put all the values that may correspond to the input values into a fixed array and read them as OUT[INPUT]. After writing a formula in excel and obtaining the output values for all possible inputs, you can turn this table into an array with very little effort.
You can make optimizations such as lowering the sensor resolution and reducing the space the directory will occupy in the rom.
2021-12-19 11:43 PM
The F4 FPU supports 32-bit floating point (float) only. It easily happens that the code uses 64-bit floating point (double). That may happen inadvertently by using double constants, parameter passing etc.. Check the .map file for calls to unexpected math emulation functions and, if present, eliminate those.
hth
KnarfB
2021-12-20 05:44 AM
@KnarfB "It easily happens that the code uses 64-bit floating point (double). That may happen inadvertently"
Indeed - see: https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/ for more details