BMM150 only reads once in forced mode

Hi,

The problem I have now with the BMM150 is that when I set it to forced mode it only reads once, then stops reading the data. I do the configuration the same way that I can see in the GitHub example.

settings.pwr_mode = BMM150_FORCED_MODE;
rslt = bmm150_set_op_mode(&settings, dev);

settings.preset_mode = BMM150_PRESETMODE_REGULAR;
rslt = bmm150_set_presetmode(&settings, dev);

I realized in the datasheet that every time the forced mode is done, the sensor goes to sleep, so I don't fully understand how this sensor works.  The sensor works in conjunction with another Bosch sensor, the BMI088, this other sensor is reading at 200 Hz. So I've tried to do the following.

settings.pwr_mode = BMM150_POWERMODE_FORCED;
rslt = bmm150_set_op_mode(&settings, &bmm150dev);
rslt = bmm150_read_mag_data(&mag_data, &bmm150dev);

Every time there is an interrupt for the BMI088 data ready, I reconfigure the forced mode of the BMM150 sensor then read the data. This way it always reads the data on every interrupt, but I think I'm not working properly with forced mode.

Is there an example of how to work with forced mode? Also, Is there a way to read in forced mode without having to set the mode every time I'm going to read?

Best reply by FAE_CA1

Hi,

Thanks for your inquiry.

After BMM150 is powered on, BMM150 will be in suspend mode. At this moment the only register you can read from and write to is register 0x4B. After you write value of 0x01 to register 0x4B, then BMM150 goes to sleep mode. At this moment you can read from and write to all registers such as the chip_ID register 0x40.

From sleep mode you can configure BMM150 to work in normal mode (continuously update data registers up to 30Hz) or forced mode (also called single-shot or on-demand). This means that after you do,

        settings.pwr_mode = BMM150_POWERMODE_FORCED;
        rslt = bmm150_set_op_mode(&settings, &bmm150dev);

BMM150 will start taking measurement. After the measurement is done and data registers are updated, BMM150 will go to sleep mode automatically waiting for the above command for next measurement. Therefore,  you need to repeat the above command every time to trigger the forced mode. If you use regular preset, then the max update rate is 100Hz in forced mode. If you choose low-power preset, then the max update rate can achieve 300Hz. The measurement time is defined in the formula on page 13 of BMM150 datasheet.

Now you are using 200Hz BMI088 gyro data ready signal to get BMM150 data with code "rslt = bmm150_read_mag_data(&mag_data, &bmm150dev);". Usually magnetometer data doesn't need to be update at that fast at 200Hz for example. For eCompass or 9DoF sensor fusion, BMM150 update rate at 25Hz should be OK. That means that you can set BMM150 to be in normal mode at 25Hz ODR. So in the BMI088 gyro 200Hz interrupt routine, you can simply read BMM150 data and you don't need to use the above command for forced mode. However, you will get 8 times the same data from BMM150 because 25Hz * 8 = 200Hz.

View original
2 replies
Resolved