Main Content

Sample Times in Subsystems

Subsystems fall into two categories: triggered and non-triggered. For triggered subsystems, in general, the subsystem gets its sample time from the triggering signal. One exception occurs when you use a Trigger block to create a triggered subsystem. If you set the block Trigger type to function-call and the Sample time type to periodic, the SampleTime parameter becomes active. In this case, you specify the sample time of the Trigger block, which in turn, establishes the sample time of the subsystem.

There are four non-triggered subsystems:

  • Virtual

  • Enabled

  • Atomic

  • Action

Simulink® calculates the sample times of virtual and enabled subsystems based on the respective sample times of their contents.

The atomic subsystem is a special case in that the subsystem block has a SystemSampleTime parameter. Moreover, for a sample time other than the default value of –1, the blocks inside the atomic subsystem can have only a value of Inf, –1, or the identical (discrete) value of the subsystem SampleTime parameter. If the atomic subsystem is left as inherited, Simulink calculates the block sample time in the same manner as the virtual and enabled subsystems. However, the main purpose of the subsystem SampleTime parameter is to allow for the simultaneous specification of a large number of blocks, within an atomic subsystem, that are all set to inherited. To obtain the sample time set on an atomic subsystem, use this command at the command prompt:

get_param(AtomicSubsystemBlock,‘SystemSampleTime’);

Finally, the sample time of the action subsystem is set by the If block or the Switch Case block.

For non-triggered subsystems where blocks have different sample rates, Simulink returns the Compiled Sample Time for the subsystem as a cell array of all the sample rates present in the subsystem. To see this, use the get_param command at MATLAB prompt.

get_param(subsystemBlock,'CompiledSampleTime')

Related Topics