cancel
Showing results for 
Search instead for 
Did you mean: 

FSM "dual" timer for fail-safe

Bennny
Associate III

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:
image.png

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

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. 

FedericaBossi_0-1774603753431.jpeg

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Federica Bossi
ST Employee

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. 

FedericaBossi_0-1774603753431.jpeg

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Bennny
Associate III

Hi.
This unfortunately doesn't help in all cases.
For better example I post an image.

Bennny_2-1777033373803.png


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.

Bennny_0-1777033324566.png

 

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:

Bennny_1-1777033352074.png

 

It looks like pretty easy detection with just 3 conditions, but this can result in wrong detection...