cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1 motion detection functions

Zaren
Associate

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!

1 ACCEPTED SOLUTION

Accepted Solutions
DSull.3
Associate III

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.

https://github.com/sparkfun/LSM9DS1_Breakout/blob/master/Libraries/Arduino/examples/LSM9DS1_Interrupts/LSM9DS1_Interrupts.ino

  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

View solution in original post

1 REPLY 1
DSull.3
Associate III

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.

https://github.com/sparkfun/LSM9DS1_Breakout/blob/master/Libraries/Arduino/examples/LSM9DS1_Interrupts/LSM9DS1_Interrupts.ino

  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