2017-05-17 12:36 PM
This document
provides information regarding an 'Activity/Inactivity recognition' on page 51ff. The section has been added in Jan 2017. I recently purchased a Sparkfun LIS3DH breakout and I cannot make this function work. Is there any pseudo code (what register has to be initialized how?)Regards
2017-05-19 01:36 AM
Hello,
I think the AN provides a step by step manual:
The Activity/Inactivity recognition function is enabled by writing a wake-up threshold value different from zero in register ACT_THS. The return-to-sleep time is also customizable, acting on register ACT_DUR.
The user can also route the status (activity/inactivity) of the system to the INT2 pin by setting to 1 bit I2_ACT in CTRL_REG6. With this feature INT2 is high when the system is in inactivity ( ODR at 10 Hz ) and goes low when the system is in Activity (user ODR). The INT_POLARITY bit controls the polarity of the Activity / Inactivity signal.
Let us know more details, what seems to be not working in your case.
What is your configuration of the sensor, what values do you get, how did you set the threshold and how does the sensor behave? Do you use the INT2 status feature?
2017-05-19 04:04 AM
Hi David,
thanks for the response. Yes, I know this part. And I programmed ACT_THS, ACT_DUR and enabled I2_ACT in CTRL_REG6. The issue is: I never managed to see an interrupt, neither on the output nor in a register.
There is literally no indication, that this works at all. Moreover: This part of the documentation has been added in Jan 2017. Previous releases of the datasheet and app note not even mention the I2_ACT bit in CTRL_REG6, it is simply clamped to 0 there.
I also don't know, if or if not my chip is from 'before Jan 2017', so that it might not have that functionality at all. For me it seems to be such a 'last minute' change, not mature enough to be considered to be used.
And in order to answer your question: I programmed +- 2G, no HP, ACT_THS = 250 mG, ACT_DUR = 5s, enabled I2_ACT. No indication in INT2_SRC nor on the pin
2017-05-19 05:45 AM
Thanks, hopefully someone from ST will notice your question.
You are right, it would be quite surprising to add this section to both datasheet and application note after 6 years, without making hardware changes inside the device itself. I haven't found any document describing hardware changes or errata.
2017-05-19 05:48 AM
The activity/inactivity detection is functional.
I think the problem is in your configuration, you set the threshold to250 mg which is always below the 1g caused by the gravity. If you sent it above the 1g it should start to work. Please see my configuration below, I highlighted the settings related to the functionality.
I think the functionality is available even in old components (before
Jan 2017), I tested it with older one. It was only not exposed in the datasheet.
Anyway I will double check this information.
2017-05-19 05:49 AM
Thanks again. Meanwhile I found a much smarter solution on the web, which allows me to have activity/inactivity detection at 1Hz ODR and low-power-mode (2uA) by 'abusing' free fall detection. Very smart. For anybody who is interested. Works like a charm.
2017-05-19 09:21 AM
Well, I also excluded Z (for the 1 G) and made attempts with the HP (differential approach)
Anyway: Your config, as long as it matters:
CTRL_REG0 0x50
CTRL_REG1 0x5F
CTRL_REG6 0x08
Rest does not apply, except
ACT_THS 0x50
ACT_DUR 0x20
I'm pretty sure to have tried that or something similar, maybe I used 0x2F for CTRL_REG1 and didn't activate pullups, because they are external. But will try again. I was trying to read INT2 status by polling INT2_SRC to no avail. Always 0
2017-05-19 09:34 AM
OK, tried this again with your settings. Unless I need to use a sledge hammer to accellerate there is no way to make my SparkFun breakout put anything else than 3.2 V on INT2. INT2_SRC reads to 0 all the time.
Here the little nodemcu Lua testscript
ACT_THS = 0x3E
ACT_DUR = 0x3FINT2_CFG = 0x34INT2_SRC = 0x35CTRL_REG1 = 0x20
CTRL_REG2 = 0x21
CTRL_REG6 = 0x25write_reg(CTRL_REG1, 0x5F)
write_reg(CTRL_REG6, 0x08) write_reg(ACT_THS, 0x50) write_reg(ACT_DUR, 0x20)tmr.alarm(0, 1000, tmr.ALARM_AUTO, function()
val = string.byte(read_reg(INT2_SRC)) print(string.format('INT 2: 0x%02X ', val))end);
2017-05-19 10:12 AM
That being said: It doesn't work for me
2017-05-20 09:15 AM
Batek.Miroslav
Would you mind to double check my code? Are you able to read the interrupt state from INT2_SRC?