Can I use multi-rate enabled subsystems for deployment on multitasking targets such as Simulink Real-Time?

I have a model that contains a multi-rate enabled subsystem that I would like to deploy to a Speedgoat target using Simulink Real-Time (SLRT). When I update or build my model, I receive an error message.
The enabled subsystem 'MyModel/MySubsystem' executes in multiple tasks. This can cause corrupted data or non-deterministic behavior in a real-time system.
In newer versions of MATLAB:
Enabled subsystem 'MyModel/MySubsystem' executes in multiple concurrent tasks. This can cause corrupted data or nondeterministic behavior in a real-time system.
I may see I get a suggested action to "Clear Treat each discrete rate as a separate task", but when I try to click "Fix it", I get the error:
Failed : Unable to change 'Treat each discrete rate as a separate task'. Changing property 'EnableMultiTasking' is not allowed

 Accepted Answer

Multi-rate enabled subsystems are not supported when multitasking is enabled via the "Treat each discrete rate as a separate task" setting. This is a general Simulink constraint.
Multi-rate enabled subsystems allow the enable port to access the states of blocks inside the enabled subsystem. Because the enable port and blocks have different rates, the enable port and blocks may execute on different tasks/cores, which will cause a race condition where the states of the blocks are accessed from different tasks/cores. Simulink detects and reports this problem when the model is configured for multitasking.
If your goal is to deploy the model to multitasking or multicore targets such as Simulink Real-Time (SLRT), you need to avoid multi-rate enabled subsystems. In R2020a and previous releases, you can turn off concurrent execution for code generation with SLRT. However, in these releases, there was still a risk of creating a race condition as described above, which is why since R2020b, multi-rate enabled subsystems are no longer supported with SLRT.
As a workaround, convert the multi-rate enabled subsystems to single-rate enabled subsystems. If the enabled subsystem has input signals of different rates, you can add rate transition blocks to signals before they enter the subsystem. If you can't convert everything inside the subsystem to a single rate, then you need to split them apart into multiple single-rate subsystems.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!