Resolve Rate Transitions
In general, a rate transition exists between two blocks if their sample times differ, that is, if either of their sample-time vector components are different. The exceptions are:
Blocks that output constant value never have a rate transition with any other rate.
A continuous sample time (black) and the fastest discrete rate (red) never has a rate transition if you use a fixed-step solver.
A variable sample time and fixed in minor step do not have a rate transition.
You can resolve rate transitions manually by inserting rate transition blocks and by using two diagnostic tools. For the single-tasking execution mode, the Single task data transfer diagnostic allows you to set the level of Simulink® rate transition messages. The Multitask data transfer diagnostic serves the same function for multitasking execution mode. These execution modes directly relate to the type of solver in use: Variable-step solvers are always single-tasking; fixed-step solvers may be explicitly set as single-tasking or multitasking.
Automatic Rate Transition
Simulink can detect mismatched rate transitions in a multitasking model during an update diagram and automatically insert Rate Transition blocks to handle them. To enable this, in the Solver pane of model configuration parameters, select Automatically handle rate transition for data transfer. The default setting for this option is off. When you select this option:
Simulink handles transitions between periodic sample times and asynchronous tasks.
Simulink inserts hidden Rate Transition blocks in the block diagram.
Automatically inserted Rate Transition blocks operate in protected mode for periodic tasks and asynchronous tasks. You cannot alter this behavior. For periodic tasks, automatically inserted Rate Transition blocks operate with the level of determinism specified by the Deterministic data transfer parameter in the Solver pane. The default setting is
Whenever possible, which enables determinism for data transfers between periodic sample-times that are related by an integer multiple. For more information, see Deterministic data transfer. To use other modes, you must insert Rate Transition blocks and set their modes manually.
Visualize Inserted Rate Transition Blocks
When you select the Automatically handle rate transition for data transfer option, Simulink inserts Rate Transition blocks in the paths that have mismatched transition rates. These blocks are hidden by default. To visualize the inserted blocks, update the diagram. Badge labels appear in the model and indicate where Simulink inserted Rate Transition blocks during the compilation phase. For example, in this model, three Rate Transition blocks were inserted between the two Sine Wave blocks and the Multiplexer and Integrator when the model compiled. The ZOH and DbBuf badge labels indicate these blocks.
You can show or hide badge labels. On the Debug tab, select Information Overlays > Automatic Rate Transitions.
To configure the hidden Rate Transition blocks, right click on a badge label and click on Insert rate transition block to make the block visible.
When you make hidden Rate Transition blocks visible:
You can see the type of Rate Transition block inserted as well as the location in the model.
You can set the Initial Conditions of these blocks.
You can change data transfer and sample time block parameters.
Validate the changes to your model by updating your diagram.
Displaying inserted Rate Transition blocks is not compatible with export-function models.
To learn more about the types of Rate Transition blocks, see Rate Transition.
Suppose you automatically insert rate transition blocks and there is a virtual block specifying sample time upstream of the block you insert. You cannot click the badge of the inserted block to configure the block and make it visible because the sample time on the virtual block causes a rate transition as well. In this case, manually insert a rate transition block before the virtual block. To learn more about virtual blocks, see Nonvirtual and Virtual Blocks.
- Handle Rate Transitions (Simulink Coder)
- Time-Based Scheduling and Code Generation (Simulink Coder)