Hello MKrishna,
You could get FOC description in BMX160 data sheet. https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmx160-ds0001.pdf FOC could conpensates offset errors of accelerometer and gyroscope.
This is FOC exmaple code for BMX160.
## FOC and offset compensation > FOC shouldnot be used in Low-power mode #### Example for configuring FOC for accel and gyro
/* An example for configuring FOC for accel and gyro data */ int8_t start_foc(struct bmi160_dev *dev) { int8_t rslt = 0; /* FOC configuration structure */ struct bmi160_foc_conf foc_conf; /* Structure to store the offsets */ struct bmi160_offsets offsets; /* Enable FOC for accel with target values of z = 1g ; x,y as 0g */ foc_conf.acc_off_en = BMI160_ENABLE; foc_conf.foc_acc_x = BMI160_FOC_ACCEL_0G; foc_conf.foc_acc_y = BMI160_FOC_ACCEL_0G; foc_conf.foc_acc_z = BMI160_FOC_ACCEL_POSITIVE_G; /* Enable FOC for gyro */ foc_conf.foc_gyr_en = BMI160_ENABLE; foc_conf.gyro_off_en = BMI160_ENABLE;
rslt = bmi160_start_foc(&foc_conf, &offsets, sen); if (rslt == BMI160_OK) { printf("\n FOC DONE SUCCESSFULLY "); printf("\n OFFSET VALUES AFTER FOC : "); printf("\n OFFSET VALUES ACCEL X : %d ",offsets.off_acc_x); printf("\n OFFSET VALUES ACCEL Y : %d ",offsets.off_acc_y); printf("\n OFFSET VALUES ACCEL Z : %d ",offsets.off_acc_z); printf("\n OFFSET VALUES GYRO X : %d ",offsets.off_gyro_x); printf("\n OFFSET VALUES GYRO Y : %d ",offsets.off_gyro_y); printf("\n OFFSET VALUES GYRO Z : %d ",offsets.off_gyro_z); } /* After start of FOC offsets will be updated automatically and * the data will be very much close to the target values of measurement */
return rslt; }
... View more