How can I trigger an action when a signal exceeds a threshold for a certain time?
34 views (last 30 days)
Show older comments
Hallo everybody,
I'm implementing a simulink algorithm. I have an amplitude signal over a time. If it exceeds a certain value for more than a certain time I want to trigger another action.
I'll explain with an example. I have a randomly oscillating signal that goes from 0 to 2. If it exceeds, let's say, 1 for a time of 10 seconds continuously I want to trigger an action.
How can I do it?
Thanks
0 Comments
Accepted Answer
Sebastian Castro
on 21 May 2014
Time-based logic like what you described is best suited for Stateflow, if you have access to that.
Your algorithm can enter a state when the signal is first 1, and keep counting until the signal remains 1. If, after 10 seconds, you're still in that same state, trigger the action.
The image below shows how you can create such a state chart.
If you do not have Stateflow, you could use a Resettable Delay block to create a counter... it already looks messier and harder to read. In fact, my screenshot below is very likely to have some bugs in it. I didn't get to test it, but you can feel free to if you're interested in this approach.
Hope this helps!
0 Comments
More Answers (1)
Bushra Kaleem
on 21 Jun 2019
I have a similar question. exmple: I have an analog input wave, for when the output goes bove particular threshold, I need to generte pulses of certain time period. Can there be a code for this?
0 Comments
See Also
Categories
Find more on DTMF in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!