cancel
Showing results for 
Search instead for 
Did you mean: 

How to calibrate tap sensing (LSM6DSM)

HSund.1
Associate

Hi, I have been able to get this sensor working, but the issue is that tap/double tap is really, really insensitive. Maybe its the plastic case of the unit, I do not know. I did the tap detection as in example:

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsm_STdC/examples/lsm6dsm_tap_double.c

Is there any good method to calibrate and find correct values? I can sample the accelerometer to a file etc via RTT, if it helps to use Excel etc.

Any help appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
TBomb.1
Senior II

Hi, did you try to change for example the threshold or the duration parameters in the tap configuration? Lowering the threshold (below 750mg) and reducing the duration you'll make the device more sensitive to tap/double tap recognition. Check also the application note:

1. Write 60h to CTRL1_XL
// Turn on the accelerometer
// ODR_XL = 416 Hz, FS_XL = ±2 g
2. Write 8Eh to TAP_CFG // Enable interrupts and tap detection on X, Y, Z-axis
3. Write 89h to TAP_THS_6D // Set tap threshold
4. Write 06h to INT_DUR2 // Set Quiet and Shock time windows
5. Write 00h to WAKE_UP_THS // Only single-tap enabled (SINGLE_DOUBLE_TAP = 0)
6. Write 40h to MD1_CFG // Single-tap interrupt driven to INT1 pin

In this example the TAP_THS field of the TAP_THS_6D register is set to 01001b, therefore the tap threshold is 562.5 mg (= 9 * FS_XL / 25).

The SHOCK field of the INT_DUR2 register is set to 10b: an interrupt is generated when the slope data exceeds the programmed threshold, and returns below it within 38.5 ms (= 2 * 8 / ODR_XL) corresponding to the Shock time window. The QUIET field of the INT_DUR2 register is set to 01b: since latched mode is disabled, the interrupt is kept high for the duration of the Quiet window, therefore 9.6 ms (= 1 * 4 / ODR_XL).

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

\Tom

View solution in original post

1 REPLY 1
TBomb.1
Senior II

Hi, did you try to change for example the threshold or the duration parameters in the tap configuration? Lowering the threshold (below 750mg) and reducing the duration you'll make the device more sensitive to tap/double tap recognition. Check also the application note:

1. Write 60h to CTRL1_XL
// Turn on the accelerometer
// ODR_XL = 416 Hz, FS_XL = ±2 g
2. Write 8Eh to TAP_CFG // Enable interrupts and tap detection on X, Y, Z-axis
3. Write 89h to TAP_THS_6D // Set tap threshold
4. Write 06h to INT_DUR2 // Set Quiet and Shock time windows
5. Write 00h to WAKE_UP_THS // Only single-tap enabled (SINGLE_DOUBLE_TAP = 0)
6. Write 40h to MD1_CFG // Single-tap interrupt driven to INT1 pin

In this example the TAP_THS field of the TAP_THS_6D register is set to 01001b, therefore the tap threshold is 562.5 mg (= 9 * FS_XL / 25).

The SHOCK field of the INT_DUR2 register is set to 10b: an interrupt is generated when the slope data exceeds the programmed threshold, and returns below it within 38.5 ms (= 2 * 8 / ODR_XL) corresponding to the Shock time window. The QUIET field of the INT_DUR2 register is set to 01b: since latched mode is disabled, the interrupt is kept high for the duration of the Quiet window, therefore 9.6 ms (= 1 * 4 / ODR_XL).

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

\Tom