user183060
user183060

Reputation: 13

how to detect 2nd crossing to point simulink

How to detect the 2nd falling crossing when it reaches the 2nd point. The signal will rise again after the 2nd crossing and then repeats. Each time the signal falls at 20(2nd time) i want to capture it via relational block like the output signal in the image

Input Signal: Input Signal

Model: Model Output Output

Upvotes: 0

Views: 648

Answers (2)

user183060
user183060

Reputation: 13

Using the answer above by Phil, i was able to create my version without using triggered subsystem

Sample answer

Upvotes: 0

Phil Goddard
Phil Goddard

Reputation: 10772

There are multiple ways this could be done. One approach is to create a triggered counter, using a Triggered Subsystem, with the counter resetting itself if the count tries to go above 2.

An example of this is shown below. The trigger is generated by comparing your input to a constant (in this case 20) and incrementing the counter based on a rising edge of that trigger. Initialize the counter to 1, then either

  1. increment the counter if the count value is currently less than 1.
  2. reset the counter to 1 if the counter is already at 2.

In this example the counter resets every second crossing of the threshold.

enter image description here

If data typing is important this could also be done using logical/boolean values (i.e. True and False), rather than the 1 and 2 used in the example.

Upvotes: 1

Related Questions