Help on compiling Simulink model with UDP send/receive

11 Ansichten (letzte 30 Tage)
Brad
Brad am 17 Mai 2023
Beantwortet: Mahaveer Satra am 30 Jan. 2025 um 15:29
I made a Simulink model that communicates with a Unity app via UDP send/receive (picture below).
I have verified that it works in real-time with 2 different configurations in the Simulink model running with the Simulink Desktop Real-Time app:
Config 1: Simulink Desktop Real-Time "Packet Input" and "Packet Output" blocks using UDP protocol
Config 2: DSP System Toolbox "UDP Receive" and "UDP Send" blocks
Ultimately, I want to compile the model to a .exe file so I can run it separately from Matlab/Simulink. My understanding is I have to choose the "System target file" in Code Generation options as grt.tlc (Generic Real-Time Target) to get a .exe file.
Problem with Config 1 is "Packet Input/Output" blocks just aren't setup to compile.
Problem with Config 2 is per this post that I have to somehow relocate the networkdevice.dll file into the same folder as the .exe file but I don't understand how to generate that file. Also I need the "Real-Time Sync" block from the Simulink Desktop Real-Time toolbox to run in real time but when I have that in my model I get a different error: Error: The system target file is set to "grt.tlc". Simulink Desktop Real-Time block 'udp_test/Real-Time Synchronization' requires it to be set to either "sldrt.tlc" or "sldrtert.tlc". Ok but sldrt.tlc does not build to a .exe file...does sldrtert.tlc build to a .exe file?? But sldrtert.tlc requires I pay for the "Embedded Coder" app for Matlab which I don't own...but could purchase if it can create a .exe file??

Antworten (1)

Mahaveer Satra
Mahaveer Satra am 30 Jan. 2025 um 15:29
Hi Brad,
I would recommend using the Simulink Compiler to generate the standalione exe for the above application by making a few minor changes.
Simulink Compiler
Simulink Compiler enables you to share Simulink simulations as standalone executables starting in R2020a. If you require variable-step solvers, or need to deploy the simulation including graphics, an App, or other Simulink semantics not supported for code generation, you should use Simulink Compiler.
Simulink Compiler enables you to build simulation executables by packaging the compiled Simulink model and the MATLAB code to set up, run, and analyze a simulation. The standalone executables can be complete simulation apps that use MATLAB graphics and UIs designed with MATLAB App Designer. Refer to the following example:
Simulink Compiler also allows you to deploy a model to experiment and tune simulation parameters. Refer to the following example:
End users do not need full MATLAB or Simulink installations, they only need to install MATLAB Runtime to run and use the compiled simulation. To install MATLAB Runtime, direct end-users to the following website:
See the Simulink Compiler product page for more information about the product:
Because you are communicating using UDP blocks in your model, I would recommend using the approach mentioned in this post to create the standlone exe from your model: https://www.mathworks.com/matlabcentral/answers/1979839-how-should-i-handle-inputs-and-outputs-for-my-simulink-compiler-model
I hope this helps!

Kategorien

Mehr zu Troubleshooting in Simulink Desktop Real-Time finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by