cancel
Showing results for 
Search instead for 
Did you mean: 

Hi everyone, I'm using LSM6DSL mems for my application with st_lsm6dsx driver for linux. But I doubt whether the raw readings that I am getting is wrong. Please see the readings below:-

AP S.1
Associate

 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

1 REPLY 1
Eleon BORLINI
ST Employee

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:

  • x_axis int16 = 759 --> 42.3 mg
  • y_axis int16 = 2273 --> 138.6 mg
  • z_axis int16 = 15979 --> 974.72 mg (this is the 1g earth-gravity vector)

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