2021-08-19 12:41 AM
Hello! I tried to work with motion detection function and here is my setup of interrupt pin
/* Interrupt pin setup */
lsm9ds1_pin_notification_set(MAG_I2C_ADD, IMU_I2C_ADD, LSM9DS1_INT_PULSED);
lsm9ds1_pin_polarity_set(MAG_I2C_ADD, IMU_I2C_ADD, LSM9DS1_ACTIVE_HIGH);
lsm9ds1_pin_logic_set(IMU_I2C_ADD, LSM9DS1_LOGIC_AND);
lsm9ds1_pin_mode_set(MAG_I2C_ADD, LSM9DS1_PUSH_PULL);
lsm9ds1_pin_mode_set(IMU_I2C_ADD, LSM9DS1_PUSH_PULL);
lsm9ds1_pin_m_route_t int_m;
int_m.ien = 1;
lsm9ds1_pin_int_m_route_set(MAG_I2C_ADD, int_m);
lsm9ds1_pin_int1_route_t pin_cfg;
pin_cfg.int1_drdy_g = 1;
pin_cfg.int1_drdy_xl = 1;
pin_cfg.int1_ig_g= 1;
pin_cfg.int1_ig_xl= 1;
lsm9ds1_pin_int1_route_set(IMU_I2C_ADD, pin_cfg);
/* Set Output Data Rate / Power mode */
ret = lsm9ds1_imu_data_rate_set(IMU_I2C_ADD, LSM9DS1_IMU_119Hz); //LSM9DS1_IMU_119Hz
But I get completely chaotic condition of interrupt PIN even I don't touch the accelerometer.
Could you give me an example how to setup motion detection function?
Thanks!
Solved! Go to Solution.
2021-08-23 01:31 AM
Hi, if you set the data-ready DRDY interrupt, you will get one interrupt every 1/ODR, so you should have a repetitive pattern of the INT pin. You should xtry separately with imu int and then with mag int (try for example to drop the mag int and the logic AND).
If you want to configure a threshold interrupt, you have to set a threshold for example for the accelerometer (register ACT_THS (04h)), and you can follow the Arduino libraries on Github for example configuration functions.
imu.configAccelInt(XHIE_XL, false);
// 4. Configure accelerometer threshold:
// - 20: Threshold (raw value from accel)
// Multiply this value by 128 to get threshold value.
// (20 = 2600 raw accel value)
// - X_AXIS: Write to X-axis threshold
// - 10: duration (based on ODR)
// - false: wait (wait [duration] before interrupt goes low)
imu.configAccelThs(20, X_AXIS, 1, false);
// 5. Configure INT1 - assign it to gyro interrupt
// - XG_INT1: Says we're configuring INT1
// - INT1_IG_G | INT1_IG_XL: Sets interrupt source to
// both gyro interrupt and accel
// - INT_ACTIVE_LOW: Sets interrupt to active low.
// (Can otherwise be set to INT_ACTIVE_HIGH.)
// - INT_PUSH_PULL: Sets interrupt to a push-pull.
// (Can otherwise be set to INT_OPEN_DRAIN.)
\Dk
2021-08-23 01:31 AM
Hi, if you set the data-ready DRDY interrupt, you will get one interrupt every 1/ODR, so you should have a repetitive pattern of the INT pin. You should xtry separately with imu int and then with mag int (try for example to drop the mag int and the logic AND).
If you want to configure a threshold interrupt, you have to set a threshold for example for the accelerometer (register ACT_THS (04h)), and you can follow the Arduino libraries on Github for example configuration functions.
imu.configAccelInt(XHIE_XL, false);
// 4. Configure accelerometer threshold:
// - 20: Threshold (raw value from accel)
// Multiply this value by 128 to get threshold value.
// (20 = 2600 raw accel value)
// - X_AXIS: Write to X-axis threshold
// - 10: duration (based on ODR)
// - false: wait (wait [duration] before interrupt goes low)
imu.configAccelThs(20, X_AXIS, 1, false);
// 5. Configure INT1 - assign it to gyro interrupt
// - XG_INT1: Says we're configuring INT1
// - INT1_IG_G | INT1_IG_XL: Sets interrupt source to
// both gyro interrupt and accel
// - INT_ACTIVE_LOW: Sets interrupt to active low.
// (Can otherwise be set to INT_ACTIVE_HIGH.)
// - INT_PUSH_PULL: Sets interrupt to a push-pull.
// (Can otherwise be set to INT_OPEN_DRAIN.)
\Dk