Simulink - C++ interface: How data transfer is done between a visual c++ program and the simulink engine
Ältere Kommentare anzeigen
I am having difficulty in understanding how exactly a C mex-S function accepts external data from a C program. I need to pass data (two inputs) from an MFC application to a simulink model and then retrieve the data output( two outputs) from the model and send it back to my MFC application.
My grey area is how exactly does the data transfer process take place? If I have the value I want to transfer stored in a variable in my MFC application, how do I then call my simulink model accept this variable from my MFC application as an input, process it, and then relay this ouput data back to my MFC application?
I tried using the S Function Builder in simulink but I was very confused when it came to which libraries I should include. Also, I am not seeing how using an S function transfers data to and from the application because I do not know how the simulink model knows how, when and even where to look for the input data.
I have looked through much of the documentation on S functions but none seem to specifically outline how the process is done (or maybe I am interpreting some things wrong).
Some specifics:
- The input and output data I want to transfer is of type float/double/int16 (any type that can represent decimals)
-The inputs and outputs of the model are real numbers (no imaginary term)
-The number of inputs is two(2) and the number of outputs is also two(2).
-The data transfer rate is discrete (not sure if discrete is the technically correct term in this case so I will illustrate via example) e.g. a user should be able to input the values to the MFC program and recieve the output after processing by simulink. If he decides to leave for 5 minutes and then comes back and enters a new set of inputs, the results should be again readily available (like using a calculator)
- MATLAB version: R2008b
- Visual Studio Version: 2010 Ultimate
-The run of the program is dictated by the MFC application. The application should call the simulink model to do the processing when desired
Also, is it necessary to use the Visual Studio compiler or can I simply use the native MATLAB compiler?
Please advise if it will be necessary to upgrade my MATLAB version or downgrage my Visual Studio version
Any help/example code/flow diagram of data transfer process would be appreciated. Thank you.
Akzeptierte Antwort
Weitere Antworten (1)
Mike Woodward
am 26 Jun. 2012
0 Stimmen
Hi,
You might want to check out this free download: http://www.mathworks.com/programs/simulink-visual-studio/simulink-and-visual-studio.html
The download shows how to build a Visual Studio project that outputs a .mexw64 file. It shows how parameters are passed into C code.
Mike
1 Kommentar
Jonathan Vo
am 14 Okt. 2016
Mike,
The link is dead. Do you have an updated URL to the same download?
Kategorien
Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!