How do I embed the Real-Time Workshop (RTW) generated code created by ERT into my own code?

7 views (last 30 days)
How do I embed the RTW generated code created by ERT into my own code?
When I do a 'build' using ert.tlc using RTW, I get an .exe file. How is the .exe file embbeded into other code?
What I had in mind was having RTW generate a subroutine that can be called and linked by a driving program. Is this possible with ERT? If not, how can I modify the file grt_main.c to accomplish this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Jan 2017
Starting Release 2010a (R2010a), information regarding the various options to integrate Real-Time Workshop generated code with existing code can be obtained from the following documentation link titled 'Exporting Generated Algorithm Code for Embedded Applications':
For previous releases, read below for any additional information:
The exe file option was added for you to see that, once the Simulink portion was compiled, linked, and made into an executable file, the file works to your specifications. If you are going to embed this Simulink model into your own code, instead use the .c file that was created.
The ert_main.c file is the best file to examine. This file can act as your main file, calling the Simulink ERT code you have generated. You will see that ert_main.c file calls the generated ERT code through three main function calls:
- MODEL_INITIALIZE
- MODEL_STEP
- MODEL_TERMINATE
The ert_main.c file is well documented; follow this as an example.
Also review the ert template makefile for instructions on how to compile everything together, along with any other lib files that are required, to compile all of the ERT code with your code.
Note that the ert_main.c file and the template makefiles are located in the
$MATLAB\rtw\c\ert directory
(where $MATLAB = MATLAB root directory on your machine)

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!