问题
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:
Model: Output
回答1:
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
- increment the counter if the count value is currently less than
1
. - reset the counter to
1
if the counter is already at2
.
In this example the counter resets every second crossing of the threshold.
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.
回答2:
Using the answer above by Phil, i was able to create my version without using triggered subsystem
Sample answer
来源:https://stackoverflow.com/questions/54844176/how-to-detect-2nd-crossing-to-point-simulink