- Use a clock source that is common to both models, you can use System Clock block to generate the clock signal and use it as a trigger for both models. https://in.mathworks.com/help/simulink/ref_extras/clock.html
- You can also use a buffer block in simulink to store the signals produced by Simulink 1 before sending it to Simulink 2.https://in.mathworks.com/help/dsp/ref/buffer.html
UDP communication issue between two Simulink models on a single machine
3 次查看(过去 30 天)
显示 更早的评论
Hi,
Currently, I am working on a project that requires to execute two simulink models on a single machine; let's name them Simulink 1 and Simulink 2. Simulink 1 sends signals to Simulink 2 through UDP Send/Receive of DSP System Toolbox. The tricky part of this project is Simulink 1 runs in non-real time, but Simulink 2 runs in real-time.
To test the UDP communication, I sent sine wave from Simulink 1 to Simulink 2. The attached image shows the sine wave in Simulink 1, the plot at the top, and Simulink 2, the bottom one. Since the two Simulink models run in different time scale, the plots does not match in x-axis. The issue is that the received sine wave is not smooth. It seems like Simulink 2 repeats receiving and stopping to receive signals periodically. I guess this is because time is not synchronized between the two models, but I cannot explain it reason clearly.
I would appreciate it if someone could explain what couses this issue and give me some soggestions to solve it.
Best,
0 个评论
回答(1 个)
Sai Kiran
2023-3-10
Hi,
As per my understanding you are facing this issue due to asynchronous execution of two Simulink models. Simulink 1 runs in non-real time and Simulink 2 runs in real-time, which means that Simulink 1 may produce signals at a different rate than the Simulink 2 can consume them, leading to loss of data.
To solve this issue you have to ensure that the two models are synchronized.
This can be achieved in a couple of ways:-
I hope it helps!
Thanks!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with DSP System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!