Skip to main content
Visitor II
February 26, 2019
Solved

Step counter with LIS2DS12

  • February 26, 2019
  • 3 replies
  • 1184 views

Hi​, I'm using LIS2DS12 and I was wondering if it was possible to use it as a pedometer? How do you suggest to set the thresholds?

Thanks​

    This topic has been closed for replies.
    Best answer by Eleon BORLINI

    hi john, please follow these instructions:

    Read current value of 21h (CTRL2_INIT) and store it

    Write reg 21h = CTRL2_INIT|10h // This will enable access the embedded functions registers: write bit#4 of reg 21h to 1,keep the other bits unchanged

    Set delta time in reg3Ah // 1 LSB = 1.6384 s

    Write reg 3Fh = CTRL2_INIT // Disable access the embedded functions registers: write bit #4 of reg3Fh to 0, keep the other bits unchanged

    Please remember to implement also a debounce functionality in order to avoid false step detection (e.g. 7 consecutive steps have to be detected before the first interrupt generation)

    3 replies

    ST Employee
    February 26, 2019

    Hi john, yes the step counter and step detector functions are embedded into the LIS2DS12 (see this link), and using the only accelerometer you can use negligible power consumption. Consider that pedometer functions work at 25 Hz, so the accelerometer ODR must be set at 25 Hz or higher values. In order to enable the pedometer functions it is necessary to set to 1 STEP_CNT_ON bit of the FUNC_CTRL(3Fh) register. Instead of generating an interrupt every time a step is recognized, it is possible to generate it if at least one step is detected within a certain time period. This time period is defined by setting a value higher than 00h in the STEP_COUNT_DELTA(3Ah) register. Please let me know if you need further details

    f87Author
    Visitor II
    February 26, 2019

    Thank you eleon for the quick answer. Would be possible for you to share a draft code? Many thanks​

    ST Employee
    February 26, 2019

    hi john, please follow these instructions:

    Read current value of 21h (CTRL2_INIT) and store it

    Write reg 21h = CTRL2_INIT|10h // This will enable access the embedded functions registers: write bit#4 of reg 21h to 1,keep the other bits unchanged

    Set delta time in reg3Ah // 1 LSB = 1.6384 s

    Write reg 3Fh = CTRL2_INIT // Disable access the embedded functions registers: write bit #4 of reg3Fh to 0, keep the other bits unchanged

    Please remember to implement also a debounce functionality in order to avoid false step detection (e.g. 7 consecutive steps have to be detected before the first interrupt generation)