Rate Transition with adjustable sampling rate

2 vues (au cours des 30 derniers jours)
Boru Wang
Boru Wang le 27 Juin 2019
Réponse apportée : MarkB le 9 Juil 2019
I am thinking about building a Simulink Model for embeded code generation with multiple task rate. I plan to vary one of the task rate during execution . I am under the impression that Simulink rate transition block only takes fixed task rate. I was wondering if there is a way to introduce rate transition with variable task rate?

Réponses (1)

MarkB
MarkB le 9 Juil 2019
Dear Boru,
Unfortunately, Simulink doesn't support changing sample times in the generated code. The underlying issue is that the generated code for rate transition blocks varies (among other things) depending on whether it is a "faster-to-slower" or "slower-to-faster transition". However, if you changed a sample time in the generated code, you could accelerate or decelerate one part of the code independently of the other sample times in the model. Changing the sample time in the generated code could cause a rate transition that was originally "slower-to-faster" to become "faster-to-slower" (or vice versa). However, the code for the rate transition can't handle this sort of change, so this approach isn't supported.
One alternative approach is to have asynchronous function-called subsystems in an "Export Functions" modeling style (https://www.mathworks.com/help/ecoder/examples/exporting-functions.html). One options is to have function-called subsystems with asynchronous sample times. In this context, the function-called subsystem has no sample time at all. This allows you to call it at irregular rates, but this limits blocks that are allowed in the subsystem, since nothing inside is allowed to demand a sample time.
Overall, this "Export Functions" style of modeling provides some control over the generated function prototypes as well. With this in mind, if you adopt an "Export Functions" modeling style, you probably don't need to use Function Prototype Control, which I recommended in your other post (https://www.mathworks.com/matlabcentral/answers/470164-how-to-customize-the-code-interface-of-a-function-generated-of-a-reference-model).
Regards,
Mark Biesiada

Catégories

En savoir plus sur Embedded Coder dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by