08-09-2022 04:35 PM - edited 08-09-2022 04:38 PM
I am using the BMI160 in the following configuration. I have High G and FLAT Interrupt on INT2. I want to send the FLAT interrupt status when HIGH-G is triggered. However, the FLAT INT value is 1 only when the module is kept idle and on a table. If I do any high-g motion on it, the FLAT interrupt becomes 0 despite keeping the device flat.
I have code snippets below which I have used.
FLAT INT
int8_t rslt;
struct bmi160_int_settg int1;
int1.int_channel = BMI160_INT_CHANNEL_2;
int1.int_type = BMI160_ACC_FLAT_INT;
int1.int_pin_settg.output_en = BMI160_ENABLE;
int1.int_pin_settg.output_mode = BMI160_DISABLE;
int1.int_pin_settg.output_type = BMI160_DISABLE;
int1.int_pin_settg.edge_ctrl = BMI160_DISABLE;
int1.int_pin_settg.input_en = BMI160_DISABLE;
int1.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;
int1.int_type_cfg.acc_flat_int.flat_en = 1;
int1.int_type_cfg.acc_flat_int.flat_theta = 40;
int1.int_type_cfg.acc_flat_int.flat_hy = 2;
int1.int_type_cfg.acc_flat_int.flat_hold_time = 0;
rslt = bmi160_set_int_config(&int1, &bmi160);
HIGH G Conf.
int2.int_channel = BMI160_INT_CHANNEL_2;
int2.int_type = BMI160_ACC_HIGH_G_INT;
int2.int_pin_settg.output_en = BMI160_ENABLE;
int2.int_pin_settg.output_mode = BMI160_DISABLE;
int2.int_pin_settg.output_type = BMI160_DISABLE;
int2.int_pin_settg.edge_ctrl = BMI160_DISABLE;
int2.int_pin_settg.input_en = BMI160_DISABLE;
int2.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;
int2.int_type_cfg.acc_high_g_int.high_g_x = 1;
int2.int_type_cfg.acc_high_g_int.high_g_y = 0;
int2.int_type_cfg.acc_high_g_int.high_g_z = 0;
int2.int_type_cfg.acc_high_g_int.high_hy = 2;
int2.int_type_cfg.acc_high_g_int.high_data_src=0;
int2.int_type_cfg.acc_high_g_int.high_dur = 2;
int2.int_type_cfg.acc_high_g_int.high_thres = 10;
Orientation Config
// Orientation
int1.int_channel = BMI160_INT_CHANNEL_2;
int1.int_type = BMI160_ACC_ORIENT_INT;
int1.int_pin_settg.output_en = BMI160_ENABLE;
int1.int_pin_settg.output_mode = BMI160_DISABLE;
int1.int_pin_settg.output_type = BMI160_DISABLE;
int1.int_pin_settg.edge_ctrl = BMI160_DISABLE;
int1.int_pin_settg.input_en = BMI160_DISABLE;
int1.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;
int1.int_type_cfg.acc_orient_int.orient_en = 1;
int1.int_type_cfg.acc_orient_int.orient_mode = 1;
int1.int_type_cfg.acc_orient_int.orient_theta = 10;
int1.int_type_cfg.acc_orient_int.orient_ud_en = 1;
int1.int_type_cfg.acc_orient_int.orient_hyst = 1;
int1.int_type_cfg.acc_orient_int.axes_ex = 0;
//int2.int_type_cfg.acc_orient_int.
int1.int_type_cfg.acc_orient_int.orient_blocking = 3;
rslt = bmi160_set_int_config(&int1, &bmi160);
Interrupt Handler
if(pin == BMI160_INT2)
{
//imu_flat = flat;
bool orient = true;
if (high) {
if (!high_g && in_hand)
{
high_g = true;
bool orient = false;
uint16_t len = 30;
raw_data_buffer[8] = 0x1A;
raw_data_buffer[10] = 0x1F; // Start Activity ID
raw_data_buffer[12] = tool_id; // Tool ID
raw_data_buffer[14] = imu_flat; // Starting Orientation
activity_counter = 1;
ble_nus_data_send(&m_nus, raw_data_buffer, &len, m_conn_handle);
}else {
activity_counter++;
}
}
if (flat)
{
orient = false;
//imu_flat = int_status.bit.flat;
imu_flat = 1;
}
if (orient){
imu_flat = 0;
}
}
Any solution?
08-10-2022 04:53 AM
Hi SanskarBiswal,
For your description "If I do any high-g motion on it, the FLAT interrupt becomes 0 despite keeping the device flat.", do you mean you move the sensor horizontally and meet the condition of high-G?
You could give detailed description about your test.
08-10-2022 06:19 AM
I hold the sensor flat, and move it in the horizontal plane. Since, it is still flat, I should get the High-G but the flat interrupt triggeres and changes to 0, (non-flat), which is obviously incorrect.
08-22-2022 06:36 AM - edited 08-22-2022 06:36 AM
Also, when the imu is held flat, the orientation interrupt gets triggered as well. This means I cannot tell for sure if the device has actually gone into the non-idle position.
09-15-2022 10:58 AM
Hi SanskarBiswal,
High-g only detects the z-axis acceleration value.
We would like to confirm with you which of the following situations you expect?
1. If flat and high-g are enabled at the same time, High-g will affect the detection of flat, right?
2. Don't turn on high g, just turn on flat. You expect flat interrupt output when IMU is flat and Z axis has acceleration, right?