How to create a counter in simulink

旧巷老猫 提交于 2019-12-23 18:29:42

问题


I would like to count how many times my signal goes to zero. For example having an impulse signal as input I want a variable which counts how many times the impulse goes to zero.

I´m becoming crazy thinking of something....can anybody help me? Thanks


回答1:


figure 1 is a pulse counter model

and figure 2 is scope output which shows for 5 input pulses we get counter output as 5




回答2:


There is a similar question here that might help. There are loads of ways to implement a counter, but a good way I've used before is to use a rising/falling edge detect. I don't have the library on my computer so I can't test this Edge Dectector but I've used one similar in the past for just this problem. It will output a single sample time impulse when it detects a given condition, which in your case would be a signal going to zero. You can then use with a memory block and an add to implement a counter. See below:



来源:https://stackoverflow.com/questions/35319945/how-to-create-a-counter-in-simulink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!