AnsweredAssumed Answered

Offset Calibration for MMA8451Q

Question asked by Chetan Veer on Sep 3, 2015

Hi,

I am using MMA8451q( Accelerometer ) for our project. We are doing the offset calibration by following AN4069 application note.

Following is the scenario,

1. Accelerometer is at flat position.

2. Before calibration, I am getting following values for X, Y, Z

   X = 0.0123 g

   Y = 0.0345 g

   Z = 1.0034 g

3. After calibration, we are getting following values.

   X = 0.0003 g

   Y = 0.0005 g

   Z = 0.2034 g

 

But according to application note Z axis value should be 1.0000.

 

Below is the code snippet for offset calibration,

UINT32 uiAPI_AccelerometerOffsetCalibration()

{

     UINT8 X_OFF, Y_OFF, Z_OFF;

     UINT16 XData = 0, YData = 0, ZData = 0;

     UINT32 rc = UNSUCCESSFUL;

     /*Configure for ODR = 200 Hz and 2g mode.*/

 

     MMA845x_Standby();

     IIC_RegWrite(XYZ_DATA_CFG, 0x00);

     IIC_RegWrite(CTRL_REG1, 0x11) ;

     /*read X-co ordinate*/

 

     if(!uiAPI_AccelerometerReadXYZData(&XData, &YData, &ZData))

         NGT_LOG(DBG_INFO, "Accelerometer.log", "Unsuccessful to read X Y Z "

         "co ordinate.\n");

     /*calculate 2's complement*/

     X_OFF = ~XData + 1;

 

     /*calculate 2's complement*/

     Y_OFF = ~YData + 1;

 

     /*calculate 2's complement*/

     Z_OFF = ~ZData + 1;

 

     /*Calculate offset correction value for each axis*/

     X_OFF = X_OFF/8; 

     Y_OFF = Y_OFF/8;

     Z_OFF = (4096 - (Z_OFF/8));

 

     MMA845x_Standby();

     /*write on to offset register*/

     IIC_RegWrite(OFF_X, X_OFF);

     IIC_RegWrite(OFF_Y, Y_OFF);

     IIC_RegWrite(OFF_Z, Z_OFF);

     /* Set acc back to active mode */

     MMA845x_Active();

     return rc;

 

}

 

Thanking you in advance.

Outcomes