Filter löschen
Filter löschen

UDP or TCP data send from Simulink Desktop real time to Simulink real time.

16 Ansichten (letzte 30 Tage)
Hi
We have our one simulation running on simulink desktop real time running on the first computer. We want to send&recieve data from Desktop real time simulation to the second computer.
The second computer has attached with speedgoat simulink real time device and also running simulation on the speedgoat.
How this can be achieved using MATLAB?

Antworten (1)

Hassaan
Hassaan am 23 Jan. 2024
To exchange data between two simulations running on different computers with Simulink Desktop Real-Time on one and Speedgoat Simulink Real-Time on the other, you can use various methods. The most common approaches are through TCP/IP, UDP, or a direct I/O connection if the systems are in close proximity.
1. Using TCP/IP or UDP
TCP/IP and UDP are common protocols for network communication. MATLAB and Simulink provide blocks for sending and receiving data over these protocols.
On the Simulink Desktop Real-Time System (Computer 1):
  1. TCP/IP Write Block: Use this block to send data. You need to specify the IP address and port of the receiving Speedgoat system.
  2. TCP/IP Read Block: To receive data from the Speedgoat system.
On the Speedgoat Simulink Real-Time System (Computer 2):
  1. TCP/IP Read Block: Use this block to receive data from the Desktop Real-Time system.
  2. TCP/IP Write Block: To send data to the Desktop Real-Time system.
Configuration: Ensure that both systems are on the same network and configure the IP addresses and ports appropriately. Also, decide on the data format and ensure it's consistent on both sides.
UDP works similarly but is generally faster and less reliable (no error checking or re-transmission of lost packets).
2. Using Direct I/O Connection
If the computers are physically close, you can use a direct connection (e.g., via an Ethernet cable) for data transfer. This might involve using specific I/O blocks compatible with your hardware setup.
3. MATLAB Function Blocks
You can also use MATLAB function blocks to write custom scripts for data transmission using TCP/IP or UDP within Simulink.
Steps to Implement:
  1. Design Your Simulink Models: Create your models on both systems with appropriate blocks for sending and receiving data.
  2. Set Up Network Configuration: Make sure both systems are correctly configured for network communication, with static IP addresses if necessary.
  3. Test the Connection: Before running the real-time simulations, test the connection using simple data packets to ensure data is correctly sent and received.
  4. Run Simulations: Start the simulations on both systems and monitor the data exchange.
  5. Troubleshoot: If you encounter issues, check for common problems like firewall restrictions, incorrect IP addresses or port numbers, and network hardware issues.
Additional Considerations:
  • Latency and Bandwidth: Especially important for real-time systems. Test the system under the expected load to ensure that it meets your real-time requirements.
  • Synchronization: Ensure that both systems are properly synchronized if your application requires tightly coupled data exchange.
  • Security: Be mindful of security implications, especially when sending data over a network.
For specific implementations, refer to the MATLAB and Simulink documentation for detailed instructions on using TCP/IP, UDP, and custom MATLAB function blocks within Simulink models.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Community Treasure Hunt

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

Start Hunting!

Translated by