Closed jerabaul29 closed 1 year ago
Hi @jerabaul29 , all the MEMS drivers that you can find in stm32duino repositories have the same units:
mg for accelerometer (thousandth of 1g that is 9.81 m/s^2) mdps for gyroscope (thousandth of degree/s) mgauss for magnetometer (thousandth of gauss)
regarding the GetSensitivity, exactly; it is the scaling constant that changes according the full scale and transforms the raw value to the units. We exported also GetSensitivity and GetAxesRaw APIs, so user can customize the output in the unit that he prefers. For example if you want the unit of the accelerometer in float "g" you can do:
int16_t acc_raw[3];
float acc_g[3];
float acc_sensitivity;
AccGyr.ACC_GetAxesRaw(acc_raw);
AccGyr.ACC_GetSensitivity(&acc_sensitivity);
acc_g[0] = ((float)acc_raw[0] * acc_sensitivity) / 1000.0f;
acc_g[1] = ((float)acc_raw[1] * acc_sensitivity) / 1000.0f;
acc_g[2] = ((float)acc_raw[2] * acc_sensitivity) / 1000.0f;
Best Regards, Carlo
Perfect, many thanks :) . For people who just come into this repository without knowing background information about the stm32duino conventions, and to make the repository self consistent, could it be added to the .h of .cpp documentation, and / or to the readme? :) . That would be very helpful, it is just so easy to get confused with units and dimensions :) .
Thanks for the feedback! Anyway, any improvement to the library is welcome. So, I invite you to submit pull requests also only on Readme file or some comments in the source code in order to improve the readability of the library. Any contribution from community is welcome!
:) .
I will try to find time for this over the weekend :) .
I finally found the time to write this down and open a pull request, let's discuss on the pull request if it is ok :) .
I was a bit confused at first about which units are used; I cannot see either in the .h or the .cpp file the unit for
ISM330DHCXStatusTypeDef ISM330DHCXSensor::ACC_GetAxes(int32_t *Acceleration)
for example. I found the information in the example here:https://github.com/stm32duino/ISM330DHCX/blob/16a3c67dc94a53a6c3115641330449f1e58f3da4/examples/ISM330DHCX_DataLog_Terminal/ISM330DHCX_DataLog_Terminal.ino#L108-L109
but wonder if units should be documented in details in the .h or .cpp?
It would be really useful to get the units for:
GetAxes
methods, for acc and gyrGetSensitivity
methods, for acc and gyr (I think that it converts from "raw value" to "mg")