Bosch Sensortec Community

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

    BMA400 activity detection

    Alessandro10
    New Poster

    BMA400 activity detection

    Good morning,

    i start working with BMA400 accelerometer and i would like to detect activity mode.

    I want to blink a led each time a receive an interrupt.

    Setup procedure:

    BMA_WriteRegister(0x7E, 0xB6);  --> software reset (maybe optional)
    BMA_WriteRegister(0x19, 0x02);  --> normal mode
    BMA_WriteRegister(0x1A, 0x38); --> range 2G, ODR 100 HZ, osr highest accuracy
    BMA_WriteRegister(0x21, 0x04); --> enable generic interrupt 1 to int1 pin
    BMA_WriteRegister(0x20, 0x00); --> non latched mode
    BMA_WriteRegister(0x24, 0x02); --> int1 pin interrupt High active
    BMA_WriteRegister(0x3F, 0xFB); --> enable X,Y,Z axis, data source = acc_filt2, update every time, hysteresis = 96 mg
    BMA_WriteRegister(0x40, 0x02); --> enable activiy detection with OR logic
    BMA_WriteRegister(0x41, 0x01); --> set threshold 
    BMA_WriteRegister(0x42, 0x00); --> set duration time
    BMA_WriteRegister(0x43, 0x01); --> set duration time 
    BMA_WriteRegister(0x1F, 0x04); --> gen1 interrupt in normal mode

     

    The code works: if i move my accelerometer, i can blink a led but i have some questions about my configuration:

    1)  is it right that OR logic generates an interrupt if the acceleration detected by the sensor from at least one of its axis is over a threshold and for AND logic detects an interrupt if the acceleration is detected from all the axis at the same time?

    2) if i want to reduce the number of interrupt (now i receive a lot of interrupts) i have to modify threshold and duration register?

     

    best regards,

     

    Alessandro

     

     

    4 REPLIES 4
    Minhwan
    Community Moderator

    Re: BMA400 activity detection

    Hello Alessandro10

     

    You probably need to increase threshold because if the BMA400 is on the table, Z value shall be 1G. 

    So, if you said threshold value as 0 and duration is 10ms, the interrupt pin always high in case interrupt is active high. 

    Did you check the result using scope? 

    And here is the answer for your questions. 

    1)  is it right that OR logic generates an interrupt if the acceleration detected by the sensor from at least one of its axis is over a threshold and for AND logic detects an interrupt if the acceleration is detected from all the axis at the same time?

    - Yes,

    2) if i want to reduce the number of interrupt (now i receive a lot of interrupts) i have to modify threshold and duration register?

    - Simply, increase threshold and duration as I guide. 

    BMA_WriteRegister(0x41, 0x96); --> set threshold //1200mg
    BMA_WriteRegister(0x42, 0x00); --> set duration time
    BMA_WriteRegister(0x43, 0x14); --> set duration time // 200ms

    Thanks, 

     

    Alessandro10
    New Poster

    Re: BMA400 activity detection

    Hello Minhwan,

    thank you for your suggestion but unfortunately, when i setup your configuration i cannot receive interrupt. 

    I'm using a breadboard with BMA400 moving it on a desk. Is it wrong?

    thanks,

    Alessandro

    Minhwan
    Community Moderator

    Re: BMA400 activity detection

    Hello  Alessandro10, 

     

    No, it should work in bread board as well. 

    Here is my two suggestions. ( I highly recommend first one)

    1) Please migrate BMA400 API and use our example - activity change. Then, you can check where you have some issue. 

    https://github.com/BoschSensortec/BMA400-API/tree/master/examples/activity_change

    2) Capture i2c or spi interface, then read all register you write. Then you can figure it out the data is really written in target registers. 

     

    Thanks, 

     

    dsherman
    New Poster

    Re: BMA400 activity detection

    The BMA400 datasheet may be wrong about the logical combination in the Generic interrupts:
     
    Register 0x40, page 86, and 0x4B, page 92
    gen1/2_comb_sel:
    0x00 = logical OR    << in reality, 0x00 requires ALL enabled axes to comply (AND/all)
    0x00 = logical AND  << in reality, 0x01 requires ONE of the enabled axes to comply (OR/any)
     
    I found this while experimenting with the BMA400 shuttle board and the Development Desktop 2.0 software.  This may be causing your problem.
     
    EDIT:
    Actually, maybe not.  My experiments were with manual reference updates and one-time reference updates.  I just tried it with the "every time" reference update mode (the mode you are using).  The "every time" mode appears to have valid combinational logic --  although it's hard to tell, because the reference is always changing.   In "every time" mode, interrupts happen more often when the bit is set to 0x00, so I think that's an indication of a logical OR operation.
     
    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