Home > Back-end >  How to build a counter in Simulink which counts impulses with given length?
How to build a counter in Simulink which counts impulses with given length?

Time:11-11

I would like to model railway interlocking. The counter recieves impulses with the following parameters:

  • length of signal:260 ms
  • short break:130 ms
  • long break: 520 ms

Here is the signal generator:

enter image description here

These are the block paramaters: Sine: enter image description here

Impulse generator: enter image description here

4-impulses:

enter image description here

And this is the sign in which I would like to count the impulses:

enter image description here

In the example I would like to count 4 impulses in one period because we know that one period is 1950 ms.

CodePudding user response:

This feels fairly convoluted, but it's hopefully easy to follow and adapt.

Essentially you can check how long the pauses are, and if that pause duration satisfies your criteria then increment a counter.

Comment groups added for what each group of blocks is doing, might be possible to simplify this using some latched timers but I didn't explore the block library so this uses all very fundamental blocks.

Diagram (click to enlarge)

enter image description here

Scope:

scope

  • Related