How to 'effectively' stop outputing signals from the subsystem when it is not triggered on or not enabled?

조회 수: 7 (최근 30일)
Dear All,
I've built a system in Simulink,which tried to interprete binary signals of a certain pattern. A counter was set based on the sampling time, and at each moment when the signal changes from 0 to 1 or from 1 to 0, I'd like to record the counter of that moment, as well as the change characteristics (like rising or falling).
I used the 'trigger subsystems', but the problem is, the subsystem will always output something at each sampling point, even it's not a rising or falling signal that I'm interested. The settings for the triggered subsystem only allow to keep the output either held or reset to a random number.
How to get around this problem and let the triggered subsystem output something only when it's triggered?
Cheers,
Yanbo

답변 (2개)

Albert Yam
Albert Yam 2012년 8월 15일
Off the top of my head, At the output of your subsystem (outside), put a switch block, with a known 'invalid' constant (NaN? or -1?) as the other input. The switch signal being the same as the 'enable'.
So if not enabled, you get an 'invalid' value.
  댓글 수: 2
Yanbo
Yanbo 2012년 8월 20일
Thank you for your comment. But speaking of the triggered subsystem, MATLAB help file says the output can only be held when it's not triggered, therefore, cannot be reset by an 'invalid' constant.
Anyway, I will try the your suggestion for the enabled subsystems, see if it works.
Cheers
Albert Yam
Albert Yam 2012년 8월 20일
"The switch signal being the same as the 'enable'." Does not mean to replace the enable, it means the signal going into the switch block, the trigger, should be the same signal used for the enable.
By 'invalid' I mean 'something that your code cannot normally produce', not something that will produce an error.
Since the Simulink signal produces an output at every step (as Kaustubha mentioned), if your output is a 1 or 0, then you can't tell if those values are calculated or held (not calculated), but if you see a NaN or -1 or 2, then you know that at that time step, the output is not from calculation.
With the switch block, those 'held' values are not sent out. They terminate at the switch. Enabled values (calculated) pass through the switch.

댓글을 달려면 로그인하십시오.


Kaustubha Govind
Kaustubha Govind 2012년 8월 16일
편집: Kaustubha Govind 2012년 8월 16일
There is no way to "stop" outputting signals from any block in Simulink. The Simulink Engine expects blocks to produce some output every time there is a sample-hit. However, you should be able to achieve what you need by having the output reset or to hold the last value and construct additional logic around that (for example, see Albert's answer).

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by