cancel
Showing results for 
Search instead for 
Did you mean: 

Step counter with LIS2DS12

f87
Associate II

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​

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

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)

View solution in original post

3 REPLIES 3
Eleon BORLINI
ST Employee

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

f87
Associate II

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

Eleon BORLINI
ST Employee

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)