Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMA400 - fall detection + tap detection and inactivity + auto-low power

    Highlighted
    New Poster

    BMA400 - fall detection + tap detection and inactivity + auto-low power

    Hi,

    I'm developing some code based on BMA400 datasheet and I2C connection code to use the sensor as fall detector, tap detector and inactivity detector.

    First question, it's possible ? 

    So, until now I create the code to generate a fixed interrupt ( until read 0x0E flag ) with 1 interrupt in INT1 to detect falls.

     

     

     

    void EnableDetectionOfFreeFall() {
      
      //COMMON REGISTERS:
      sensorWrite(0x19, 0x02);//Write 0x02 to register 0x19 (BMA400_ACC_CONFIG_0); // bring BMA400 to normal mode form sleep mode ->  SLEEP = 0x00, // Stop conversion LOW_POWER = 0x01, NORMAL = 0x02,
      delay(10);
      sensorWrite(0x1A, 0x49);//Write 0x49 to register 0x1A (BMA400_ACC_CONFIG_1); // set BMA400 to 200Hz ODR, +/-4g full scale range and 0 over sampling rate (OSR) meaning one single measurement without averaging. The current consumption is about 3.5uA
      delay(10);
      sensorWrite(0x1B, 0x00);//Write 0x00 to register 0x1B (BMA400_ACC_CONFIG_2); // select acc_filt1 200Hz as source for data registers
      delay(10);
    
      //INTERRUPT 1 PARAMETERS FOR FREE FALL DETECTION:
      sensorWrite(0x3F, 0xF0);//Write 0xF0 to register 0x3F (BMA400_GEN_1_INT_CONFIG_0);   // enable X/Y/Z axis for interrupt evaluation. Gen1 interrupt engine data source is acc_filt2 which is fixed 100Hz ODR or 10ms time interval. Manual update and hysteresis 0mg
      delay(10);
      sensorWrite(0x40, 0x01);//Write 0x01 to register 0x40 (BMA400_GEN_1_INT_CONFIG_1);   // select inactivity detection which means the interrupt will be generated within the positive and negative threshold zone. Select AND logic meaning that when all enabled axes enter the threshold zone simultaneously an interrupt will be generated
      delay(10);
      sensorWrite(0x41, 0x46);//Write 0x3F to register 0x41 (BMA400_GEN_1_INT_CONFIG_2);   //  set inactivity threshold to 0x3F = 63LSBs = 63LSBs * 8mg/LSB = 504mg (can be fine-tuned). So the threshold zone is +/-504mg
      delay(10);
      sensorWrite(0x42, 0x00);  //Write 0x00 to register 0x42 (BMA400_GEN_1_INT_CONFIG_3); // set MSB of Gen1 interrupt duration to 0x00
      delay(10);
      sensorWrite(0x43, 0x10);//Write 0x0C to register 0x43 (BMA400_GEN_1_INT_CONFIG_3_1); // set LSB of Gen1 interrupt duration to 0x0C = 12LSBs = 12 * 10ms =120ms (can be fine-tuned). This corresponds to about 7cm height freefall. H =0.5 * g * t^2 = 0.5 * 9.81m/s^2 * (0.12s)^2
      delay(10);
      sensorWrite(0x44, 0x00);//Write 0x00 to register 0x44 (BMA400_GEN_1_INT_CONFIG_4);
      delay(10);
      sensorWrite(0x45, 0x00);//Write 0x00 to register 0x45 (BMA400_GEN_1_INT_CONFIG_5);   // set X axis reference to 0mg
      delay(10);
      sensorWrite(0x46, 0x00); //Write 0x00 to register 0x46 (BMA400_GEN_1_INT_CONFIG_6);
      delay(10);
      sensorWrite(0x47, 0x00);//Write 0x00 to register 0x47 (BMA400_GEN_1_INT_CONFIG_7);   // set Y axis reference to 0mg
      delay(10);
      sensorWrite(0x48, 0x00);//Write 0x00 to register 0x48 (BMA400_GEN_1_INT_CONFIG_8);
      delay(10);
      sensorWrite(0x49, 0x00);//Write 0x00 to register 0x49 (BMA400_GEN_1_INT_CONFIG_9);   // set Z axis reference to 0mg > Because the manual update is selected for Gen1, every 10ms BMA400 Gen1 will compare the X/Y/Z measurement data against the X/Y/Z references respectively to check if the differences are all within the threshold or not. If yes, then the duration timer will start counting. If not,then the duration timer will be reset to 0.
      delay(10);
      //
    
      //CONFIGURE INTERRUPT REGISTERS
      sensorWrite(0x1F, 0x04); //Write 0x04 to register 0x1F (BMA400_INT_CONFIG_0);  // enable generic interrupt 1 (Gen1)
      delay(10);
      sensorWrite(0x21, 0x04);//Write 0x04 to register 0x21 (BMA400_INT_1_MAP);     // route Gen1 interrupt signal to INT1 pin
      delay(10);
      sensorWrite(0x24, 0x22);//Write 0x2 2 to register 0x24 (BMA400_INT_1_2_CTRL);  // set INT1 pin and INT2 pin both to push-pull and active-high
      delay(10);
    
      //FORCE STOP
      //force to accept the interrupt on regist 0x20 (BMA400_INT_CONFIG_1) until clear regist 0x0E (BMA400_INT_STAT0)
       sensorWrite(0x20, 0x80);
       delay(10);
       
    }

     

     

    This code works fine and I can detect falls.

    The idea is to mearge with something like this for int2:

    void EnableDetectioOfInactivity() {
    
      //COMMON REGISTERS:
      sensorWrite(0x22, 0x04); //Set interrupt 2 
      delay(10);
      sensorWrite(0x1F, 0x00);
      delay(10);
      sensorWrite(0x24, 0x02);
      delay(10);
      sensorWrite(0x4A, 0xFA);
      delay(10);
      sensorWrite(0x4B, 0x01);
      delay(10);
      sensorWrite(0x4C, 0x05);
      delay(10);
      sensorWrite(0x4D, 0x00);
      delay(10);
      sensorWrite(0x4E, 0xFF);
      delay(10);
      sensorWrite(0x1F, 0x04);
      delay(10);
      
    }

     

    To detect TAPS, I can use the sensors acceleration direcly if it's not possible to use 3 methods like this.

    I need some help merge this and add TAP option..

    Thanks for the help.

    Best Regards

     

    4 REPLIES 4
    Highlighted
    Community Moderator

    Re: BMA400 - fall detection + tap detection and inactivity + auto-low power

    First, i will say it is possible.  

    BMA400 already have TAP interrupt integrated,  you just need to enable that and map it to INT pin.  

    You can map more than one interrupt source to INT pin.  

    So with those 3 interrupt source from BMA400 INT pin is possible.  

    Do you expect some source code to enable those interrupt? 

    Highlighted
    New Poster

    Re: BMA400 - fall detection + tap detection and inactivity + auto-low power

    Hi, 

    Thanks for you time. Yes. If it's possible you can change my code to adapt INT1 to fall detections and INT2 to detect Inactivity and taps ? 

    I read the manual but I am not able to put it into practice.

    Thank you a lot.

    Joao

    Highlighted
    New Visitor

    Re: BMA400 - fall detection + tap detection and inactivity + auto-low power

    Hi Joao,

    we´r a vienna based company selling a product with fall detection, tap detection and inactivity which is making use of the Bosch Sensorhub BHA250.

    Maybe we can have a short zoom call.

    If your interested let me know a suiting time for you - preferable at mbframes(at)aon.at - and I´ll send you a zoom invitation.

     

    Best regards

    Michael

    Highlighted
    Community Moderator

    Re: BMA400 - fall detection + tap detection and inactivity + auto-low power

    Hi,

    Please see the attached three PDF files. You can modify your code accordingly.

    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