MATLAB Answers

How to adapt C-language S-function to Opal-RT?

6 views (last 30 days)
I am working with Opal-RT (with Matlab R2011a) to implement a Microgrid controller using a S-function in C language. The simulation works very well in Simulink environment, where I am using .mexw32 for compilation. However, the following error apears when I try to build the model into the target (i.e. Opal RT):
ntox86-g++-3.3.5: sfunc_teste2.o: No such file or directory
The name of the .c file that my S-function calls is sfunc_teste2.c . The full error is in the attached file. It seems that Opal-RT cannot find the .c files, even though they are in the same directory of all my project file. How can I send all dependant .c/.h of my S-function to Opal-RT? Is it possible to use S-function without using .tlc files in Opal-RT?


Sign in to comment.

Accepted Answer

Clay Walker
Clay Walker on 12 Sep 2019
From my experience, if the model simulates correctly in Simulink, then it is usually an RT-Lab issue.
When you compile the model on the target, you need to move all required .c/.h files to the target prior to compilation. The way to do this is by opening the model in RT-Lab, opening the "Files" tab, click Add, then add your sfunc_teste2.c file. Make sure its "Before compilation".


Daniela Yamashita
Daniela Yamashita on 19 Sep 2019
Thank you for your answer. I followed your instructions and I achieved to compile the project with sucess.
I have another issue. I would like to use external libraries. To be more specific, I would like to add the library CPLEX and Eigen. Do you know how to add an external library into OPAL-RT? Is it in the same way?
Clay Walker
Clay Walker on 19 Sep 2019
I don't have any experience with that, but in theory it should be similar. Your first step would be to get it working on your desktop using S-functions. Then you should be able to install the library to the target PC. One thing to note is, at least for us, the target is a linux computer so the library will need to have a linux binary. I wish I could help you more, but I haven't really used external libraries like these.

Sign in to comment.

More Answers (0)




Translated by