Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMI270 gyroscope always zero immediately after initialisation

    BMI270 gyroscope always zero immediately after initialisation

    sebmadgwick
    Established Member

    The first few gyroscope samples immediately after initialisation are always zero.  The corresponding accelerometer samples are of expected values.  Both the gyroscope and accelerometer are configured for the same ODR.  Data is read each time the data-ready interrupt is asserted.

    This behaviour suggests that the gyroscope and accelerometer are not synchronised.  Please can someone clarify what is going on.

    The number of consecutive gyroscope samples equal to zero immediately after initialisation is constant for each ODR as summarised in the table below.  These values are not affected by gyr.filter_perf or gyr.noise_perf.

    ODR (same for gyro and accel)Number of gyro zero samplesCalculated period (ms)
    100220
    200630
    4001743
    8003848
    16008251

     

    Here is the initialisation code for reference:

        // Initialise device
        if (bmi270_init(&bmi270) != BMI2_OK) {
            initialisationFailed = true;
            return;
        }
    
        // Perform soft reset
        bmi2_soft_reset(&bmi270);
        bmi2_set_adv_power_save(BMI2_DISABLE, &bmi270);
    
        // Enable accelerometer and gyroscope
        const uint8_t sensorList[] = {BMI2_ACCEL, BMI2_GYRO};
        bmi2_sensor_enable(sensorList, 2, &bmi270);
    
        // Configure accelerometer
        struct bmi2_sens_config accelerometerConfig = {
            .type = BMI2_ACCEL,
            .cfg.acc.odr = BMI2_ACC_ODR_400HZ,
            .cfg.acc.bwp = BMI2_ACC_NORMAL_AVG4,
            .cfg.acc.filter_perf = 1,
            .cfg.acc.range = BMI2_ACC_RANGE_16G,
        };
        bmi2_set_sensor_config(&accelerometerConfig, 1, &bmi270);
    
        // Configure gyroscope
        struct bmi2_sens_config gyroscopeConfig = {
            .type = BMI2_GYRO,
            .cfg.gyr.odr = BMI2_GYR_ODR_400HZ,
            .cfg.gyr.bwp = BMI2_GYR_NORMAL_MODE,
            .cfg.gyr.filter_perf = 1,
            .cfg.gyr.ois_range = BMI2_GYR_OIS_2000,
            .cfg.gyr.range = BMI2_GYR_RANGE_2000,
            .cfg.gyr.noise_perf = 1,
        };
        bmi2_set_sensor_config(&gyroscopeConfig, 1, &bmi270);
    
        // Configure data ready interrupt on INT1 pin
        struct bmi2_int_pin_config intPinConfig = {
            .pin_type = BMI2_INT1,
            .int_latch = BMI2_INT_NON_LATCH,
            .pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH,
            .pin_cfg[0].od = BMI2_INT_PUSH_PULL,
            .pin_cfg[0].output_en = BMI2_INT_OUTPUT_ENABLE,
            .pin_cfg[0].input_en = BMI2_INT_INPUT_DISABLE,
        };
        bmi2_set_int_pin_config(&intPinConfig, &bmi270);
        bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &bmi270);

     

    2 REPLIES 2

    shellywang
    Occasional Contributor

    This is an expected behavior.

    After sensor initialization, both accelerometer and gyroscope are in suspend mode by default.

    The startup time it takes the accelerometer to start from suspend mode to normal mode is different from the time it takes the gyroscope. The gyroscope is slower than the accelerometer.

    In other words, they are not synchronized at the beginning. But once the gyroscope starts up, they will be synchronized.

    Hi sebmadgwick,

    could you insert a call to bmi2_get_int_status or bmi2_get_status in your interrupt service routine ?

    BMI270 has 3 data ready sources (auxiliary, gyro and accel), but a unified data ready interrupt. If you have more than 1 sensor enabled (especially at different rates), you can read the status to determine the source of the interrupt.

    Synchronicity is guaranteed by design, the sampling of accelerometer, gyroscope and internal temperature sensor is aligned with the updates to the SENSORTIME register. For example, when sampling at 100 Hertz, bits 23..8 will of the SENSORTIME register will become a sample counter, and bit 7..0 indicate the age of the sample.

    o_o
    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist