Bosch Sensortec Community

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

    BMI160 Movement detect help

    New Poster

    BMI160 Movement detect help

    I am using a BMI160.  Normal usage will have the unit "somewhat" horizontal and I would like an interrupt if the unit is moving "too much".  I'd like to be able to program the tolerance of what "too much" means.

    Right now, I am just using the interrupt in register 0x50.

    uint8_t intReg = 0x87;
    bmi160_set_regs( BMI160_INT_ENABLE_0_ADDR, &intReg, 1, &motionSensor );
    intReg = 0x07;
    bmi160_set_regs( BMI160_INT_ENABLE_2_ADDR, &intReg, 1, &motionSensor );
    intReg = 0x07;
    bmi160_set_regs( BMI160_INT_MOTION_3_ADDR, &intReg, 1, &motionSensor );

    My issue is that "any motion" triggers the interrupt. Even typing on my keyboard will trigger is if the unit is sittingon the same desk.  Can someone help me configre this part so it is less sensitive?  I would like to be able to move it a little bit like it can be resting on somoene laying down and not interrupt due to movement from breathing.

    Any help would be greatly appreciated.

     

    my Init code is attached. Unable to attched so pasted here:

    Thanks

    -Ed

     

     

     

    3 REPLIES 3
    Community Moderator

    Re: BMI160 Movement detect help

    Hello,

    There was BMI160 any-motion example on github, you could refer and run it.

    https://github.com/BoschSensortec/BMI160_driver

    New Poster

    Re: BMI160 Movement detect help

    Thank you for your reply.   The code you point to is indeed useful but I am already using it and as I mention above, the interrupt intterups for ANY motion.  I was wondering if there was a way to set a threashold?

    Thanks again,

    -Ed

    Senior Member

    Re: BMI160 Movement detect help

    Hi elandau1260

    There are also some other interrupts available for BMI160. You can find them on pg 4 of the datasheet. Maybe it is also useful for you the Significant Motion interrupt and the  Slow Motion alert.

    By the way the Any Motion and Significant motion interrupts have a thershold that you can to set. I will share my configuration for both interrupts that might be usefull for you.

    Nikosant03_0-1596896248761.png

     

    void anyMotionInt_set(struct bmi160_dev *dev) {
    
      int8_t rslt = 0;
    
      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_ENABLE;           // na - Setting interrupt pin to active high -> 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_2_56_SEC; // 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 = 3;            // 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 = 10;           // 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, dev); // na - Set Any-motion interrupt
      //printf("rslt: %d", rslt);
    
      if (rslt != BMI160_OK) {
        //printf("BMI160 Any-motion interrupt configuration failure!\n");
      } else {
        //printf("BMI160 Any-motion interrupt configuration done!\n");
      }
    }
    
    void significantMotionInt_set(struct bmi160_dev *dev) {
    
      int8_t rslt = 0;
    
      int_config.int_channel = BMI160_INT_CHANNEL_1;   // na - Select the interrupt channel
      int_config.int_type = BMI160_ACC_SIG_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_ENABLE;       // na - Setting interrupt pin to active HIGH -> 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)
    
      int_config.int_type_cfg.acc_sig_motion_int.sig_en = BMI160_ENABLE; // na - 1: Significant motion, 0: Any-motion (datasheet pg79 -> <int_sig_mot_sel>)
      int_config.int_type_cfg.acc_sig_motion_int.sig_mot_skip = 1;       // na - skip time of sig-motion interrupt (datasheet pg34) - sleep for sig_mot_skip - available options: 0= 1.28s, 1= 2.56s, 2= 5.12s, 3=10.24s (datasheet pg34 -> <t_skip>)
      int_config.int_type_cfg.acc_sig_motion_int.sig_mot_proof = 2;      // na - proof time of sig-motion interrupt (datasheet pg34) - motion detected within sig_mot_proof - available options: 0= 0.24s, 1= 0.48s, 2=0.96s, 3= 1.92s (datasheet pg34 -> <t_proof>)
      int_config.int_type_cfg.acc_sig_motion_int.sig_mot_thres = 20;     // na - same as anymotion_thr (see the anymotion interrupt)
    
      rslt = bmi160_set_int_config(&int_config, dev); // na - Set Any-motion interrupt
      //printf("rslt: %d", rslt);
    
      if (rslt != BMI160_OK) {
        //printf("BMI160 Significant motion interrupt configuration failure!\n");
      } else {
        //printf("BMI160 Significant motion interrupt configuration done!\n");
      }
    }

     

     

    Hope that helps

    Nick

    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