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-30-2019 05:32 PM
We finally found the problem using X-Ray: a simply short circuit under the sensor due to a wrong way of placing the soldering paste.
Now the sensors seems to work correctly, even if the Z axis is showing a very low working range, but I expect to solve this with hard and soft iron calibration.
10-30-2019 05:36 PM
Hi o_o,
the Z2 value to zero is a possible value, but in the "compensate_z" function it is checked and generates a `BMM150_OVERFLOW_OUTPUT` error.
This is the function I'm referring to:
/*!
* @brief This internal API is used to obtain the compensated
* magnetometer Z axis data(micro-tesla) in int16_t.
*/
int16_t compensate_z(int16_t mag_data_z, uint16_t data_rhall, const struct bmm150_dev *dev)
{
int32_t retval;
int16_t process_comp_z0;
int32_t process_comp_z1;
int32_t process_comp_z2;
int32_t process_comp_z3;
int16_t process_comp_z4;
if (mag_data_z != BMM150_ZAXIS_HALL_OVERFLOW_ADCVAL) {
if ((dev->trim_data.dig_z2 != 0) && (dev->trim_data.dig_z1 != 0)
&& (data_rhall != 0) && (dev->trim_data.dig_xyz1 != 0)) {
/*Processing compensation equations*/
process_comp_z0 = ((int16_t)data_rhall) - ((int16_t) dev->trim_data.dig_xyz1);
process_comp_z1 = (((int32_t)dev->trim_data.dig_z3) * ((int32_t)(process_comp_z0))) / 4;
process_comp_z2 = (((int32_t)(mag_data_z - dev->trim_data.dig_z4)) * 32768);
process_comp_z3 = ((int32_t)dev->trim_data.dig_z1) * (((int16_t)data_rhall) * 2);
process_comp_z4 = (int16_t)((process_comp_z3 + (32768)) / 65536);
retval = ((process_comp_z2 - process_comp_z1) / (dev->trim_data.dig_z2 + process_comp_z4));
/* saturate result to +/- 2 micro-tesla */
if (retval > BMM150_POSITIVE_SATURATION_Z) {
retval = BMM150_POSITIVE_SATURATION_Z;
} else {
if (retval < BMM150_NEGATIVE_SATURATION_Z)
retval = BMM150_NEGATIVE_SATURATION_Z;
}
/* Conversion of LSB to micro-tesla*/
retval = retval / 16;
} else {
retval = BMM150_OVERFLOW_OUTPUT;
}
} else {
/* Overflow condition*/
retval = BMM150_OVERFLOW_OUTPUT;
}
return (int16_t)retval;
}
10-31-2019 09:56 AM
@Myzhar wrote:
We finally found the problem using X-Ray: a simply short circuit under the sensor due to a wrong way of placing the soldering paste.
Now the sensors seems to work correctly, even if the Z axis is showing a very low working range, but I expect to solve this with hard and soft iron calibration.
Glad you found your issue. If the part has been short-circuited, I cannot guarantee that will work with full performance, and would advise to replace it to be on the safe side.
On the topic of compensation formula, I will double-check to confirm whether zero is a possible value, and therefore a bug in the API.
o_o