Skip to main content
Visitor II
May 17, 2017
Question

LIS3DH Activity/Inactivity detection

  • May 17, 2017
  • 5 replies
  • 5682 views
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

    This topic has been closed for replies.

    5 replies

    May 19, 2017
    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?

    Visitor II
    May 19, 2017
    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

    May 19, 2017
    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.

    ST Employee
    May 19, 2017
    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.

    Visitor II
    May 19, 2017
    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

    Visitor II
    May 19, 2017
    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);

    Visitor II
    May 20, 2017
    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?

    ST Employee
    May 22, 2017
    Posted on May 22, 2017 at 14:11

    The status of the activity/inactivity is not available in the 

    INT2_SRC register or any other register.

    In my trial, I was monitoring the INT2 pin.

    Visitor II
    May 22, 2017
    Posted on May 22, 2017 at 14:13

    OK, did the same. No movement. Will try again. What do you think about my code? Looks OK to you?

    ST Employee
    May 25, 2017
    Posted on May 25, 2017 at 12:50

    I think it deepens on your application requirements. The latency can be important for some application.

    The advantage of the activity/inactivity feature is that it is managed automatically by the sensor.

    For current consumption please check the following table from application note.

    0690X000006076tQAA.png
    Visitor II
    May 25, 2017
    Posted on May 25, 2017 at 15:36

    OK, what I wanted to say is: The free fall abuse allows me to stay at 1Hz low power all the time, which results in 2 uA overall power consumption, regardless of activity or inactivity.

    The Actvity/Inactivity detection as outlined above _automatically_ stays at 10 Hz low power, which means 3 uA in inactivity phases. 

    ST Employee
    January 24, 2018
    Posted on January 24, 2018 at 10:45

    I'm not sure that I understand you request, but you can change the duration without impact on the duration counter. So I think you request is not possible.