MMA8452Q - Strange reading values

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MMA8452Q - Strange reading values

Jump to solution
2,874 Views
speryt
Contributor I

Hi,

 

I am currently testing MMA8452Q accelerometer in my application and during test I found totally strange values coming out. While normally all axis should be between 0 - 1 g from very beginning of measurements I have x axis value around 15g. This value is constant no matter if sensor is laying or I am moving it in any direction - all the time it is around 15g. Can someone give me advice what might be wrong? Is it something wrong with IC, or should I look somewhere else? For reference I am enclosing my readings.

 

Thank you in advance.

Original Attachment has been moved to: acc.csv.zip

Labels (1)
0 Kudos
Reply
1 Solution
1,815 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Sebastian,

It looks like an incorrect interpretation of negative acceleration values. How are you converting the raw data from accelerometer registers 0x01 – 0x06 to signed 12-bit values and then real values in g’s?

You might find useful my example code where I illustrate this conversion:


// Signed 12-bit accelerometer data

Xout_12_bit = ((short) (AccelData[0]<<8 | AccelData[1])) >> 4;            // Compute 12-bit X-axis acceleration output value

Yout_12_bit = ((short) (AccelData[2]<<8 | AccelData[3])) >> 4;            // Compute 12-bit Y-axis acceleration output value

Zout_12_bit = ((short) (AccelData[4]<<8 | AccelData[5])) >> 4;            // Compute 12-bit Z-axis acceleration output value

                

// Accelerometer data converted to real values in g's

Xout_g = ((float) Xout_12_bit) / SENSITIVITY_2G;              // Compute X-axis output value in g's

Yout_g = ((float) Yout_12_bit) / SENSITIVITY_2G;              // Compute Y-axis output value in g's

Zout_g = ((float) Zout_12_bit) / SENSITIVITY_2G;              // Compute Z-axis output value in g's     


Let me know whether or not this helps, or if you have any other questions.

Regards,

Tomas

PS: If my answer helps to solve your question, please mark it as "Correct" or “Helpful”. Thank you.

View solution in original post

0 Kudos
Reply
2 Replies
1,816 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Sebastian,

It looks like an incorrect interpretation of negative acceleration values. How are you converting the raw data from accelerometer registers 0x01 – 0x06 to signed 12-bit values and then real values in g’s?

You might find useful my example code where I illustrate this conversion:


// Signed 12-bit accelerometer data

Xout_12_bit = ((short) (AccelData[0]<<8 | AccelData[1])) >> 4;            // Compute 12-bit X-axis acceleration output value

Yout_12_bit = ((short) (AccelData[2]<<8 | AccelData[3])) >> 4;            // Compute 12-bit Y-axis acceleration output value

Zout_12_bit = ((short) (AccelData[4]<<8 | AccelData[5])) >> 4;            // Compute 12-bit Z-axis acceleration output value

                

// Accelerometer data converted to real values in g's

Xout_g = ((float) Xout_12_bit) / SENSITIVITY_2G;              // Compute X-axis output value in g's

Yout_g = ((float) Yout_12_bit) / SENSITIVITY_2G;              // Compute Y-axis output value in g's

Zout_g = ((float) Zout_12_bit) / SENSITIVITY_2G;              // Compute Z-axis output value in g's     


Let me know whether or not this helps, or if you have any other questions.

Regards,

Tomas

PS: If my answer helps to solve your question, please mark it as "Correct" or “Helpful”. Thank you.

0 Kudos
Reply
1,815 Views
speryt
Contributor I

Thank you. That was my mistake.

0 Kudos
Reply