Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
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 Kommentare
Todd Flanagan
Todd Flanagan am 27 Mai 2011
Could you give us a screenshot of what you have now?
abdelkader mahmoudi
abdelkader mahmoudi am 4 Nov. 2020
hello if you get the solution please tell usabout it i'm really need it

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 27 Mai 2011
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 Kommentare
Fangjun Jiang
Fangjun Jiang am 30 Mai 2011
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 am 31 Mai 2011
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Fangjun Jiang
Fangjun Jiang am 31 Mai 2011
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 Kommentare
harish bharadwaj
harish bharadwaj am 7 Jun. 2011
could u please tell how to send that screenshot of that model
Walter Roberson
Walter Roberson am 7 Jun. 2011
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu General Applications finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by