Convert Asynchronous Subsystem to a Referenced Model
You can specify an asynchronous function-call input to a referenced model. However, to do so, you must convert the Async Interrupt and Function-Call Subsystem blocks to a subsystem and then convert the subsystem to a referenced model. This example shows how to convert an asynchronous subsystem to a referenced model.
Open Example Model
Open the example model AsyncSubsysToRefModelConversion
.
open_system('AsyncSubsysToRefModelConversion');
Convert Async Interrupt and Count Blocks to a Subsystem
Select the Async Interrupt and Count blocks.
Right-click the Count block.
From the context menu, select Create Subsystem from Selection.
Check Model Configuration Parameter Settings
Confirm that the model is configured with these model configuration parameter settings:
Multitask data transfer is set to
error
.Multitask conditionally executed subsystem is set to
error
.Underspecified initialization detection is set to
Simplified
.
Consider running the Model Advisor checks in the folder Migrating to Simplified Initialization Mode Overview and make the suggested changes.
Convert Subsystem to an Atomic Subsystem
Open Block Parameters dialog box for the subsystem.
On the Main tab, select the block parameter Treat as atomic unit.
Convert Subsystem to a Referenced Model
Right-click the subsystem.
Select Subsystem & Model Reference > Convert to > Referenced Model.
In the Model Reference Conversion Advisor, click Convert. The advisor converts the subsystem and replaces the Subsystem block with a Model block.
Set model configuration parameter Fixed-step size (fundamental sample time) to
1/300
so that it matches the setting of that parameter for the top model.
Move Async Interrupt Block to Top Model
Move the Async Interrupt block from the referenced model to the top model. Place the block between the Variant Source and Model blocks.
Add Asynchronous Task Specification Block to Reference Model
In the referenced model, insert an Asynchronous Task Specification block.
Set the Task priority parameter of the Asynchronous Task Specification block. For this example, the priority is set to 10. For more information on setting the priority, see Asynchronous Task Specification.
Adjust Block Parameters of Inport Block in Referenced Model
In the referenced model, for the Inport block, open the Block Parameters dialog box.
On the Signal Attributes tab, select the Output function call parameter.
On the Execution tab, set Sample time to
-1
(inherited). Click OK.Set the model configuration parameter Fixed-step size (fundamental sample time) to
1/300
. Click OK.Save the model changes.
Verify Model Configuration
Save the top model.
Update the model diagram.