Bosch Sensortec Community

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

    bmi160 tap detection

    bmi160 tap detection

    Gideon
    Long-established Member

    Dear

     

    I am trying to see the tap interrupt(Single and Double). It seems that it doesn't work properly even single tap detection.

    Please, review what I enabled and configured the registers for tap sensing. The file attached.

     

    Thanks,

    bmi160 tap.PNG

     

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Gideon,

    TAP feature needed high ODR, you could set ODR to 200 Hz and test it again.

    Gideon
    Long-established Member

    Thanks for your help.

     

    Could you let me get the best configuration values for double tap?

     

    Here are settings that I evaluated but it is hard to see double tap interrupt. 

    Sometimes, the double tap interrupt occurs but not every time.

     

    int_config.int_channel = BMI160_INT_CHANNEL_2;// Interrupt channel/pin 1

    int_config.int_type = BMI160_ACC_DOUBLE_TAP_INT;// Choosing Any motion interrupt
    /* Select the interrupt channel/pin settings */
    int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
    int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing Open drain for interrupt pin
    int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active low output
    int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
    int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
    // int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_80_MILLI_SEC;// non-latched output
    // int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_160_MILLI_SEC;
    int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_10_MILLI_SEC;

    // Configure accel and gyro sensors in normal mode
    sensor.accel_cfg.odr = BMI160_ACCEL_ODR_200HZ;
    sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;
    sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
    sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;

    sensor.gyro_cfg.odr = BMI160_GYRO_ODR_50HZ;
    sensor.gyro_cfg.range = BMI160_GYRO_RANGE_125_DPS;
    sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
    sensor.gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE;
    /* Set the Power mode */
    rslt = bmi160_set_power_mode(&sensor);

    /* Select the Any-motion interrupt parameters */

    int_config.int_type_cfg.acc_tap_int.tap_thr = 4; // 62.5mg * val for 2g
    // 125mg * val for 4g
    int_config.int_type_cfg.acc_tap_int.tap_shock = BMI160_DISABLE; // 0 : 50ms / 1 : 75ms
    int_config.int_type_cfg.acc_tap_int.tap_quiet = BMI160_DISABLE; // 0 : 30ms / 1 : 20ms
    int_config.int_type_cfg.acc_tap_int.tap_data_src=BMI160_DISABLE; // filtered or pre-filtered
    int_config.int_type_cfg.acc_tap_int.tap_dur = 3; //0:50ms, 1:100ms, 2:150ms, 3:200ms, 4:250ms....
    int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_ENABLE;

     

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Gideon,

    Here is BMI160 double TAP code for your reference.

    int8_t rslt = BMI160_OK;
    struct bmi160_int_settg int_config;
    /* Select the Interrupt channel/pin */
    int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1

    /* Select the Interrupt type */
    int_config.int_type = BMI160_ACC_DOUBLE_TAP_INT;
    /* Select the interrupt channel/pin settings */
    int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
    int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
    int_config.int_pin_settg.output_type = BMI160_ENABLE;// Choosing active high output
    int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE;// Choosing edge triggered output
    int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
    int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_80_MILLI_SEC;// latched output

    /* Select the Flat interrupt parameters */
    int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_ENABLE;//tap enable, 1 - enable, 0 - disable
    int_config.int_type_cfg.acc_tap_int.tap_data_src=BMI160_ENABLE;//data source 0- filter & 1 pre-filter
    /*tap duration, select the length of the time window for the second shock event for double tap detection,
    000 - 50ms, 001 - 100ms, 010 - 150ms, 011 - 200ms, 100 - 250ms, 101 - 375ms, 110 - 500ms, 111 - 700ms*/
    int_config.int_type_cfg.acc_tap_int.tap_dur = 2;
    int_config.int_type_cfg.acc_tap_int.tap_quiet = BMI160_DISABLE;//tap quiet, 0 - 30ms, 1 - 20ms
    int_config.int_type_cfg.acc_tap_int.tap_shock = BMI160_DISABLE;//tap shock duration, 0 - 50ms, 1 - 75ms
    int_config.int_type_cfg.acc_tap_int.tap_thr = 2;//tap threshold

    /* Set the Flat interrupt */
    rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */

    Gideon
    Long-established Member

    Thanks a lot.

    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