02-25-2023 05:42 PM
I am working with Arduino Nano BLE33_Sense Rev. 2 MCU. This MCU has built-in sensors, BMI270, BMM150, etc. I am writing app for BMM150 to determine heading. I have extracted the trim data from the trim registers. These data are partially in agreement with the trim data shown in one of your data sheet, shown below:
BOSCH Data Data from
Arduino MCU
dig_X1 0 0
dig_Y1 0 0
dig_X2 26 25 different
dig_Y2 26 25 different
dig_xy1 29 29
dig_xy2 -3 -3
dig_z1 22752 21463 different
dig_z2 737 770 different
dig_z3 -1035 0 different
dig_z4 0 0
dig_xyz1 6753 7019 different
I am not sure what to make of the difference. Please help me if the difference is due to Arduino with built-in sensors or I am making some mistake in extracting the data. By the way, one the app supplied by Arduino for BMM150 also reproduced the same data as mine.
A second question I have is regarding preset values for REPZ repetitions (register 0x52). According to the definition input value should be 14 (15 -1) for BMM150_REPZ_REGULAR preset. Please help me, if my interpretation is flawed. What is the significance of the repetitions?
Thanks, Vinod
03-14-2023 09:47 AM
Hi Vinod,
You could refer BMM150 official sensor API and example code to get sensor data, by call bmm150_read_mag_data() to get compensated x, y, z mag data.
https://github.com/boschsensortec/BMM150-Sensor-API/tree/master/examples/generic
In BMM150 sensor API, z_rep was set according different preset mode.
/*!
* @brief This API is used to set the preset mode of the sensor.
*/
int8_t bmm150_set_presetmode(struct bmm150_settings *settings, struct bmm150_dev *dev)
{
int8_t rslt;
uint8_t preset_mode;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if (rslt == BMM150_OK)
{
preset_mode = settings->preset_mode;
switch (preset_mode)
{
case BMM150_PRESETMODE_LOWPOWER:
/* Set the data rate x,y,z repetition
* for Low Power mode
*/
settings->data_rate = BMM150_DATA_RATE_10HZ;
settings->xy_rep = BMM150_REPXY_LOWPOWER;
settings->z_rep = BMM150_REPZ_LOWPOWER;
rslt = set_odr_xyz_rep(settings, dev);
break;
case BMM150_PRESETMODE_REGULAR:
/* Set the data rate x,y,z repetition
* for Regular mode
*/
settings->data_rate = BMM150_DATA_RATE_10HZ;
settings->xy_rep = BMM150_REPXY_REGULAR;
settings->z_rep = BMM150_REPZ_REGULAR;
rslt = set_odr_xyz_rep(settings, dev);
break;
case BMM150_PRESETMODE_HIGHACCURACY:
/* Set the data rate x,y,z repetition
* for High Accuracy mode *
*/
settings->data_rate = BMM150_DATA_RATE_20HZ;
settings->xy_rep = BMM150_REPXY_HIGHACCURACY;
settings->z_rep = BMM150_REPZ_HIGHACCURACY;
rslt = set_odr_xyz_rep(settings, dev);
break;
case BMM150_PRESETMODE_ENHANCED:
/* Set the data rate x,y,z repetition
* for Enhanced Accuracy mode
*/
settings->data_rate = BMM150_DATA_RATE_10HZ;
settings->xy_rep = BMM150_REPXY_ENHANCED;
settings->z_rep = BMM150_REPZ_ENHANCED;
rslt = set_odr_xyz_rep(settings, dev);
break;
default:
rslt = BMM150_E_INVALID_CONFIG;
break;
}
}
return rslt;
}