cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12 Direction Recognition Interrupt

KYeo.1
Associate II

In the datasheet, for the INT1_CFG register, it says:

AOI-6D = ‘11’ is direction recognition. An interrupt is generated when the orientation is

inside a known zone. The interrupt signal remains while the orientation is inside the zone.

I want to be able to generate an interrupt on INT1 pin when the sensor is on a flat surface for more than 3 seconds. The data sheet has little information on how to set this up. Other than setting the AOI and 6D bit to 11 in the INT1_CFG register, what other bits and register do I need to set to detect the flat position?

Can someone advise?

5 REPLIES 5
Eleon BORLINI
ST Employee

Hi @KYeo.1​ , the AN5005 (at p.28) is a little more detailed than the datasheet. Supposing you want to detect the e) or f) position of Figure 14, you have to set the INT1_SRC register according to the following table. If you then want to make the interrupt last about 3 seconds, you can set the INT1_DURATION (33h) register to N/ODR time, to get the appropriate timing (the value depends on the chosen ODR)

0693W000001pgwDQAQ.png

Regards

Hi Eleon,

Thank you for the reply. I want to detect position E in Figure 14. I don't understand when you say I have to set the INT1_SRC register because this is a read only register. Do you mean setting the INT_CFG instead?

I want the interrupt to be generated after the sensor is stable for 3 seconds the (e) position. I tried to the following settings:

INT1_CFG: 0b11100000

INT1_THS: 0b00001000

INT1_DUR: 0b01001011 // I am using ODR 25Hz , so 75/25 = 3 seconds

When the sensor is flat for 3 seconds, no interrupt is generated.

I lower the INT1_DUR to a very small value eg 0b00000010 and still there is no interrupt generated.

But what I noticed is with this same settings, when the sensor is in the (b) position, and when I try to tilt it forward and backwards by a few degrees, an interrupt will be generated.

What should be the correct setting?

Yes, I was referring to INT_CFG register, sorry... so you want to generate an interrupt after the device is in flat position at least from 3 seconds, and not for a 3 second interval just after the device is in flat position... it si not so simple, I'm afraid... you could maybe latch the interrupt for 3 seconds (LIR_INT1 bit of CTRL_REG5 (24h), and setting the INT1_DURATION (33h) as before), and enable INT_POLARITY of CTRL_REG6 (25h) to have a transition from low to high when the event occurs... this procedure could however be affected by false positive events (for example changing the device position during the 3 seconds), but you should check if this is the case... Regards

Hi Eleon,

I found another Design Note (DT0097 - Setting up 6D orientation detection with ST’s MEMS accelerometers) that describes the setup of the LIS2DH12 for 6D detection.

In page 3 of the documentation, it say:

Duration (LIS2DH12 only) allows setting how long the device needs to stay in the orientation detection area before the position is assumed to be valid.

So I think what you explained is not correct.

I followed the example pseudo code in this document and got it to work partially. By writing a value of 0x32 into the INT1_DUR register, I can make the interrupt trigger only after the sensor is in the flat for 3 seconds.

The settings for the INT1_CFG register is also confusing. In the datasheet, it states that if AIO = 1 and 6D =1, this will set the interrupt mode to 6D position recognition. Meaning that the interrupt will remain HIGH as long as it is in a known zone. For me, this is not working. It only works if I set AIO = 0 and 6D = 1. Also, in AN5005, I follow table 19 and set ZH = 1 and the rest to 0 and this is not detecting the flat orientation. Instead when I set XL = 1 and the rest to 0, then I am able to detect the flat orientation.

Hi @KYeo.1​ , you are right, as per ST documentation the D[6:0] bits of the INT1_DURATION (33h) sets the minimum duration of the Interrupt 2 event to be recognized. Duration steps and maximum values depend on the ODR chosen. Duration time is measured in N/ODR, where N is the content of the duration register. As regards the AOI and 6D configuration, setting AOI = 10 and 6D = 0, you will detect the 6-direction movement recognition instead of the 6-direction position recognition... so the interrupts should generate after 3 seconds from the position change, ad I described above... but is your device in flat configuration (i.e. mounted and placed so that the X-Y plane is perpendicular to the floor)? Regards