Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMX160 Any Motion Detection and Flat Detection interrupts are always triggered

    BMX160 Any Motion Detection and Flat Detection interrupts are always triggered

    Nikosant03
    Long-established Member

    Hi everyone,

    I am trying to map some interrupts on CHANNEL1. I followed the API instructions to configure the interrupts with success. So far I have configured the Any-Motion Detection,  Flat Detection, and the NO-Motion Detection

    Regarding the NO-Motion Detection, everything works fine but when I use the Any-Motion Detection & Flat Detection the interrupt they are both always set and never resets. I have experimented with the configuration parameters as well as the acceleration range with no success so far. I have read carefully the manual without being able to find what's going wrong. However, I assume that is something simple.. I checked the registers 0x55-0x57 (INT_MAP), 0x5F-0x62 (INT_MOTION), 0x54 (INT_LATCH) and everything are fine (no latching).

     

    This is the Any-Motion Detection configuration

    void anyMotionInterrupt_set() {
    
      int_config.int_channel = BMI160_INT_CHANNEL_1;   // na - Select the interrupt channel
      int_config.int_type = BMI160_ACC_ANY_MOTION_INT; // na - choosing Any Motion Interrupt
    
      // na - the following configuration is written to registers (0x53) INT_OUT_CTRL & (0x54) INT_LATCH  see datasheet pg71 section 2.11.20
      int_config.int_pin_settg.output_en = BMI160_ENABLE;         // na - Enabling interrupt pin as output -> register (0x53)
      int_config.int_pin_settg.output_mode = BMI160_DISABLE;      // na - Selecting push-pull mode for interrupt pin -> register (0x53)
      int_config.int_pin_settg.output_type = BMI160_DISABLE;      // na - Setting interrupt pin to active low -> register (0x53)
      int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;         // na - Enabling edge trigger -> register (0x53)
      int_config.int_pin_settg.input_en = BMI160_DISABLE;         // na - Disabling interrupt pin to act as input -> register (0x54)
      int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; // na - non-latched output -> register (0x54)
    
      // na - Select the Any Motion Interrupt parameter
      int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE; // na - 1- Enable the any-motion, 0- disable any-motion
      int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE;  // na - Enabling x-axis for any motion interrupt - monitor x axis
      int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE;  // na - Enabling y-axis for any motion interrupt - monitor y axis
      int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE;  // na - Enabling z-axis for any motion interrupt - monitor z axis
      int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 2;            // na - any-motion duration. This is the consecutive datapoints -> see datasheet pg32 section 2.6.1 <int_anym_dur> and pg78
      int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 20;           // na - An interrupt will be generated if the absolute value of two consecutive accelarion signal exceeds the threshold value -> see datasheet pg32 section 2.6.1 <int_anym_th> and pg78 INT_MOTION[1]
                                                                               // na - (2-g range) -> (anymotion_thr) * 3.91 mg, (4-g range) -> (anymotion_thr) * 7.81 mg, (8-g range) ->(anymotion_thr) * 15.63 mg, (16-g range) -> (anymotion_thr) * 31.25 mg
    
      rslt = bmi160_set_int_config(&int_config, &sensor); // na - Set Any-motion interrupt
      NRF_LOG_INFO("rslt: %d", rslt);
    
      if (rslt != BMI160_OK) {
        NRF_LOG_INFO("BMI160 Any-motion interrupt configuration failure!\n");
      } else {
        NRF_LOG_INFO("BMI160 Any-motion interrupt configuration done!\n");
      }
    }

     

    This is the Flat Detection configuration

    void flatInterrupt_set() {
    
      /* 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_FLAT_INT; // Choosing flat 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 push-pull mode 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_NONE; // non-latched output
    
      /* Select the Flat interrupt parameters */
      int_config.int_type_cfg.acc_flat_int.flat_en = BMI160_DISABLE; // 1-enable, 0-disable the flat interrupt
      int_config.int_type_cfg.acc_flat_int.flat_theta = 8;          // threshold for detection of flat position in range from 0° to 44.8°.
      int_config.int_type_cfg.acc_flat_int.flat_hy = 1;             // Flat hysteresis
      int_config.int_type_cfg.acc_flat_int.flat_hold_time = 1;      // Flat hold time (0 -> 0 ms, 1 -> 640 ms, 2 -> 1280 ms, 3 -> 2560 ms) - delay time for which the flat value must remain stable for the flat interrupt to be generated (datasheet pg82)
    
      /* Set the Flat interrupt */
      rslt = bmi160_set_int_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
    
      if (rslt != BMI160_OK) {
        NRF_LOG_INFO("BMI160 flat interrupt configuration failure!\n");
      } else {
        NRF_LOG_INFO("BMI160 flat interrupt configuration done!\n");
      }
    }

     

    This is accel/gyro/mag configuration

    // na - configure Accel sensor
      sensor.accel_cfg.odr = BMI160_ACCEL_ODR_100HZ;     // na - output data rate - Configure accel to measure at 100Hz
      sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;    // na - range
      sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; // na - bandwidth
      sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; // na - powermode
    
      // na - configure Gyro sensor
      sensor.gyro_cfg.odr = BMI160_GYRO_ODR_100HZ;       // na - output data rate - Configure gyro to measure at 100Hz
      sensor.gyro_cfg.range = BMI160_GYRO_RANGE_500_DPS; // na - range
      sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;   // na - bandwidth
      sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;   // na - powermode
    
      rslt = bmi160_set_sens_conf(&sensor); // na - configures the power mode, range and bandwidth of sensors
      APP_ERROR_CHECK(rslt);
    
      bmm150.settings.preset_mode = BMM150_PRESETMODE_REGULAR; //BMM150_PRESETMODE_LOWPOWER; // // na - Presetmode of sensor - Datasheet page 19
      rslt = bmm150_set_presetmode(&bmm150);                   // na - set the preset mode of the sensor
      APP_ERROR_CHECK(rslt);
    
      bmm150.settings.pwr_mode = BMM150_NORMAL_MODE; //BMM150_FORCED_MODE;
      rslt = bmm150_set_op_mode(&bmm150);            //
      APP_ERROR_CHECK(rslt);
    
      // Set the polling rate (Hz). Is the output data rate
      sensor.aux_cfg.aux_odr = BMI160_AUX_ODR_100HZ; // na - Configure accel to measure at 100Hz. See the table on page 67 of the datasheet. 8 = 100Hz , 6 = 25Hz see the formula on pg67 of the datasheet
      bmi160_config_aux_mode(&sensor);
      bmi160_set_aux_auto_mode(&aux_addr, &sensor); // na - Set the auxiliary sensor to auto mode

    Any advice from the experts?

    Thanks in advance

    Nick

     

    4 REPLIES 4

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your inquiry.

    Please try to change BMM150 to forced mode from normal mode and ODR to 25Hz from 100Hz. When you test both any-motion and flat interrupt, please make sure BMI160 is tilted and stationary. Then INT1 pin signal should be low. When you tap BMI160, INT1 should show a pulse. When you put your device flat, then the flat interrupt will show a pulse on INT1 pin.

    Please let us know which country you are located. Our local FAE will support you further.

    Thanks.

    Nikosant03
    Long-established Member

    Thank you for your answer  FAE_CA1

    I will try your suggestion and I will return with feedback.
     
     
    I am located in Cyprus
     is there a FAE for this region?
     
     

    Nikosant03
    Long-established Member

    Hi  FAE_CA1

    I've changed the mode to forced and ODR to 25Hz but still the INT1 pin is always low either when the sensor is flat of tilted.

     

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Sorry that we don't have FAE covering Cyprus. Please try to enable any-motion interrrupt only to see if you can get it to work. Then you can enable flat interrupt only.

    Please see the attached "How to generate single-tap and double-tap interrupt using BMI160 accelerometer.pdf" as a reference. You need to set BMI160 interrupt as push-pull and active high.

    Also please see the attached "How to use BMA253 flat interrupt in low power mode v1.1.pdf" as a reference about how flat interrupt works.

    Thanks.

    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