MATLAB Answers

Execute subsystem in Simulink if condition is met for 5 seconds?

조회 수: 1(최근 30일)
I have a subsystem that I want executed in Simulink when a variable, RC_flag, is equal to 0 for 5 seconds. I have RC_flag updating at each Simulink time step, and I have Elapsed Real Time block to output the elapsed real time since the start of the simulation (different than the Simulink time step). How do I combine these two variables to execute my subsystem when RC_flag = 0 for 5 seconds?

  댓글 수: 0

로그인 to comment.

채택된 답변

Fangjun Jiang
Fangjun Jiang 26 Nov 2019
Do an equal comparison (==) between RC_flag and zero, generate this int_flag. Feed int_flag to an Integrator. If the output of the Integrator is greater than 5, then execute the subsystem.
Enable the external reset of the Integrator block. Use the int_flag and specify "falling" edge to reset the Integrator. Any change of the int_flag during the 5 seconds will reset the Integrator block.

  댓글 수: 1

Andrew Poissant
Andrew Poissant 26 Nov 2019
Works like a charm, great idea!

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.





Translated by