cancel
Showing results for 
Search instead for 
Did you mean: 

How do you calculate LSM6DS3TR-C X,Y and Z user offsets?

kaygee
Associate II

Is there simple and straight-forward way to calculate the user offsets and store it in the relevant register

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @kaygee​ ,

My suggestion is to characterize the LSM6DS3 offset in a known position, typically perfectly flat on a floor, with the z axis pointing upwards. Then you can store the found value in the user registers and it will be automatically applied to the data-out stream.

-Eleon

View solution in original post

5 REPLIES 5
Eleon BORLINI
ST Employee

Hi @kaygee​ ,

My suggestion is to characterize the LSM6DS3 offset in a known position, typically perfectly flat on a floor, with the z axis pointing upwards. Then you can store the found value in the user registers and it will be automatically applied to the data-out stream.

-Eleon

kaygee
Associate II

Hi @Eleon BORLINI​ 

Noted, Thanks

kaygee
Associate II

@Eleon BORLINI

I have a Adafruit breakout board of the LSM6DS3TR-C.

I managed to I2C communication working between the PIC-microcontroller and the LSM6DS3TR-C.

I am able to read the XYZ register for the Accelerometer, the Gyroscope and the Magnometer.

The problem is I tried to get data fused so I can compute the Pitch, Roll and Yaw. My problem is my values jump around and they are not consistent. Since I could not find an example of how to compute the Pitch, Roll and Yaw values. I based my program on the code written by Kris Winer for the LSM9DS1 (https://github.com/kriswiner/LSM9DS1/blob/master/LSM9DS1_BasicAHRS_Nano33.ino), Because I could not find the appropriate code for the LSM6DS3TR-C. I had a look at the code suggested by ST, on Github (https://github.com/STMicroelectronics/lsm6ds3tr-c-pid) which I found to be too basic for what I am trying to do. There is nothing about fusing data after reading it.

As you suggested that I lay the breakout board flat on a table and take a few measurements. Then store them in the user offset registers. The problem is I do not understand how the below fits into calculating the offsets.

CTRL6_C register description

USR_OFF_W: Weight of XL user offset bits of registers X_OFS_USR (73h),

FUNC_CFG_ACCESS (01h), Z_OFS_USR (75h)

0 = 2-10 g/LSB

1 = 2-6 g/LSB

So I made the user offsets all zeros

X_OFS_USR (73h) = 0,

X_OFS_USR (74h) = 0,

Z_OFS_USR (75h) = 0,

And still the Pitch, Roll and Yaw values still jump around a lot.

Is there any website or example code you can point me to, which I can use as an example for my application

kaygee
Associate II

The typical offset values calculated are:

Offset_X = 105

Offset_Y = -1353

Offset_Z = 17573

The question is how do I store these values in the 8 bit user offset registers

kaygee
Associate II

The code from Adafruit is unnecessarily bloated because they try to cater for a lot of accelerometers in one program