cancel
Showing results for 
Search instead for 
Did you mean: 

What should be the reason for getting Accelerometer offset value in [g] always zero in MOTION AC library?

omkardixi
Associate II

Basically I'm working on ISM330DLC for interfacing I have used ism330dlc_read_data_polling data example code. So I'm sending the same Accelerometer data to the MOTION AC Library but I'm getting Accelerometer offset value in [g] value always zero I'm not able to understand what should be the reason.

I have done the following settings for the sensor raw data,

/* Enable Block Data Update */
  ism330dlc_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
  /* Set Output Data Rate */
  ism330dlc_xl_data_rate_set(&dev_ctx, ISM330DLC_XL_ODR_104Hz);
  ism330dlc_gy_data_rate_set(&dev_ctx, ISM330DLC_GY_ODR_104Hz);
  /* Set full scale */
  ism330dlc_xl_full_scale_set(&dev_ctx, ISM330DLC_2g);
  ism330dlc_gy_full_scale_set(&dev_ctx, ISM330DLC_2000dps);
  /* Configure filtering chain(No aux interface) */
  /* Accelerometer - analog filter */
  ism330dlc_xl_filter_analog_set(&dev_ctx, ISM330DLC_XL_ANA_BW_400Hz);
  /* Accelerometer - LPF1 path ( LPF2 not used )*/
  ism330dlc_xl_lp1_bandwidth_set(&dev_ctx, ISM330DLC_XL_LP1_ODR_DIV_4);
  /* Accelerometer - LPF1 + LPF2 path */
  ism330dlc_xl_lp2_bandwidth_set(&dev_ctx,
                                 ISM330DLC_XL_LOW_NOISE_LP_ODR_DIV_100);
  /* Accelerometer - High Pass / Slope path */
  ism330dlc_xl_reference_mode_set(&dev_ctx, PROPERTY_DISABLE);
  ism330dlc_xl_hp_bandwidth_set(&dev_ctx, ISM330DLC_XL_HP_ODR_DIV_100);
  /* Gyroscope - filtering chain */
  ism330dlc_gy_band_pass_set(&dev_ctx, ISM330DLC_HP_260mHz_LP1_STRONG);

Do i need to change any settings here now?

Also I'm initializing the MOTION AC library as follows

void library_init()
{
	/*** Initialization ***/
	char lib_version[VERSION_STR_LENG];
	MAC_knobs_t Knobs;
	/* Accelerometer calibration API initialization function */
	MotionAC_Initialize(1);
	MotionAC_GetKnobs(&Knobs);
	Knobs.Sample_ms = REPORT_INTERVAL;
	(void)MotionAC_SetKnobs(&Knobs);
	/* Optional: Get version */
	MotionAC_GetLibVersion(lib_version);
}

Is anything I need to change to init function?

Also I'm feeding the raw data to library as follows

void library_process()
{
	MAC_input_t data_in;
	MAC_output_t data_out;
	float acc_cal_x, acc_cal_y, acc_cal_z;
 
//	/* Get acceleration X/Y/Z in g */
//	MEMS_Read_AccValue(data_in.Acc[0], data_in.Acc[1], data_in.Acc[2]);
 
	data_in.Acc[0] = (float)(acceleration_mg[0]/1000);
	data_in.Acc[1] = (float)(acceleration_mg[1]/1000);
	data_in.Acc[2] = (float)(acceleration_mg[2]/1000);
 
	/* Accelerometer calibration algorithm update */
	MotionAC_Update(&data_in, &is_calibrated);
 
	/* Get Calibration coeficients */
	MotionAC_GetCalParams(&data_out);
 
    sprintf((char *)AC_TX_BUFF,
            "Accelerometer offset value in [g]:%f\t%f\t%f --- quality %d\r\n",
			data_out.AccBias[0], data_out.AccBias[1], data_out.AccBias[2],data_out.CalQuality);
 
    tx_com( AC_TX_BUFF, strlen( (char const *)AC_TX_BUFF ) );
 
 
	/* Apply correction */
	acc_cal_x = (data_in.Acc[0] - data_out.AccBias[0])* data_out.SF_Matrix[0][0];
	acc_cal_y = (data_in.Acc[1] - data_out.AccBias[1])* data_out.SF_Matrix[1][1];
	acc_cal_z = (data_in.Acc[2] - data_out.AccBias[2])* data_out.SF_Matrix[2][2];
}

Also while building I faced undefined MotionAC_LoadCalFromNVM issues now I have added those function as follows

char MotionAC_LoadCalFromNVM(unsigned short int datasize, unsigned int *data)
 
{
 
 return 1; /* FAILURE: Read from NVM not implemented. */
 
}
 
char MotionAC_SaveCalInNVM(unsigned short int datasize, unsigned int *data)
 
{
 
 return 1; /* FAILURE: Write to NVM not implemented. */
 
}

After doing all this things I'm getting output as follows

Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2
Accelerometer offset value in [g]:0.000000      0.000000        0.000000 --- quality 2

As we can see Accelerometer offset value is always zero but quality is always showing as a MAC_CALQSTATUSOK.

Not able to understand exactly where I'm doing mistake. Whether I'm initializing sensor wrongly or i need to change MotionAC_LoadCalFromNVM function not sure exactly waht to do

0 REPLIES 0