02-21-2023 11:51 AM
02-21-2023 06:52 PM
Hi David,
Thanks for your inquiry.
After BMM150 is powered on, it will stay in Suspend mode doing nothing. In your initialization function you can write value of 0x01 to register 0x4B to bring BMM150 to Sleep mode. Then you can configure register 0x51 and 0x52 to make nXY = 3 and nZ = 3. In your 100Hz timer interrupt routine you can write value of 0x02 to register 0x4C to trigger Forced mode. According to the formula on page 13 of BMM150 datasheet, BMM150 will take about 2.9ms to finish the measurement and then BMM150 will go to Sleep mode automatically waiting for the next trigger by writing value of 0x02 to register 0x4C again. Then you should be able to get BMM150 data at 100Hz sampling rate in Forced mode.
Here is the pseudo code:
BMM150_init()
{ Write value of 0x01 to register 0x4B; // bring BMM150 to Suspend mode
Write value of 0x01 to register 0x51; // set nXY = 3
Write value of 0x02 to register 0x52; // set nZ = 3
}
Timer_interrupt_10ms()
{ Write value of 0x02 to register 0x4C; // trigger Forced mode
Delay(5ms); // wait for BMM150 to finish the measurements
Get BMM150 x/y/z compensated values in the unit of uT; // call API function at https://github.com/boschsensortec/BMM150-Sensor-API
Print out the values; // on PC terminal through serial port
}
Thanks.
03-06-2023 11:55 AM
Hi, thanks for your help!
So I've been trying to modify the driver in this opensource flight controller firmware (PX4, linked below) by implementing your advice, however I've not managed to get it to work yet.
https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/magnetometer/bosch/bmm150
I've tried setting Forced mode with a 5ms delay on every read cycle, set the XY and Z repetitions accordingly in the configuration etc but still no luck, it seems to stay ~17Hz.
I know it's asking a bit much, but would you be able to take a look at the driver and linked above and see if you can spot any obvious parts that would conflict with Forced mode? It really would help massively. (The link above is without any of my modifications)
Kind Regards,
David
03-07-2023 08:33 PM
Hi,
Sorry that we cannot check third party code for our sensors because we have our own API code available on the Github.
Now you can try to use BMM150 normal mode to see if you can get correct data by following the example at https://github.com/boschsensortec/BMM150-Sensor-API/blob/master/examples/generic/mag_drdy_interrupt/.... If it works, then you can follow my above pseudo code for forced mode so that you can have much faster sampling rate from BMM150.
Thanks.