jacky
jacky

Reputation: 81

How to build a counter in Simulink which counts impulses with given length?

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

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.

Upvotes: 2

Views: 946

Answers (1)

Wolfie
Wolfie

Reputation: 30101

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

Upvotes: 1

Related Questions