Hi
I want to extract 14 bit data out of MMA8451Q Accelerometer and display it over UART. So for storing I am taking int16_t x, y, z; the maximum value which I am getting out is 23736 instead of permissible value 2^14 = 16384. and the minimum value which I am getting out is -17736 instead of the permissible value -16384. I am using FRDM-K20D50M board and the accelerometer is mounted on it. I am using codewarrior with processor expert. I am using MMA8451Q library in processor expert and extracting data using x=MMA1_GetX(); or x=MMA1_MeasureGetRawX(); Kindly look into the matter.
Regards,
Amit Kumar
Hi,
In mma8451q registers, both OUT_X_MSB[7:0] and OUT_X_LSB[7:2] indicates value of X.
You have to read OUT_X_MSB and OUT_X_LSB, and get X value by (OUT_X_MSB << 6) | (OUT_X_LSB >> 2).
Thanks.
Best regards
Terry
So, it has been a while... Did you get the answer?
Hi Alisson
It has been a year now. The data being stored in 16 bit data type so to get 14 bit u need to bit shift the received data 2 times. i.e acc_x >> 2; for all x,y,z values. An alternative solution can be dividing the raw 16 bit value by 4. i.e 2^2(on dividing 2^16 by 2^2 u will get 2^14 bit value i.e 14 bit value which we need but in this case the fluctuation in value is observed more.Hope It helps
Best Regards
Amit
Hello
I also tried printf("%d %d %d \n",MMA1_GetX(),MMA1_GetY(), MMA1_GetZ()); and the maximum values I got was 17408, 15256, 17808 and the minimum values I got was -16384, -16584, -16408 for x,y,z respectively, But the value for 14 bit data should range b/w 16384 to -16384 So i was wondering is it due to the drift in accelerometer?
Regards
Amit Kumar