4

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

  • Can you show some code you've tried and give a more specific question about what isn't working as expected? – thanksd Feb 10 '16 at 16:13
  • I tried to use the counter limited block. The problem is that the latter keeps counting meanwhile the signal is zero. Instead I want just 1 when the signal is zero and it has to keep 1 until the signal goes to zero again. Then it will become 2 and so on – Alessandro Peticchia Feb 10 '16 at 16:40

2 Answers2

2

figure 1 is a pulse counter model pulse counting model] and figure 2 is scope output which shows for 5 input pulses we get counter output as 5 Scope output

ArunK
  • 1,731
  • 16
  • 35
0

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:

enter image description here

Community
  • 1
  • 1
DrBuck
  • 822
  • 7
  • 22