10-24-2019 05:14 PM
Hi,
I'm using a BMM150 as auxiliary sensor of a BMI270.
The communication works correctly, but I get weird data for the Z axis.
Debugging the sensor API I noticed that the `compensate_z` function always returns `BMM150_OVERFLOW_OUTPUT` because `dev->trim_data.dig_z2` is always ZERO.
How is this possible?
Thank you
Walter
10-24-2019 06:34 PM
Would you be able to share any further details about your setup? For example any of the following could help: your schematic (unless you are using our official Shuttle Board(s)?), code snippets, timing information, logic trace, etc.
10-24-2019 07:14 PM
The sensor is connected to BMI270 as auxiliar I2C device.
This is my initialization code:
int8_t BMM150_DEVICE_Init() {
systemStatus.bmm150_init_count++;
int8_t rslt = BMM150_OK;
// ----> BMM150 initialization over I2C (BMI270 aux)
bmm150_dev.dev_id = BMM150_DEFAULT_I2C_ADDRESS;
bmm150_dev.intf = BMM150_I2C_INTF;
bmm150_dev.read = bmm150_read;
bmm150_dev.write = bmm150_write;
bmm150_dev.delay_ms = bmm150_delay_ms;
rslt = bmm150_init(&bmm150_dev);
if(rslt!=BMM150_OK) {
goto exit;
}
// <---- BMM150 initialization over I2C (BMI270 aux)
// ----> Configuration
bmm150_dev.settings.preset_mode = BMM150_PRESETMODE_REGULAR;
rslt = bmm150_set_presetmode(&bmm150_dev);
if(rslt!=BMM150_OK) {
goto exit;
}
bmm150_dev.settings.pwr_mode = BMM150_NORMAL_MODE;
rslt = bmm150_set_op_mode(&bmm150_dev);
// <---- Configuration
exit:
if( rslt == BMM150_OK ) {
systemStatus.bmm150_initialized = 1;
} else {
systemStatus.bmm150_initialized = 0;
}
return rslt;
}
One of the weird thing that I noticed is that after putting a neodymium magnet near the sensor it started working like if there was something "blocked".
10-25-2019 03:10 PM
Assuming BMI270's auxiliary interface configuration, bmm150_read/write functions, timings/delays and data read-out are all correct, this short code snippet seems valid. Joining this other comment, BMM150 is actually quite robust against magnetization and magnetic shocks, therefore I would also make sure that the magnetic environment around the sensor is also relatively stable and clean.
10-28-2019 09:39 PM - edited 10-28-2019 09:39 PM
I would reiterate what was said in the linked comment linked above: "What you are seeing is most likely the effect of magnetization of OTHER components around the PCBs, such as mounting screws, standoffs, batteries, metal case, etc."
Moving a neodymium magnet near the hardware will likely magnetise such components even if the BMM150 itself is immune. It can also have the effect of undoing magnetisation to some extent (i.e. magnetising in the opposite direction) which could explain your 'fix'.
Nearby magnetised components offset magnetometer measurements by a fixed amount. This effect if often referred as a hard-iron distortion and must be accounted for in calibration. It is often necessary to provide the end user with a means of performing this calibration. However, you should take care when designing your product that such distortions do not risk saturating measurements.