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.
... View more