Triggering a subsystem to run for set duration

조회 수: 3 (최근 30일)
Roger
Roger 2011년 5월 24일
Hello, I want to trigger a subsystem that will then run for 0.25 time units (more than once) at points through the simulation but I do not know how to trigger a clock. Can anyone help?
Roger

채택된 답변

Roger
Roger 2011년 6월 20일
The solution to this problem can be solved using 'Reset clock' block written by Ravi Mravi which is very elegent and can be built out of standard blocks. This would be a clock that would be running from the start but could be set to zero at any point by a trigger. see: http://www.mathworks.com/matlabcentral/fileexchange/5761

추가 답변 (2개)

Fangjun Jiang
Fangjun Jiang 2011년 5월 24일
I am not fully understand your question. Let's see if this is the case. Set your simulation step size as 0.01 second. Drag a "Pulse Generator" block, set the period as 1 second and the pulse width as 25 (percent). Use the output of the "Pulse Generator" to trig an "Enabled Subsystem". The subsystem will be running every 0.25 second out of 1 second.
  댓글 수: 1
Roger
Roger 2011년 5월 25일
Thank you for taking the time to consider my problem. As Mark said in his reply I am not sure of the time between triggers - but this was not clarified.

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


MarkB
MarkB 2011년 5월 24일
Fangjun's approach is probably the best way if the interval between the 0.25 pulses is also known in advance. If it is not, I would recommend using Stateflow instead.
The general idea is that you would still use an "Enabled Subsystem" like above, but in this case, Stateflow would output a Boolean signal to drive it. Inside Stateflow, you could read any relevant inputs, and use them to enter a state that sets the output as "true", only exits after 0.25 (check the documentation for "temporal logic" to see the Stateflow keywords for defining time intervals), and then sets the output to "false" upon exiting the state.
  댓글 수: 5
Roger
Roger 2011년 5월 26일
The trigger is another process exceeding a maximum value. So every time the other process results in a parameter getting larger than say 10, I need a process to be triggered to run for 0.25 time units.
Sorry about not replying earlier did not realise that I did not get notified about comments. In the mean time I think I have found a work around.
My solution:
The actual value I need to produce (and hold) from my subsystem is zero so I made a circuit where:
- the value from the external system is feed into a "compare to constant" block (if above set value then has value of 1)
- this feeds into a "zero order hold" block with time span set to 0.25
- this feeds into "matlab function" block (u) along with another feed which gives standard feed (Q) as long with following code:
function Q_final = fcn(u,Q)
%#codegen
if u > 0
Q_final = 0;
else
Q_final = Q
end
- Output is what I want.
This is a pig ugly way of achieving goal and if anyone else has a simpler way of holding values or triggering systems for set amount of time I am still interested.
Fangjun Jiang
Fangjun Jiang 2011년 5월 26일
The use of Matlab function block is not needed. You could just use a switch block.

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

카테고리

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