Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMM150 threshold limit value

    jorgazam
    Established Member

    BMM150 threshold limit value

    https://github.com/BoschSensortec/BMM150-Sensor-API/blob/master/examples/generic/low_threshold/low_t... 

    The low threshold example uses a 0x0A value, which corresponds to 10 in decimal, so 10*6 = 60 uT is the low threshold limit the example have set, but it doesn't specify whether it's a positive or a negative limit, or for which axis the limit is.

    /*! low threshold limit */
    uint8_t low_threshold;

    /*! high threshold limit */
    uint8_t high_threshold;

    Also, both low and high threshold limit are uint8_t, so I would like to know if it's possible to use a negative limit in order to get a interrupt, since both the raw and compensated micro tesla values of the magnetometer are sometimes negative.

    8 REPLIES 8
    BSTRobin
    Community Moderator

    Re: BMM150 threshold limit value

    Hello jorgazam,

    The setting of each axis can be enabled or disabled by the enable bit.

    BMM150.png
    The threshold value could be positive and negative, the highest bit7 is the sign bit.

    jorgazam
    Established Member

    Re: BMM150 threshold limit value

    Thank you very much for answering. I understand that what you mean is that the MSB is the sign bit, so I've tried the following.

    const int8_t LOW_THR_INT = 0x82; // (10000010) -2*6 = -12(u T) 

    uint16_t desired_settings = BMM150_SEL_INT_PIN_EN | BMM150_SEL_INT_LATCH |
    BMM150_SEL_INT_POLARITY | BMM150_SEL_LOW_THRESHOLD_SETTING | BMM150_SEL_LOW_THRESHOLD_INT;

    settings.int_settings.int_pin_en = BMM150_INT_ENABLE;
    settings.int_settings.int_polarity = BMM150_ACTIVE_LOW_POLARITY;
    settings.int_settings.int_latch = BMM150_NON_LATCHED;
    settings.int_settings.low_threshold = LOW_THR_INT;
    settings.int_settings.low_int_en = BMM150_THRESHOLD_Y;

    rslt = bmm150_set_sensor_settings(desired_settings, &settings, dev);

    In this example I want the low threshold of the Y axis to be -12 uT, however the way you've explained doesn't seem to work. So what I've tried is to change it to the inverse value of 0x02. When the value on the Y axis is < -12 uT, there is a interrupt, so this way seems to work, although it's not as described in the datasheet. 

    const int8_t LOW_THR_INT = 0xFE; // (11111110) -2*6 = -12(u T)

    On the other hand, I've also had problems with the high threshold. I made the configuration the same way as the low threshold.

    const int8_t HIGH_THR_INT = 0x02; // (00000010) 2*6 = 12(uT)

    uint16_t desired_settings = BMM150_SEL_INT_PIN_EN | BMM150_SEL_INT_LATCH |
    BMM150_SEL_INT_POLARITY | BMM150_SEL_HIGH_THRESHOLD_SETTING | BMM150_SEL_HIGH_THRESHOLD_INT;

    settings.int_settings.int_pin_en = BMM150_INT_ENABLE;
    settings.int_settings.int_polarity = BMM150_ACTIVE_LOW_POLARITY;
    settings.int_settings.int_latch = BMM150_NON_LATCHED;
    settings.int_settings.high_threshold = HIGH_THR_INT;
    settings.int_settings.high_int_en = BMM150_THRESHOLD_Y;

    rslt = bmm150_set_sensor_settings(desired_settings, &settings, dev);

    My understanding is that I should get an interrupt every time the value on the Y axis is > 12 uT. However, the interrupt seems to be arbitrary. Regardless of whether the value on the Y axis is greater or less than 12 uT, sometimes there are interrupts and sometimes there aren't.

    bmm150_read_mag_data(&mag_data, &dev);
    compass = atan2(mag_data.y, mag_data.x) * 180 / M_PI;

    rslt = bmm150_get_interrupt_status(&dev);
    // BMM150_INT_ASSERTED_DRDY |BMM150_INT_ASSERTED_LOW_THRES | BMM150_INT_ASSERTED_HIGH_THRES
    if (dev.int_status & BMM150_INT_ASSERTED_HIGH_THRES)
    {
    counter++;
    }

    This is how I get the value of the magnetometer in the while loop, so I think it should be correct. I'm also attaching two GIFs showing the behavior of the interrupts.

    BSTRobin
    Community Moderator

    Re: BMM150 threshold limit value

    Hello jorgazam,

    Could you run the example program normally?
    https://github.com/BoschSensortec/BMM150-Sensor-API/tree/master/examples/generic

    jorgazam
    Established Member

    Re: BMM150 threshold limit value

    The low threshold seems to work correctly. The problem I see there is that to use a negative value as a threshold, it doesn't seem to work the way you explained to me in the previous answer.

    The high threshold is the one that doesn't seem to work correctly either way. Also when I want to test with a different axis than Y, it seems that I have the same problems.

    In any case, I probably won't use this sensor in the project, so thank you very much for answering.

    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