How do I start a counter based on a threshold value in Simulink?

14 ビュー (過去 30 日間)
harish bharadwaj
harish bharadwaj 2011 年 5 月 27 日
I am implementing some fault detection logic, i.e i am comparing some incoming digital data with the threshold value using comparator in Simulink. When incoming data crosses threshold value, a counter has to start. If that counter value is greater than 20 mili sec then counter has to send a step signal until the comparison using comparator is done.
How do I do this?
  2 件のコメント
Todd Flanagan
Todd Flanagan 2011 年 5 月 27 日
Could you give us a screenshot of what you have now?
abdelkader mahmoudi
abdelkader mahmoudi 2020 年 11 月 4 日
hello if you get the solution please tell usabout it i'm really need it

サインインしてコメントする。

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 5 月 27 日
This counter question seems to come up often recently. One of the ways to implement a counter in Simulink is to use the Integrator block. Take a look at this post to see if it gives you a clue.
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 5 月 30 日
I assume you want to count how long your signal has exceeded the threshold value. Compare your signal value with the threshold value, if it is greater than the threshold, it outputs 1. Feed this signal to the integrator, as long as your signal is greater than the threshold, the comparator outputs 1 and the integrator keeps integrating, thus the output of the integrator is a time counter. Regarding reset, when do you want to reset the time counter? You can enable the reset of the integrator and construct your logic to provide that resetting signal. There is many options for the resetting signal, edge or low/high value. I am not clear what do your mean by saying "until the comparison using comparator is done". Do you mean when your signal is less than the threshold? Then you can use the opposite (logical NOT) of the comparator output to reset the integrator. What resetting signal do you have now? How can it reset regularly? Can you take a look at the resetting signal and see what's happening?
harish bharadwaj
harish bharadwaj 2011 年 5 月 31 日
i want to count how long the signal exceeded the threshold value.
i have followed according to your suggestion,but the integrator based counter is resetting even though the comparator output is one but this is not the way how i expected the counter to work. it has to count as long as the signal exceeds thresdhold value.
hope you are now clear about my problem.
please suggest me a solution for this

サインインしてコメントする。

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 5 月 31 日
It sounds like that you don't need to re-set your integrator. Let's say your input signal is greater than the threshold for 10 mili sec, then goes below the threshold for 20 mili sec, and then greater than the threshold for 30 mili sec, what is your expected output?
1. You want the output to increase from 0 to 0.01 for the first 10 mili sec, then stay at 0.01 for 20 mili sec time period, then goes from 0.01 to 0.04 for the rest of 30 mili sec time period. You don't need the re-setting. Disable the re-setting option of the integrator block.
2. You want the output to increase from 0 to 0.01 for the first 10 mili sec, then re-set to 0 for 20 mili sec time period, then goes from 0 to 0.03 for the rest of 30 mili sec time period. You need the re-setting. Use the opposite of the comparator block output to re-set the integrator block.
  4 件のコメント
harish bharadwaj
harish bharadwaj 2011 年 6 月 7 日
could u please tell how to send that screenshot of that model
Walter Roberson
Walter Roberson 2011 年 6 月 7 日
For locations you can upload to, please see
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by