1
votes

I have a question about my triggered subsystem in Simulink:

Level 0

So the Susbsystem is executed every 0.01 s.

My question is: how can I get this variable (0.01) inside my subsystem? NB: I don't need the Simulation step time.

I've already thought to two solutions: 1) use a Digital Clock with a Memory block 2) use a Weighted Sample Time block

but, both of them gave me an initial value of 0.

Do you have an elegant solution for my task

Thank you very much. Have a nice day

3

3 Answers

0
votes

The easiest solution is to have a constant block feeding into the subsystem. Define a MATLAB Workspace variable dt=0.01; and have the constant set to dt, and the sample rate of your Pulse Generator set to dt.

Alternatively you can use the Probe block to get the Sample Rate of the signal coming out of the Pulse Generator, and feed that as an input to the Subsystem.

0
votes

Another way is to use get_param() command in your workspace. In your case, it should be:

get_param('<path-to-block>/Pulse Generator','Period')

This should output:

>> ans =

0.01
0
votes

I had this same problem myself. I received the following feedback from MATHWORKS when I reported it as a bug:

If triggered subsystems are executed on edge detection on the triggering event then it will require at least two model execution time steps in order to satisfy the triggering condition. As a result the triggered subsystem will not execute at 0 causing the results you are seeing. This is expected behavior.

If you require the triggered subsystem to execute on the first timestep you can change the "Trigger type" option to "function call." This option will execute the subsystem or model when the control signal receives a function-call event from a Statflow chart, Function-Call Generator block, or an S-function block." In this case you will just need to confirm that your function call block executes prior to the triggered subsystem block. This can be confirmed using the "Blocks - Execution Order" Debug tool under "Information Overlays."