Connection between two PCs with Simulink
7 views (last 30 days)
Show older comments
Flavio Cruz
on 25 Nov 2017
Commented: Walter Roberson
on 30 Apr 2021
I am doing a master degree project and it is based on Hardware-in-the-loop (HIL) to a quadrotor model. The difference between common projects I will not use a external hardware (like a board, Arduino), I will use an other computer (PC) to be the hardware and run the controller block of my model. That is, I want run a model in Simulink (PC1) but only the controller block must run in the PC2 and the two PCs has to exchange the informations (inputs and outputs of this controller block).
How can I do it??
Please contact if you nedd further information.
TKS.
0 Comments
Accepted Answer
Mark McBroom
on 26 Nov 2017
The solution depends on whether you need real-time performance. If real-time performance is not needed, then you can run Simulink on the two computers and use the UDP send/receive blocks ( available in the Instrument Control blockset) to send data between the two computers. You will need to configure the UDP Rx blocks to "block" and not execute until data is received. In this way you can keep the execution of the two models synchronized.
If you need real-time performance, then you will need to leave the Simulink environment. The most common workflow is to generate C/C++ code from the two Simulink models using Simulink Coder/Embedded Coder and then compiling/linking the code to run on a system with a real-time operating system. MathWorks sells a turnkey software/hardware solution called Simulink Real-Time and Speedgoat, but you can use any RTOS/hardware combination that has the horsepower to run your C/C++ code in real-time.
Note. If psuedo real-time is acceptable, you can stay in the Simulink environment and use a "pace" block in the two Simulink models that will slow the simulation of both models to ~real-time. The Pace block is available in the Aerospace blockset, but other implementations can be found on MATLAB central.
4 Comments
Walter Roberson
on 30 Apr 2021
You should never use blocking with udp, as udp is an unreliable transport by design. For example it would be considered valid for a udp driver to just drop all packets it has for input or output if the operating system ddecided that it wanted to give priority to polling the mouse.
Walter Roberson
on 30 Apr 2021
Udp is inherently discrete packets of information. You cannot interpolate to send 0.381 packets to meet interpolation tolerances. Therefore you cannot use udp with continuous systems, and needto switch to discrete.
More Answers (0)
See Also
Categories
Find more on Development Computer Setup in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!