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

7 visualizaciones (últimos 30 días)
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 comentarios
Todd Flanagan
Todd Flanagan el 27 de Mayo de 2011
Could you give us a screenshot of what you have now?
abdelkader mahmoudi
abdelkader mahmoudi el 4 de Nov. de 2020
hello if you get the solution please tell usabout it i'm really need it

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 27 de Mayo de 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 comentarios
Fangjun Jiang
Fangjun Jiang el 30 de Mayo de 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 el 31 de Mayo de 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

Iniciar sesión para comentar.

Más respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Array and Matrix Mathematics en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by