cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DH Activity/Inactivity detection

neil young
Associate II
Posted on May 17, 2017 at 21:36

This document

http://www.st.com/content/ccc/resource/technical/document/application_note/77/ed/e7/e1/28/5a/45/d6/CD00290365.pdf/files/CD00290365.pdf/jcr:content/translations/en.CD00290365.pdf

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

28 REPLIES 28
Legacy member
Not applicable
Posted on May 19, 2017 at 10:36

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?

Posted on May 19, 2017 at 11:04

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

Legacy member
Not applicable
Posted on May 19, 2017 at 12:45

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.

Miroslav BATEK
ST Employee
Posted on May 19, 2017 at 14:48

The activity/inactivity detection is functional.

I think the problem is in your configuration, you set the threshold to 

250 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.

0690X000006073BQAQ.png0690X00000606lOQAQ.png

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.

Posted on May 19, 2017 at 12:49

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. 

https://www.ecnmag.com/article/2013/04/one-accelerometer-interrupt-pin-both-wakeup-and-non-motion-detection

 
Posted on May 19, 2017 at 16:21

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

Posted on May 19, 2017 at 16:34

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 = 0x3F

INT2_CFG = 0x34

INT2_SRC = 0x35

CTRL_REG1 = 0x20

CTRL_REG2 = 0x21

CTRL_REG6 = 0x25

write_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);

Posted on May 19, 2017 at 17:12

That being said: It doesn't work for me

neil young
Associate II
Posted on May 20, 2017 at 18:15

Batek.Miroslav

‌ Would you mind to double check my code? Are you able to read the interrupt state from INT2_SRC?