2014-11-17 02:45 AM
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!
2014-12-11 04:56 AM
I can't understand how so many people have problems about LIS3DSH and any ST's moderator responds.
2014-12-17 01:28 AM
Problem solved. The code was correct, the incorrect functioning was due to a bad connection to one accelerometer's ground pin. If anyone has problems using LIS3DSH by I2C I could help them.
2014-12-18 12:27 PM
Hi Juan,
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 Joshi2014-12-28 03:55 AM
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.Juan2015-01-05 12:33 PM
2015-01-22 04:04 AM
That is ok but by multiplying by a float with one digit of precision your output accuracy in g's is a bit off. you get the .00006 (approx.) by dividing 2G'sby 2^^15 (16 bits precision signed) which yields .0000610352, which is about 2% off if you care. you could use 6.10352E-5 for a truer representation of 1G, or divide by 32k