S-Function with different behaviors during simulation and embedded coding

5 views (last 30 days)
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

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 30 Dec 2013
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 Comment
Florent
Florent on 31 Dec 2013
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

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!