Bosch Sensortec Community

    BMM150 Z value not correct

    Highlighted
    Established Member

    Re: BMM150 Z value not correct

    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.

    Highlighted
    Established Member

    Re: BMM150 Z value not correct

    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;
    }
    Highlighted
    Community Moderator
    Community Moderator

    Re: BMM150 Z value not correct


    @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

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist