I get wrong accelerometer's values. I have concatenated xMSB+xLSB, yMSB+yLSB and zMSB+zLSB. Then I verify if the resulting valor is negative, in such case I substract 2^16 to convert from 2's complement number to decimal. Finally I multiply each axis valor by 0.00006 to obtain acceleration values in g units. What I'm doing wrong? What is the effective number of bits?

Thanks!

Thanks!

What do you do to convert the int16 word to engineering units ? I am using LIS331HH sensor for reading the accelerometer.

I am able to read the two registers OUT_X_H & OUT_X_L and combine them into an int16 word. however, I am not sure how to convert it into gs of acceleration. Would -32768 to 32767 correspond to -12g to +12g ?

Please advise.

Thanks,

Kamal Joshi

Sorry for the delay. Here's an example for you to understand it better.

uint8_t xLSB = 0; // LSB x-axis acceleration value

uint8_t xMSB = 0; // MSB x-axis acceleration value

uint8_t yLSB = 0; // LSB y-axis acceleration value

uint8_t yMSB =0; // MSB y-axis acceleration value

uint8_t zLSB =0; // LSB z-axis accelerationvalue

uint8_t zMSB =0; // MSB z-axis acceleration value

short xint =0; //x-axis acceleration value without format

short yint =0; //y-axis acceleration value without format

short zint =0; //z-axis acceleration value without format

float x =0; //x-axis acceleration value

float y = 0; // y-axisacceleration value

float z = 0; // z-axisacceleration value

/* Accelerationvalue reading */

I2C_Read6_LIS3DSH(OUT_X_L,&xLSB, &xMSB, &yLSB, &yMSB, &zLSB, &zMSB);

xint =((xMSB<<8)|xLSB); //Concatenating MSB & LSB (x-axis)

yint =((yMSB<<8)|yLSB); //Concatenating MSB & LSB (y-axis)

zint =((zMSB<<8)|zLSB); //Concatenating MSB & LSB (z-axis)

/* Multiply for0.00006 to obtain g units (+/-2g) */

x =xint*0.00006;

y = yint*0.00006;

z = zint*0.00006;

I hope this will be useful foryou.

Best regards.

Juan

Thank You Juan ! This was helpful !