#### Bosch Sensortec Community

cancel
Showing results for
Did you mean:
SOLVED

## BMM150 threshold limit value

Established Member

## BMM150 threshold limit value

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.

Tags (3)
9 REPLIES 9
Community Moderator

## Re: BMM150 threshold limit value

Hello jorgazam,

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

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

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.

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.

Tags (3)
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

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.