Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Calibration Process Possibility & Reset Orientation for BHI160B IMU

    Calibration Process Possibility & Reset Orientation for BHI160B IMU

    vamshi
    Established Member

    Hi,

    I'm working on BHI160B IMU. Need to get clarity on some of the below

    1) I'm trying to do calibration for BHI160B IMU. For that, I'm using "calib_profile_example" provided by Bosch with STM32-L053R8.
    As per instructions I need to get "calib_profile[i].accuracy = 0b11". But it is getting only 0b01 though done calibrate actions for a while. Why?

    	    do_calibrate:
    
    	        /* first time run rotation vector, do calibrate actions for a while */
    	        //DEBUG("Presss button1 and do calibrate with BSX running...\n");
    	        while(HAL_GPIO_ReadPin(BHI160_BINT_GPIO_Port, BHI160_BUT_INT));
    
    	        //ioport_get_pin_level(BHY_INT);
    	        /* enables the virtual sensor */
    	        if(bhy_enable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
    	        {
    	            //DEBUG("Fail to enable sensor id=%d\n", VS_TYPE_ROTATION_VECTOR);
    	        }
    
    	        while(count++ < 1500)//1500
    	        {
    	            /* wait until the interrupt fires */
    	            /* unless we already know there are bytes remaining in the fifo */
    	            while (!HAL_GPIO_ReadPin(BHI160_INT_GPIO_Port, BHI160_INT_Pin) && !bytes_remaining)
    	            {
    	            }
    
    	            bhy_read_fifo(fifo + bytes_left_in_fifo, FIFO_SIZE - bytes_left_in_fifo, &bytes_read, &bytes_remaining);
    	            bytes_read           += bytes_left_in_fifo;
    	            fifoptr              = fifo;
    	            packet_type          = BHY_DATA_TYPE_PADDING;
    
    	            do
    	            {
    	                /* this function will call callbacks that are registered */
    	                result = bhy_parse_next_fifo_packet(&fifoptr, &bytes_read, &fifo_packet, &packet_type);
    
    	                /* prints all the debug packets */
    	                if (packet_type == BHY_DATA_TYPE_DEBUG)
    	                {
    	                    bhy_print_debug_packet(&fifo_packet.data_debug, bhy_printf);
    	                }
    
    	                /* the logic here is that if doing a partial parsing of the fifo, then we should not parse  */
    	                /* the last 18 bytes (max length of a packet) so that we don't try to parse an incomplete   */
    	                /* packet */
    	            } while ((result == BHY_SUCCESS) && (bytes_read > (bytes_remaining ? MAX_PACKET_LENGTH : 0)));
    
    	            bytes_left_in_fifo = 0;
    
    	            if (bytes_remaining)
    	            {
    	                /* shifts the remaining bytes to the beginning of the buffer */
    	                while (bytes_left_in_fifo < bytes_read)
    	                {
    	                    fifo[bytes_left_in_fifo++] = *(fifoptr++);
    	                }
    	            }
    	        }
    	        count = 0;
    
    	        /* disable the rotation vector sensor */
    	        if(bhy_disable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_WAKEUP))
    	        {
    	            //DEBUG("Fail to disable sensor\n");
    	        }
    
    	        /* get the calibrate profile(acc mag gyro) from bhy and save to the host side. */
    	        for(i = 0; i < 3; i++)
    	        {
    	            if(!bhy_read_parameter_page(BHY_PAGE_2, BHY_PARAM_OFFSET_ACC_GET+i, (uint8_t *) (&calib_profile[i]), sizeof(ts_calibprofile)))
    	            {
    //	                DEBUG("calibrate profile %d loaded. 0x%d, x=0x%x, y=0x%x, z=0x%x,r=0x%d\n",
    //	                    i,
    //	                    calib_profile[i].accuracy,
    //	                    calib_profile[i].calibParam.x_offset,
    //	                    calib_profile[i].calibParam.y_offset,
    //	                    calib_profile[i].calibParam.z_offset,
    //	                    calib_profile[i].calibParam.radius);
    	            }
    	            else
    	            {
    	                //DEBUG("calibrate read failed on %d, re-do calibrate..\n", i);
    	                goto do_calibrate;
    	            }
    
    	            /* set the valid profile(accuracy=3) to bhy */
    	            if(calib_profile[i].accuracy != 3)//changed 3 to 1
    	            {
    	                //DEBUG("calibrate accuracy failed on %d, re-do calibrate..\n", i);
    	            		goto do_calibrate;
    	            }
    	            else
    	            {
    	            	;
    	            }
    	        }
    	        //DEBUG("profile save to host side success\n");
    
    
    	        //DEBUG("enable the rotation vector sensor again with set calibrate profile(acc mag gyro) in advance\n");
    	        for(i = 0; i < 3; i++)
    	        {
    	            if(calib_profile[i].accuracy != 3 || bhy_write_parameter_page(BHY_PAGE_2, BHY_PARAM_OFFSET_ACC_SET+i, (uint8_t *) (&calib_profile[i].calibParam), sizeof(ts_calibparam)))
    	            {
    	                //DEBUG("calibrate set failed on %d ...\n", i);
    	            }
    	        }
    
    	        if(bhy_enable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_WAKEUP, ROTATION_VECTOR_SAMPLE_RATE, 0, VS_FLUSH_NONE, 0, 0))
    	        {
    	            //DEBUG("Fail to enable sensor\n");
    	        }


    2) Is there any approach for Orientation Reset in the provided library? We need to Reset the Orientation of the BHI160B IMU. No matter the position of IMU.
    Any Suggestions/guidance to Reset Orientation & Calibration would be very thankful.

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hi vamshi,

    1.You need to follow the calibration process of accelerometer and gyroscope.
    For accelerometer calibration:
    It's the static calibration method. The calibration method is like:
    (1).Enable the virtual sensor: Accelerometer Calibrated and keep reading our the accuracy. The accuracy is 0 at the beginning.
    (2).Put the device on a flat table with the +z axis pointing up. (You can also point other directions up firstly. the key point is to calibrate every direction.)
    (3).After some seconds for step 1, you can then put the +x axis pointing up.
    (4)Repeat the above step 2 and step 3 for other 4 directions: -x, -z, +y, -y.
    After a good six-sided calibration described above, the accuracy of the virtual sensor, Accelerometer Calibrated would becomes 3. Otherwise, you have to do the six-sided calibration again, because, maybe you did not put the device on a flat place or the calibration time for each side is too short.

    For gyroscope calibration:
    To calibrate gyroscope signal, keep the device stable for approx. 9-10 seconds. Gyroscope
    calibration is complete when calibration accuracy becomes 3.
    As the offset is observed when the device is at rest,

    Accuracy is also provided with values 0, 1, 2, and 3 (0 = No calibration; 1 = Low accuracy, calibration process initiated; 2 Medium accuracy for the estimated offsets; 3 Calibration process complete, highest accuracy for the estimated offsets).

    2.Do you mean remap sensor axis to your target device coordinate system? If yes, you could refer axis remap example code on github: https://github.com/BoschSensortec/BHy1_driver_and_MCU_solution/blob/master/examples/accelerometer_re...

    vamshi
    Established Member

    Hi @BSTRobin,

    1) I tried the procedure you suggested. I got accuracy = 3. Now it is working as expected but not every time. I should look at calibration time.

    2) No, not axes remapping. I think axes remapping & Orientation reset different! Because of the gimble lock, I need to reset Orientation for every sensor Orientation change.  Is that possible?

    3) Also, a small requirement is about to change scale factors for BHI160B IMU. But I can't find perfect procedure or proper guidance in particular Datasheet. Could you please guide me to change the default scale factors to our own (Acc, Gyr, Mag) ranges?

    Any help would be very thankful 

    vamshi
    Established Member

    Also given in the datasheet as attached image for selecting Accelerometer Range via digital interface. What it does mean?

     

    Thank you,

    BSTRobin
    Community Moderator
    Community Moderator

    Hi vamshi,

    Yes, it requires axis mapping. Could we know the placement of your sensor and the target coordinates of your device

    The measurement range FS is also called the measuring range, and the unit is g(earth gravity), which refers to the rated value range of the maximum acceleration in the positive and negative directions that can be measured by the accelerometer.

    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