How to use a C# DLL in an S-Function for a Real Time application

5 views (last 30 days)
I have a problem using a C# DLL (which I don´t have the root code) in a S-function in Simulink. I tried with a simple call using "addNetAssembly", but since it is not a valid "C++" command, it didn´t work.
I then looked for a way of implement code from C# in C++, so I created a C# Wrapper code that I compiled for a COM use. I made my tests in Visual Studio and then came back to my S-Function and it worked well.
The problem appears when I switched to external use for Real Time Work Shop with Real Time Windows Targe(RTWT), because I load my COM with the command line #import, and the compiler for RTWT (OPEN WATCOM)did not accept it. I have been thinking in some ways to solve the problem, but I don´t want to lose myself in so many languages. Are there others ways to do what I´m trying here? Are there other ways to run a real time application with no physical devices connected than Real Time Windows Target? Thanks in advance and forgive my short experience :D.

Accepted Answer

Jan Houska
Jan Houska on 14 Aug 2013
You cannot use C# or any other language that requires .NET in real-time code. This is not because of Open Watcom, but because of the .NET code not being able to run in real time (with guaranteed execution time).
You should be able to use your S-function in Real-Time Windows Target Normal Mode, available from Release 2012a. This is probably the best you can do if you want to run your model in real time. There is no chance you can compile any .NET code for any real-time target running in External Mode.
  1 Comment
Martin
Martin on 14 Aug 2013
Thanks for your time and advice, I´ll try what you said and hope to find an acceptable result.

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing 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!