S-Function with different behaviors during simulation and embedded coding

16 次查看(过去 30 天)
Hi,
I have a microprocessor target for which I would like to have my S-function "simulate" and "generate embedded code".
By "simulation", I mean that the S-Function is executed in the computer and behaves like an I/O block reading/writing microprocessor input/output pins via a network link (the microprocessor target then runs an existing IO program). Right now, a m-file S-Function does it perfectly.
By "generation of embedded code", I mean that the generated code runs directly on the microprocessor target and is not related to any network link at all (the microprocessor target runs a program containing all the Simulink model). I'm about to write a TLC file for this second behavior.
After a look at the RTW User Guide, I could not find clues for having a single block with these two different behaviors. Is it possible using R2013?
My second question is about accelerated "simulations", how to prevent Matlab from using the TLC file and only rely on the m-file S-function? (the TLC file does not contain the simulation behavior).
Same question about the "external mode", how to force the usage of the TLC file in this mode when the code is generated?
TIA,
- Florent

采纳的回答

Kaustubha Govind
Kaustubha Govind 2013-12-30
Yes, as you noted from my previous answer, your M-file will define simulation behavior, while the TLC will be used for code generation. So you can keep your MATLAB S-function as it is, and write your TLC using the target libraries. I believe that TLC is not used for accelerated mode by default. C S-functions need to add the SS_OPTION_USE_TLC_WITH_ACCELERATOR to opt out of this behavior for instance.
  1 个评论
Florent
Florent 2013-12-31
Hello,
Thanks for your confirmation, it works like a charm simulation & code generation. I've created a new platform target for the DarwinOP robot: https://github.com/darwinop-ens/darwin-op/tree/master/Simulink
Cheers,
- Florent

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by