2026-03-09 6:54 AM
Hi.
I'm working with the FSM in LSM6DSO. I'm able to program detection which I want, but I struggle to do something like "fail-safe" to avoid the algorithm to stuck in the middle of the detection.
For example, I want to do a "throw" detection of a thing. The accelerometer is in the thing.
I can simply wait for enough acceleration in -X (in my case it will be always in this axis), then wait for the "fly" of the thing, where simply I can use norm V, which must be almost 0, as it's almost free fall, and it must fly for some time.
But I struggle to do some timeout to jump out of the fly detection, when there is no any, after e.g. 1s.
The problem is, that I can't use 2 timers (there is only single TC), because from manual, every time when comparison is done, the TC is loaded automatically and even when setting SCTC1, it loads anyway when I do comparison of 2 different timers.
Here is the example in the MEMS studio:
Now the FSM is able to stuck at S4, where it will wait for the "fly" detection, which must be detected at least for 200ms. I need to add something like "reset to start after 1s if no fly was detected".
Any idea how to implement it using these limitations?
Thank you
Solved! Go to Solution.
2026-03-27 2:29 AM
Hi @Bennny ,
Hello,
In order to be able to wait one second before evaluating fly condition you could add an additional TI4 | LNTH2 state. During the evaluation of TI4 | LNTH2, TC value will be 1s while during GNTH2 | TI3, TC value will be 0.202s.
2026-03-27 2:29 AM
Hi @Bennny ,
Hello,
In order to be able to wait one second before evaluating fly condition you could add an additional TI4 | LNTH2 state. During the evaluation of TI4 | LNTH2, TC value will be 1s while during GNTH2 | TI3, TC value will be 0.202s.
2026-04-24 5:23 AM
Hi.
This unfortunately doesn't help in all cases.
For better example I post an image.
I need to detect a peak (no problem), then detect that V+ is under threshold for some time, e.g. 100ms, then detect another peak - no problem.
This solution can be used for "fail-safe" on the second peak detection, but no for the "low level" detection.
In this situation the state machine is able to "stuck" on S2-S3 until the level is detected, because there can be problem, that there is no level (the value oscillate e.g. around the threshold, as at picture below) so it will detect level somewhere in future which doesn't correlate to this pattern.
Like this:
It looks like pretty easy detection with just 3 conditions, but this can result in wrong detection...