Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Sample Time Propagation

Inherited sample times in source blocks (for example, a root inport) can sometimes lead to unexpected and unintended sample time assignments. Since a block may specify an inherited sample time, information available at the outset is often insufficient to compile a block diagram completely.

In such cases, the Simulink engine propagates the known or assigned sample times to those blocks that have inherited sample times but that have not yet been assigned a sample time. Thus, the engine continues to fill in the blanks (the unknown sample times) until sample times have been assigned to as many blocks as possible.

Blocks that still do not have a sample time are assigned a default sample time according to the following rules:

  1. If the current system has at least one rate in it, the block is assigned the fastest rate.

  2. If no rate exists and the model is configured for a variable-step solver, the block is assigned a continuous sample time (but fixed in minor time steps). The Real-Time Workshop product (with the exception of the rapid simulation and S-function targets) does not currently support variable-step solvers.

  3. If no rate exists and the model is configured for a fixed-step solver, the block is assigned a discrete sample time of (Tf - Ti)/50, where Ti is the simulation start time and Tf is the simulation stop time. If Tf is infinity, the default sample time is set to 0.2.

To ensure a completely deterministic model (one where no sample times are set using the above rules), you should explicitly specify the sample times of all your source blocks. Source blocks include root inport blocks and any blocks without input ports. You do not have to set subsystem input port sample times. You might want to do so, however, when creating modular systems.

An unconnected input implicitly connects to ground. For ground blocks and ground connections, the default sample time is derived from destination blocks or the default rule.

All blocks have an inherited sample time (Ts = -1). They are all assigned a sample time of (Tf - Ti)/50.

Constant Block Sample Times

You can specify a sample time for Constant blocks. This has certain implications for code generation.

When a sample time of inf is selected for a Constant block,

Generated code for any block differs when it has a constant sample time; its outputs are represented in the constant block outputs structure instead of in the general block outputs structure. The generated code thus reflects that the Constant block propagates a constant sample time downstream if a sample time of inf is specified and Inline parameters is on.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS