03-26-2019 11:04 AM
Hi,
We are having problems with significant motion interrupt triggering. It behaves really flaky.
On some program run, interrupt behaves as it should, and sometimes, it cannot be triggered, no matter what motion you do . My opinion is that BMI isn't configured properly every time, altough bmi160_set_int_config function returns that is executed properly.
Flow in program is:
_bmi160_sensor.accel_cfg.odr = BMI160_ACCEL_ODR_1600HZ; _bmi160_sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G; _bmi160_sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; _bmi160_sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; _bmi160_sensor.gyro_cfg.odr = BMI160_GYRO_ODR_3200HZ; _bmi160_sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS; _bmi160_sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE; _bmi160_sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
interrupt_config.int_channel = BMI160_INT_CHANNEL_1; interrupt_config.int_type = BMI160_ACC_SIG_MOTION_INT; interrupt_config.int_pin_settg.output_en = BMI160_ENABLE; interrupt_config.int_pin_settg.output_mode = BMI160_DISABLE; interrupt_config.int_pin_settg.output_type = BMI160_DISABLE; interrupt_config.int_pin_settg.edge_ctrl = BMI160_ENABLE; interrupt_config.int_pin_settg.input_en = BMI160_DISABLE; interrupt_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; // Proof time of motion detection. 0=0.24s, 1=0.48s, 2=0.96s, 3=1.92s interrupt_config.int_type_cfg.acc_sig_motion_int.sig_mot_proof = sig_mot_proof; // Time to skip between two motion detect check. 0=1.28s, 1=2.56s, 2=5.12s, // 3=10.24s interrupt_config.int_type_cfg.acc_sig_motion_int.sig_mot_skip = sig_mot_skip; /* Threshold value. (2-g range) -> Threshold * 3.91 mg (4-g range) -> Threshold * 7.81 mg (8-g range) -> Threshold * 15.63 mg (16-g range) -> Threshold * 31.25 mg */ interrupt_config.int_type_cfg.acc_sig_motion_int.sig_mot_thres = sig_mot_thres; int8_t result = bmi160_set_int_config(&interrupt_config, &_bmi160_sensor);
Data from accelerometer works fine no matter what, but interrupt isn't.
Do you have any clue what can be problem here? Do I need to change some values in configuration? Do I need to change an order of execution, so set interrupt configuration before sensor configuration?
Looking forward for your answer.
Best regards,
Josip
Solved! Go to Solution.
04-05-2019 01:53 PM
Hi,
thanks for your response! It works now!
Marta
04-11-2019 12:36 PM
1. Yes. I am using version before commit(a23022cc3208fe367d886c65df2f025e80203037).
2. Configuration sequence is:
3. I would.
4. I can do that, but every time I made a call of function bmi160_set_int_config with given parameters, BMI_OK result was returned every time.
5. I read that in datasheet and I am aware of that fact. But, sometimes no matter what you do with device, interrupt is never triggered.
Looking forward to your answer.
04-26-2019 09:48 AM
Any update on this topic?
Regards,
Josip
08-07-2019 09:41 PM
Hi! I'm having problems with the first part:
I'm using a gy-bmi160 like this https://es.banggood.com/GY-BMI160-Module-6DOF-6-Axis-Angular-Velocity-Gyroscope-Gravity-Acceleration...
I've tried to turn on a LED with the INT1 interrupt but I'm getting the 'Failure' message indicating the init went wrong. This is programmed into a ESP32 using SPI interface.
Here's my code:
#include "bmi160.h
void setup() {
int8_t rslt;
Serial.begin(19200);
pinMode(26,INPUT);
pinMode(25,OUTPUT);
struct bmi160_int_settg int_config;
struct bmi160_dev sensor;
//Init Modo SPI
sensor.id = 0;
sensor.interface = BMI160_SPI_INTF;
rslt = bmi160_init(&sensor);
if(rslt==BMI160_OK){
Serial.println("Success");
}else{
Serial.println("Failure");
}
delay(1000);
//Rango acc 2g, low power, 50HZ
sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;
sensor.accel_cfg.odr = BMI160_ACCEL_ODR_50HZ;
sensor.accel_cfg.power = BMI160_ACCEL_PMU_LOW_POWER;
delay(5);
/* Interrupcion INT1 */
int_config.int_channel = BMI160_INT_CHANNEL_1;
int_config.int_type = BMI160_ACC_ANY_MOTION_INT;// Choosing Any motion interrupt
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active low output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
/* Select the Any-motion interrupt parameters */
int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE;// 1- Enable the any-motion, 0- disable any-motion
int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE;// Enabling x-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE;// Enabling y-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE;// Enabling z-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 0;// any-motion duration
int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 2;// (2-g range) -> (slope_thr) * 3.91 mg, (4-g range) -> (slope_thr) * 7.81 mg, (8-g range) ->(slope_thr) * 15.63 mg, (16-g range) -> (slope_thr) * 31.25 mg
/* Set the Any-motion interrupt */
bmi160_set_int_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
}
void loop() {
Serial.println(digitalRead(26));
if(digitalRead(26)==1){
digitalWrite(25,HIGH);
Serial.println("Activated");
delay(500);
digitalWrite(25,LOW);
}
}