2020-11-01 07:04 AM
Hello ST community,
I am exploring the use of LIS2DH12 for an application where I need to detect positive peak of 200 mg and negative peak of -150 mg. For this, I am planning to use the two interrupts INT1 and INT2 for positive and negative peak detection. However, as per interrupt generation logic for this sensor, only the absolute value of threshold value is considered. How can I use this sensor to detect both positive and negative peaks? Can you please provide your inputs on this?
Thanks in advance,
Anusha
2020-11-02 05:17 AM
Hi Anusha @AB.4 ,
please note that the threshold crossing event recognition works in the following mode: you can define a threshold, for example 200mg, and this threshold is the same one both for the negative and for the positive sides of the full scale. You can decide if this threshold has to be crossed from low to high (XHIE. YHIE, ZHIE bits of INTx_CFG registers) or from high to low (XLIE. YLIE, ZLIE of INTx_CFG registers). An event will be generated accordingly to these cress-treshold direction events.
What you could do for your purpose is use the 6D orientation detection (that can be enabled through the AOI and 6D bits of the INTx_CFG register), as described in the application note AN5005 at p.28:
When configured for 6D function, the ZH, ZL, YH, YL, XH, and XL bits of INTx_SRC give information about the value of the acceleration generating the interrupt when it is greater than the threshold, and about its sign. In more detail:
• ZH (YH, XH) is 1 when the sensed acceleration is bigger than the threshold in the positive direction
• ZL (YL, XL) is 1 when the sensed acceleration is bigger than the threshold in the negative direction.
So, in your specific case, you can set the INT1_THS (32h) at 200mg and enable the XHIE (or the YHIE or ZHIE depending on the axis along which you want to detect the peak) of the INT1_CFG (30h) register.
Similar in the INT2 case, setting 150mg in INT21_THS (36h) registerg, but same configuration bits that in the previous case.
-Eleon
2020-11-02 09:54 AM
Hi Eleon,
Thanks for this helpful suggestion.
I would like to understand the effect of enabling the filter in reference mode and providing a negative value for the reference register on the 6D orientation function. For example, if I enable 6D movement in INTx_CFG register for ZH and ZL, provide a threshold of 150 mg and z-axis values after reference filtering range from 60 mg to 300 mg, does the 6D interrupt get generated when the value crosses 150 mg and indicate the direction?
Regards,
Anusha
2020-11-03 02:08 AM
Hi Eleon,
As per your suggestion, I set the following values for INT1 registers:
Full scale +- 2g
INT1_THS - 0x06
INT1_DURATION - 0x02
INT1_CFG - 0x70
Control registers are as follows:
CTRL1_REG - 0x47 (50 Hz, 3 axis enabled)
CTRL2_REG - 0x7B ( Filter enabled for output data and interrupts)
CTRL3_REG - 0x40 (Enable IA1 on INT1 pin)
CTRL4_REG - 0x08 (Enable high resolution)
CTRL5_REG - 0x0A (Enable latch on INT1 & INT2)
CTRL6_REG - 0x20 (Enable IA2 on INT2 pin)
However, I was not to receive an interrupt for the physical motion that causes the z-axis values to have a negative peak followed by a positive peak.
I have attached the acceleration data screenshot collected for the physical motion using the same LIS2DH12 with settings enabled for FIFO. In this screenshot, the orange graph shows the z-axis data and you can notice that there is a negative peak followed by positive peak in the highlighted area.
Can you please provide your inputs on how to resolve this?
2020-11-04 03:18 AM
Hi @AB.4 ,
But are you receiving some kind of interrupt signal?
Setting the INT1_CFG - 0x70, you may not enable the OR condition on the Z axis.
Can you try with 0x30? In this way you will enable only the "OR combination of interrupt events" function:
You may also try to reduce the INT1_DURATION - 0x02 to 0x01...
-Eleon
2020-11-08 01:38 AM
Hi Eleon,
No, I wasn't getting any interrupt.
I set INT1_CFG to 0x70 because I want to enable 6D orientation detection as per your suggestion to detect positive and negative peaks as attached in the previous screenshot. I tested by setting to 0x30 and it generates the interrupt but there is no way to know if it's positive or negative peak since the absolute value of threshold is considered. Is there a way to get around this?
Regards,
Anusha
2020-11-13 07:28 AM
Hi Anusha @AB.4 ,
if you could read the data out just after the generated input, it would be great and you'll know the sign of the acceleration.
But if you are not able to do it, and if you know the initial status, you should be able to know all the subsequent signs of the interrupts.
For example, suppose of starting with the board (or the device) in rest condition on the table, with the Z axis pointing upwards. In this condition, the LIS2DH12 will measure 1g along z and 0g along x and y. Suppose the threshold sets at 300mg. If then the device experiences an acceleration along -z above -300mg, the ZL interrupt will rise (=1), and the sign of the acceleration will be of course negative. Considering the X axis, if the first bit enabled is the XH, the acceleration above threshold will be positive, while if the XL rise to 1, the (first) acceleration peak will be negative.
You can also tune the minimum duration of these interrupts by configuring the INT1_DURATION (33h) register (see datasheet p.43), in order to avoid spike effects.
-Eleon