2018-06-18 10:40 PM
Hi
I am using the accelerometer LIS2DE12 with MC60. Can you tell me how I can calculate the acceleration from the sensitivity being displayed?2018-06-19 12:59 AM
Cast the raw value to signed variable and multiply it by sensitivity according to the selected Full Scale.
2018-06-19 03:04 AM
Uh I didn't get you. Where do I get the selected FS bits from?
Sorry I'm a complete newbie2018-06-19 03:13 AM
In CTRL_REG4 register.
2018-06-29 01:19 AM
Can someone tell me if the functions and calculations I am using are correct? If yes, how do I get the value of acceleration along the X-axis? If no, what am I doing wrong? Please let me know. Took
ACCLEROMETERSENSITVITY
value as 2.u16 Accelerometer_ReadRawData_X(void)
{ u16 lowerByte; u16 upperByte; u16 axiesX; Accelerometer_ReadReg(&lowerByte, LIS2DE_OUT_X_L); // Function to read value in register LIS2DE_OUT_X_L Accelerometer_ReadReg(&upperByte, LIS2DE_OUT_X_H); axiesX = (u16)upperByte; return axiesX;}u16 Accelerometer_ReadSensitivity_Xaxies(void){u16 value = Accelerometer_Sensitivity(Accelerometer_ReadRawData_X());
return value;}u16 Accelerometer_Sensitivity(u16 input){ u16 value; u16 sensitivityVal; switch(ACCLEROMETERSENSITVITY) { case 2: value = 16; break; case 4: value = 8; break; case 8: value = 4; break; case 16: value = 2; break; default: value = 16; break; } sensitivityVal = (u16)input * 1000/(1024*value); return sensitivityVal;}