Hi, This is my init function for the BMI160. I just want to test the accel and the gyro data. The data I get doesn't seem valid. When the device is flat, I get around 0 for X and around 0 for Y, and the Z value is around 17 000. If the measurement is in mg, I would expect it to be around 1000. When I add the FOC (as you can see in the code below), the Z value for the same situation turns around 9500 (see picture). Should I be seeing results around 1000 mg or is it normal to add a formula to set them around 1000 manually ? Thank you Jerome int8_t initBMI160(struct bmi160_dev *dev){
int8_t rslt = BMI160_OK;
dev->id = BMI_DEVICE_ID;
dev->interface = BMI160_SPI_INTF;
dev->read = bosch_read_regs;
dev->write = bosch_write_regs;
dev->delay_ms = nrf_delay_ms;
/* Configure device structure for auxiliary sensor parameter BMM150 */
dev->aux_cfg.aux_sensor_enable = 1; // auxiliary sensor enable
dev->aux_cfg.aux_i2c_addr = BMI160_AUX_BMM150_I2C_ADDR; // auxiliary sensor address
dev->aux_cfg.manual_enable = 1; // setup mode enable
dev->aux_cfg.aux_rd_burst_len = 2;// burst read of 2 byte
rslt = bmi160_init(dev);
/* Select the Output data rate, range of accelerometer sensor */
dev->accel_cfg.odr = BMI160_ACCEL_ODR_1600HZ;
dev->accel_cfg.range = BMI160_ACCEL_RANGE_2G;
dev->accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
/* Select the power mode of accelerometer sensor */
dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
/* Select the Output data rate, range of Gyroscope sensor */
dev->gyro_cfg.odr = BMI160_GYRO_ODR_3200HZ;
dev->gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
dev->gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
/* Select the power mode of Gyroscope sensor */
dev->gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
/* Set the sensor configuration */
rslt = bmi160_set_sens_conf(dev);
/* Initialize the auxiliary sensor interface */
rslt = bmi160_aux_init(dev);
/* Initialize the Fast Offset Compensation (FOC) */
const struct bmi160_foc_conf foc_conf =
{
.foc_gyr_en = BMI160_ENABLE,
.foc_acc_x = BMI160_FOC_ACCEL_0G,
.foc_acc_y = BMI160_FOC_ACCEL_0G,
.foc_acc_z = BMI160_FOC_ACCEL_NEGATIVE_G,
.acc_off_en = BMI160_ENABLE,
.gyro_off_en = BMI160_ENABLE
};
struct bmi160_offsets offset;
offset.off_acc_x = 0;
offset.off_acc_y = 0;
offset.off_acc_z = 0;
offset.off_gyro_x = 0;
offset.off_gyro_y = 0;
offset.off_gyro_z = 0;
bmi160_start_foc(&foc_conf, &offset, dev);
nrf_delay_ms(255);
return rslt;
}
... View more