AnsweredAssumed Answered

LIS2DH12 Measure conversion

Question asked by P M on Jun 6, 2017
Latest reply on Jun 12, 2017 by Miroslav B

I am having some problems when I try to get data from my sensor. I can read registers and get some data but I don't know how I should do the covnersion to get a real value.

I am using an arduino and I found some libraries. Those libraries tend to use this format:

x = ((int8_t)sensorData[1])*256+sensorData[0];
y = ((int8_t)sensorData[3])*256+sensorData[2];
z = ((int8_t)sensorData[5])*256+sensorData[4];

Where position 0 of sensorData starts at OUT_X_L (28h) and goes up.

Is this right? I have read something about left justified of LSB and I think it should be like:

Is it the same?

Apart from that, they use a formula to get mg values from the x,y and z values:

x = (int32_t)x*1000/(1024*mgScaleVel); //transform data to millig, for 2g scale axis*1000/(1024*16),
y = (int32_t)y*1000/(1024*mgScaleVel); //for 4g scale axis*1000/(1024*8),
z = (int32_t)z*1000/(1024*mgScaleVel); //for 8g scale axis*1000/(1024*4)

What is this about? where does this formula appear? Is it correct? How should I parse the data?

Outcomes