how to detect 2nd crossing to point simulink

ⅰ亾dé卋堺 提交于 2020-01-16 09:35:28

问题


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

  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.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!