2021-01-04 07:46 PM
cat /sys/bus/iio/devices/iio\:device0/in_accel_x_raw
759
cat /sys/bus/iio/devices/iio\:device0/in_accel_y_raw
2273
root@nitrogen6x:~# cat /sys/bus/iio/devices/iio\:device0/in_accel_z_raw
15979
These are the values that i am getting when reading the sysfs nodes of the sensor. Are there values expected?
Also How do we calculate the X_OFS_USR, Y_OFS_USR and Z_OFS_USR register values from raw x,y,z readings?
Thanks in advance.
#lsm6dsl #accelerometer #calibration
2021-01-07 03:24 AM
Hi @AP S.1 ,
they could be plausible values, especially if you are working with FS = +-2g. I suggest you to refer to the C drivers on Github for the LSM6DSL, lsm6dsl_reg.c:
float_t lsm6dsl_from_fs2g_to_mg(int16_t lsb)
{
return ((float_t)lsb * 0.061f);
}
In particular, in your case:
Since these values are not too accurate, I suggest you first to check if your device is fully planar (z axis should be close to 1g and x and y close to 0g): some tilt can namely be introduced by the placing on the application or even by the soldering process that results in a non-uniform solder paste dispensing.
For this reason, after checking to be fully planar, you can perform some consecutive measure for each axis, calculate the average and insert the values into the X_OFS_USR, Y_OFS_USR and Z_OFS_USR registers: the device automatically subtract internally this offset value to the dataout values in the data acquisitions performed after the user offset configuration.
You could also decide to perform a more accurate accelerometer calibration using the available libraries provided by ST and included in the X-CUBE-MEMS1 firmware function pack for STM32 microcontroller, especially the MotionAC library.
Please let me know if this answer has been helpful for you.
-Eleon