Run an enabled and triggered subsystem only one time (single shot)

조회 수: 12 (최근 30일)
I have a Simulink enabled and triggered subsystem that I want to execute only one time.
I think one way to do it is to make sure the enable pulse is only slightly wider than a time step, but I don't really want to mess with doing it that way because the time step could be variable.
Any other possibilities?
--- EDIT ---
Added model showing what I am trying to do. I have a byte, and I want to change it to a new byte in a timed, bitwise manner. So if I went from 0b00000000 to 0b11111111, I would after 1ms go to 0b00000001, then after two go to 0b00000011, and so on. What I want to see on the scope is this value staircasing up at millisecond intervals.

채택된 답변

Paul
Paul 2025년 2월 6일
Does it really need be enabeld and triggered? Even if so, it should only run when triggered (and enabled), so if the trigger triggers only once, the block will execute only once.
  댓글 수: 4
Paul
Paul 2025년 2월 6일
I'm afraid I won't be able to look at your model.
However, I'm quite sure that the subsystem will only execute when triggered and enabled. If the Outports of the subsystem are set with parameter "Output when disabled" set to "held", which is the default, then the output is held when the subsystem is disabled (per the Enable input).
In the example below, the subsystem is triggered once at T = 1 second from the Step block and the output jumps from the initial value of 0 to the value of sin(1) at that time and is subsequently held at that value.
Matthew Mishrikey
Matthew Mishrikey 2025년 2월 7일
I had a bug in my matlab function that was causing it not to work, and I mistakenly assumed it had to do with the enable/trigger.
Your nice example gave me the insight I needed to believe it behaved correctly. Many thanks!!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by