AnsweredAssumed Answered

MMA8562 giving strange acceleration values

Question asked by Morten Piil on Sep 28, 2015
Latest reply on Oct 9, 2015 by Morten Piil

Hi I've just started using the MMA8562 sensor in a project where I want to calculate my position as time goes by.

I want to do this by using a gyro (FXAS21002C) and the accelerometer.

I would like to get the 3 axis acc values with 12.5Hz sample rate and after correcting with the gyro values double integrate to find my position in x and y as time goes by.

So far the setup is stationary on my desk.

If the PCB is flat I get good results: x and y is near zero and I see the gravity in the z channel (value of around 16600) , and samples come in with 12.5Hz

But if I lift the PCB edge a few (5-10) degrees the z component disapears - so I get all three values near zero - gravity disapeared???

The MMA8562 can then measure with or without the gravity acceleration and it can change from second to second??

If I put the PCB on the side I can get the gravity in the X direction - but again the value can then disappear without warning.

 

These are the commands I use to intialize the MMA8562:

    IIC_WriteReg(0x1d, 0x2b, 0x40); //Reset accelerometer

    __delay_ms(10);

    IIC_WriteReg(0x1d, 0x2b, 0x00); //remove reset - maybe not nessesary

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x0e, 0x00); //select 2g range

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x2b, 0x12); //High resolution

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x2c, 0x02); //Interrupt active high

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x2d, 0x01); //Interrupt on Data Ready

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x2e, 0x01); //Data ready comes out on Int1 pin

    __delay_ms(1);

    IIC_WriteReg(0x1d, 0x2a, 0x29); //Sample at 12.5Hz and activate

 

Is there some more registers I need to program to just get the raw accelerations?

 

Here is an example where I have rotated the PCB up to vertical - I write out every 25 samples and move the board very slowly

ACC  X:   -80  Y:   -32  Z: 16672 first the board i laying flat on the desk

ACC  X:   -80  Y:   -32  Z: 16672 

ACC  X:   -96  Y:   -16  Z: 16672

ACC  X:   -80  Y:   -48  Z: 16672

ACC  X:   -80  Y:   -32  Z: 16672

ACC  X:   -96  Y:   -32  Z: 16688

ACC  X:   -80  Y:   -32  Z: 16688  Now I start lifting the PCB

ACC  X:  1552  Y:   -32  Z:   -32   Some of the gravity is now in the X channel, but where is the Z component?

ACC  X:  -112  Y:   -64  Z:   -48    Now all is gone

ACC  X:  6176  Y:   -48  Z: 15376  This is what I would expect 

ACC  X:  6192  Y:   -32  Z:   -32    There goes the Z component again

ACC  X:  9760  Y:   304  Z:   -16   --

ACC  X:  -112  Y:  -112  Z:  -128   all gone!

ACC  X:   -64  Y:    16  Z:   -64   

ACC  X:   -96  Y:   -64  Z:  -112   

ACC  X: 15648  Y:   -32  Z:  3856    Here We are at almost vartical - all good

ACC  X:  -128  Y:   -64  Z:   -48    all gone

ACC  X:   -96  Y:   -64  Z:  3344    Now we got Z back but where is X?

ACC  X:   -16  Y:   -96  Z:  2928  

ACC  X: 15872  Y:   -96  Z:   -80   Here's X but no Z

 

Any help would be greatly appreciated.

Morten

Outcomes