cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12 Movement Interrupt configuration

curtiscode
Associate II
Posted on October 03, 2016 at 18:31

Good morning, I'm having a heck of a time trying to get my configuration settings correct on my LIS2DH12 Accelerometer.

I would like it to fire the interrupt when an abrupt movement occurs on any or all axes.

I have some settings (below) that I'm trying, but it seems too sensitive and sometimes fires the interrupt when it's just sitting there not moving at all.  Seems like there are too many interrelated settings on this, but that's the nature of the beast.  Has anybody got some settings that work well to detect movement on any/all axes ?  The way I understand it is that Threshold is the amount of movement and Duration is the time frame in which that movement occurs.  So a short time frame and a large threshold should indicate an abrupt movement?

Any assistance on this would be GREATLY appreciated

Anyway, here are the settings I'm currently using:

&sharpdefine      ACCL_CTRL_REG1_DEFAULT     0x37 

&sharpdefine      ACCL_CTRL_REG2_DEFAULT     0x01

&sharpdefine      ACCL_CTRL_REG3_DEFAULT     0x06

&sharpdefine      ACCL_CTRL_REG4_DEFAULT     0x98

&sharpdefine      ACCL_CTRL_REG5_DEFAULT     0x41

&sharpdefine      ACCL_CTRL_REG6_DEFAULT     0x20

&sharpdefine      ACCL_INT1_CFG_DEFAULT      0x7F   

&sharpdefine      ACCL_INT1_SRC_DEFAULT      0x00   

&sharpdefine      ACCL_INT1_THS_DEFAULT      0x04

&sharpdefine      ACCL_INT1_DUR_DEFAULT      0x00 

&sharpdefine      ACCL_INT2_CFG_DEFAULT      0x7F   

&sharpdefine      ACCL_INT2_SRC_DEFAULT      0x10   

&sharpdefine      ACCL_INT2_THS_DEFAULT      0x04

&sharpdefine      ACCL_INT2_DUR_DEFAULT      0x00

#accelerometer-lis2dh12-configure
5 REPLIES 5
Miroslav BATEK
ST Employee
Posted on October 04, 2016 at 11:12

Here is an explanation of your settings:

#define      ACCL _CTRL_REG1_DEFAULT    0x37 … ODR=25Hz, All axis enabled

#define      ACCL_CTRL_REG2_DEFAULT     0x01 … High-pass filter enable for AOI function on Interrupt 1.

#define      ACCL_CTRL_REG3_DEFAULT     0x06 … FIFO watermark interrupt on INT1 pin, FIFO overrun interrupt on INT1 pin

#define      ACCL_CTRL_REG4_DEFAULT     0x98 … BDU enabled, FS=4g, High resolution

#define      ACCL_CTRL_REG5_DEFAULT     0x41 … FIFO enabled, 4D detection is enabled on INT2 pin

#define      ACCL_CTRL_REG6_DEFAULT     0x20 … Interrupt 2 function enable on INT2 pin

#define      ACCL_INT1_CFG_DEFAULT      0x7F … 6-direction movement recognition, X,Y,Z UP/DOWN enabled

#define      ACCL_INT1_SRC_DEFAULT      0x00   

#define      ACCL_INT1_THS_DEFAULT      0x04 … Threshold

#define      ACCL_INT1_DUR_DEFAULT      0x00 â€¦ Duration

I see several problems in it.

- Enable High pass filter is possible but not necessary. If enabled be aware that you compare the threshold with delta values

- Interrupts from FIFO are also linked to the INT1, so if interrupt occurs you need to check what is the interrupt source

- Why you enabled 4D detection on INT2?

- Only interrupt 2 is linked to the particular pin (not interrupt 1)

- INT1_CFG, INT2_CFG is wrong, it doesn’t make sense (please check datasheet for correct settings according to your needs)

The correct interrupt settings can be following:

#define      ACCL_INT1_CFG_DEFAULT     0x0A …X OR Y Higher than threshold or  0x2A … X OR Y OR Z higher than threshold (high-pass filter must be enabled or threshold set higher than 1g)

#define      ACCL_INT1_SRC_DEFAULT      0x00   

#define      ACCL_INT1_THS_DEFAULT      0x25 … Threshold

#define      ACCL_INT1_DUR_DEFAULT     0x00 â€¦ Duration

You can fine tune the threshold and duration to adjust the sensitivity.

Best regards

Miroslav

curtiscode
Associate II
Posted on November 03, 2016 at 07:58

I’m using the following settings now and am not getting any interrupts.  What is wrong with my settings?

#define      ACCL_CTRL_REG1_DEFAULT     0x3F   //LPM 25khz

#define      ACCL_CTRL_REG3_DEFAULT     0x40   //AOI1 INT1

#define      ACCL_INT1_CFG_DEFAULT     0x2A // X OR Y OR Z  Movement

#define      ACCL_INT1_SRC_DEFAULT     0x00 //… Source

#define      ACCL_INT1_THS_DEFAULT     0x25 //… Threshold

#define      ACCL_INT1_DUR_DEFAULT     0x00 //… Duration

Also, I cannot for the life of me figure out what the following Table says:

Table 64. INT2_THS description

THS[6:0] Interrupt 2 threshold. Default value: 000 0000

1 LSb = 16 mg @ FS = 2 g

1 LSb = 32 mg @ FS = 4 g

1 LSb = 62 mg @ FS = 8 g 1 LSb = 186 mg @ FS = 16 g

Miroslav BATEK
ST Employee
Posted on November 04, 2016 at 11:00

The table describe how to calculate threshold value for certain range.

In your case:

#define      ACCL_INT1_THS_DEFAULT     0x25 //… Threshold

If you use 2g range threshold = 0x25 * 16mg = 592mg

If you use 4g range threshold = 0x25 * 32mg = 1184mg

…

You didn’t specify the range which you use. If you use 2g than the interrupt will be always triggered by the gravity, because the threshold is only 592mg.

Best regards.

Miroslav
curtiscode
Associate II
Posted on November 05, 2016 at 11:36

It seems that I'm getting lots of partial answers.  Please pretend that I have no clue how this accelerometer works and provide me with the proper values.  Not 2 or 3 of them, but ALL OF THE VALUES I need to set on all registers of the accelerometer in order to make it fire Interrupt 1 when I move it around.  I have yet to see it fire.  I'm sure that the settings make sense to those who designed the thing, but it is baffling me at this point.  What CTRL registers need to be set, and what INT1 registers need to be set, and to what values.  I want to pick up the sensor and shake it and have the dang interrupt fire.  This is taking a rediculous amount of time to figure out.  There are no examples on the internet with settings that actually work for this sensor.  Does it even work, or is it only to read values.  Does the interrupt actually fire?  Maybe my Accelerometer is defective, or not properly soldered..  I'm at the point where I'm going to go try somebody else's accelerometer so that I will have some documentation and examples of actual working settings that can get this blasted thing to do what I need it to do.

Very simple behavior is wanted.  I want low power mode.  I want data to be read at 25hz.  I want an interrupt to fire if abrupt X, Y, or Z movement is detected.  This should take 10 minutes to figure out, but I've been working on it off and on for weeks and it still wont fire an interrupt...

Please do not refer to any other examples or settings, just pretend you are writing this from scratch.  What are the settings necessary to achieve the results above?

I'm sorry I'm coming off as impatient, but this is truly making me crazy...

timmycninja
Associate II
Posted on December 01, 2016 at 12:38

This is making me crazy as well I am having the same problem with the LSM303D