Interface/communicate data between SIMULINK and a C-program running on the same computer

1 回表示 (過去 30 日間)
Hey everyone! I'm very new to this so, please bear with me.
I'm working on a C-program that is supposed to control a small fluid system (read pressures and actuate valves, etc.). I need to simulate a plant model in SIMULINK/SIMSCAPE that can be controlled by the C-program. I'm trying to figure out how I would setup the model such that it can communicate and transfer live data with the C-program.
Things like, send .csv sensor data over to the C-program and accept HIGH/LOW signals from it. Any assistance is appreciated. Thank you!

採用された回答

Mark McBroom
Mark McBroom 2020 年 6 月 26 日
If you have the source code for the C program, the best approach is to create a new Simulink block that contains your C code modified to be a C function. The inputs to the C-Function would be the outputs of the plant model, and the return vaues from the C function are the inputs to your plant model.
THe easiest way to create this Simulink block that contains your C code is with the Simulink C Caller block:
Thanks.
Mark.
  1 件のコメント
Abhigya Raval
Abhigya Raval 2020 年 6 月 27 日
Thank you for the answer, Mark!
I have the source code in C however, it's a complicated program. I'm not really experienced with C, only MATLAB.
There're about 9 source code files and 5 header files. Is it plausible in SIMULINK to do what you suggested for a program like this?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeUpgrading Hydraulic Models to Use Isothermal Liquid Blocks についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by