s-function tlc

10 views (last 30 days)
Dalmo Silva Júnior
Dalmo Silva Júnior on 28 Jul 2021
Commented: Mohammad on 15 Jun 2023
We are using MATLAB/Simulink to generate a real-time executable model to embed into dSPACE's Microautobox hardware.
Our system under study is mainly constituted by an optimization algorithm that aims to return an optimized battery charge/discharge decision in a microgrid. In this sense, our optimization algorithm code is encapsulated in the “S-function” block, where we can incorporate functions such as the Yalmip solver. The file with the extension (.slx) works as it should when simulating offline through Simulation Model (Run).
However, when performing the procedure of building a model for realtime (via Ctrl+B), we ran into a problem that the “S-function” block is not an inlined function, so, as we understand it, it does not have enough resources to generate all the auxiliary codes like the file with the extension (.tlc) for example.
In this sense, we identified that the “S-function Builder” block is capable of generating these auxiliary files, however, it is necessary to program it in (.c) language, and our code is written entirely in MATLAB (.m) language.
As a test, we tried to convert the MATLAB (.m) code to language (.c) by the MATLAB Coder app, however, without success because some functions used in the algorithm are not transcribed to the language (.c).
So we would like to know if it is possible to perform a transcription of the "S-function" block to the "S-function Builder" without the need for us to rewrite our code in the language (.c) in the "S-function Builder" block? Or, some procedure in which we can convert the file with MATLAB language (.m) to language (.C)?
  1 Comment
Mohammad
Mohammad on 15 Jun 2023
Hi Dalmo,
I am new to Yalmip and also seek to flash simulink code on to Dspace hardware. Were you successfull in flashing code to the dSPACE's Microautobox hardware?
Your reply would be of high significance.
Thanks

Sign in to comment.

Answers (1)

Benjamin Thompson
Benjamin Thompson on 2 Feb 2022
Do you still need help with this? S-Function builder or the legacy c code tool can both produce skeleton C or C++ source files and skeleton TLC files to use as a starting point. For any custom blocks that you add to Simulink, Embedded Coder will need information about how to reproduce the C/C++ code for that block at the time of code generation.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!