2016-10-03 09:31 AM
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 appreciatedAnyway, 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-configure2016-10-04 02:12 AM
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 … DurationI 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
2016-11-02 11:58 PM
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
2016-11-04 03:00 AM
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. Miroslav2016-11-05 03:36 AM
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...2016-12-01 03:38 AM
This is making me crazy as well I am having the same problem with the LSM303D