以下是您的设置说明:
#define ACCL _CTRL_REG1_DEFAULT 0x37 - ODR = 25Hz,所有轴都启用
#define ACCL_CTRL_REG2_DEFAULT 0x01 - 中断1上的AOI功能的高通滤波器使能。
#define ACCL_CTRL_REG3_DEFAULT 0x06 - INT1引脚上的FIFO水印中断,INT1引脚上的FIFO溢出中断
#define ACCL_CTRL_REG4_DEFAULT 0x98 - BDU启用,FS = 4g,高分辨率
#define ACCL_CTRL_REG5_DEFAULT 0x41 - FIFO使能,INT2引脚使能4D检测
#define ACCL_CTRL_REG6_DEFAULT 0x20 - INT2引脚上的中断2功能使能
#define ACCL_INT1_CFG_DEFAULT 0x7F - 6方向移动识别,启用X,Y,Z UP / DOWN
#define ACCL_INT1_SRC_DEFAULT 0x00
#define ACCL_INT1_THS_DEFAULT 0x04 - 阈值
#define ACCL_INT1_DUR_DEFAULT 0x00 - 持续时间
我看到了几个问题。
- 可以启用高通滤波器,但不是必需的。如果启用,请注意您将阈值与增量值进行比较
- FIFO的中断也链接到INT1,因此如果发生中断,则需要检查什么是中断源
- 为什么在INT2上启用4D检测?
- 只有中断2链接到特定引脚(不是中断1)
- INT1_CFG,INT2_CFG错误,没有意义(请根据需要查看数据表中的正确设置)
正确的中断设置可以是:
#define ACCL_INT1_CFG_DEFAULT 0x0A | X或Y高于阈值或0x2A - X或Y或Z高于阈值(必须启用高通滤波器或阈值设置高于1g)
#define ACCL_INT1_SRC_DEFAULT 0x00
#define ACCL_INT1_THS_DEFAULT 0x25 - 阈值
#define ACCL_INT1_DUR_DEFAULT 0x00 - 持续时间
您可以微调阈值和持续时间以调整灵敏度。
最好的祝福
米罗斯拉夫
以上来自于谷歌翻译
以下为原文
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