cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure an LSM6DSO to detect device motion?

Myzhar
Associate III

Hi,

I want to configure the LSM6DSO to trigger an interrupt on INT2 when the device starts and stops moving.

I used the following configuration, but I can only detect taps on the vertical axis:

	// LSM6DSO datasheet pg 74
	// (00: stationary/motion-only interrupts generated, XL and gyro do not change;
	tap_cfg2_reg.inact_en = 0;
	// Enable interrupt
	tap_cfg2_reg.interrupts_enable = 1;
 
	// LSM6DSO datasheet pg 73
	// Filter
	tap_cfg0_reg.slope_fds = 0;
	// Interrupt enable for movement
	tap_cfg0_reg.sleep_status_on_int = 0;
 
	// LSM6DSO datasheet pg 76-77
	// Threshold
	wake_up_ths_reg.wk_ths = 0x02; // TODO tune threshold here
	// Duration
	wake_up_dur_reg.wake_dur = 0x02;	// TODO tune duration here
 
	// Enable interrupt on INT2
	md2_cfg_reg.int2_sleep_change = 1;

Is it possible to have a latched signal on INT2 that stays high when the device is moving and low when it's static?

Thank you for your help,

Walter

4 REPLIES 4
TSand.1
Associate III

Hi Walter, you might consider enable the high pass filter, so that only movements different from constant acceleration (such as the start and stop moving of the device) can be detected. You can refer to the datasheet p.58. Or see also the application note:

1. Write 60h to CTRL1_XL // Turn on the accelerometer
// ODR_XL = 417 Hz, FS_XL = ±2 g
2. Write 51h to TAP_CFG0 // Enable latch mode with reset on read and digital high-pass filter
3. Write 80h to TAP_CFG2 // Enable interrupt function
4. Write 00h to WAKE_UP_DUR // No duration and selection of wake-up threshold weight (1 LSB = FS_XL / 26)
5. Write 02h to WAKE_UP_THS // Set wake-up threshold

https://www.st.com/resource/en/application_note/dm00517282-lsm6dso-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf

/tim

Hi, thank you for the reply.

I already tried that configuration, but I'm not getting the behavior that I'm searching for.

I explain better:

I want to enable the motion detection feature in order to get on INT2 the status of the motion of the sensors: 1 if moving, 0 if static (or 1 if "sleeping", 0 if moving).

What I get instead are two impulses on INT2 when I tap the sensor... nothing when I move it.

You might also thing to use the Finite state machine to detect this movement.

https://www.st.com/resource/en/application_note/dm00537590-lsm6dso-finite-state-machine-stmicroelectronics.pdf

It seems very complicated. The motion detection is a ready feature, I can't see why I should replicate it with the state machine.