10-03-2022 04:51 PM
Hi,
I've noticed a weird problem in the compensated magnetometer data. The x ,y axes showed extremely low values(up to 0.03 gauss, and the earth's magnetic field was interpreted as 0.01, as if the scale is wrong), while the z axis seems okay(raw data for x and y axes was between -50 to 50).
After searching the forum i came across the "bmm150-step-by-step-temperature-compensation-sample.pdf", and checked the sensor trimming data.
Most of the values seemed okay except dig_xyz1(between 50000 and 60000), dig_xy1(around 250), which were about 10 times bigger than the values shown in the temperature-compensation-manual file.
After looking at the BMM-Sensor-API, I've noticed that the mathematic operations in compenstaion_x and compensation_y functions with the trim parameters we received resulted in a value larger than the uint16 scale(data_rhall is about 6300).
>>process_comp_x0 = data_rhall;
>>process_comp_x1 = ((int32_t)dev->trim_data.dig_xyz1) * 16384;
>>process_comp_x2 = ((uint16_t)(process_comp_x1 / process_comp_x0)) - ((uint16_t)0x4000);
>>retval = ((int16_t)process_comp_x2);
The results are:
process_comp_x0 = 6300
process_comp_x1 = 60000*16384 = 983x10^6
process_comp_x2 = ((uint16_t)(983x10^6/ 6300)) - ((uint16_t)16384) = ((uint16_t)156038) - ((uint16_t)16384) when 65535 is the maximum value for uint...
afterwards I noticed in the driver that when it reads the dig_xyz register it excludes the MSB bit:
>> temp_msb = ((uint16_t)(trim_xy1xy2[5] & 0x7F)) << 8;
>>dev->trim_data.dig_xyz1 = (uint16_t)(temp_msb | trim_xy1xy2[4]);
While the temperature compensation document doesn't mention it. Even with the trim corrent the values are still high and when casting the result of process_comp_x2 to int16 in the following line it filps sign and becomes negative.
The Issue appeared in 3 sensor out of 10.
At this point I'm a bit confused and wanted to know if the trimming values we received are normal.
In case they are not, can I calibration the value myself or should I disregard the temperature compensation?
Best Regards,
Jason
Solved! Go to Solution.
10-06-2022 12:11 PM
Hi,
Solved!
Apparently , every time the BMX160 tries to read BMM150 registers in setup mode, a multiple ms delay is required... after adding the delay the trim register values seemed fine.
Thank you,
Jason
10-06-2022 08:21 PM
Hi,
Thanks for the update.