MATLAB: Have you ever noticed an increasing delay while UDP protocol send/receive packets

udp xpc real-time closed loop

Dear matlab users, I'll be thankful for the answer on the following question. Have you ever noticed an increasing delay while UDP protcol send/receive packets? It seems, that latency is going on and on during the time. I've worked with xPC real-time windows target in simulink in the external mode. I've made a closed-loop system where the embedded system receives assignment via UDP to drive a motor and sends encoder data to simulink. For example, if I send sinusoidal signal to the object with 1 ms and then send it back to the host, I will see an increasing error at the host side if I subtract the received signal from the sent signal. It seems to me that matlab puts received packets in the queue and takes it one by one with 1 ms. The delay is really increase: closed loop system is stable in the beginning of simulation and during the time it is getting more and more unstable. So, maybe there are some method to purge this queue and receive actual data? I'll be thankful for any information Host: PC Windows 7 Remote PC: Arm Cortex M3

Best Answer

From the image of the model, you are using blocks from the product "Real-Time Windows target (RTWT)". I am not too familiar with it and recommend you contact tech support but here are my thoughts:
1. The Real-Time synchronization block is used to synchronize a normal mode simulation to the real time clock. So if you are running in external mode then perhaps this block is not required. Try the experiment without this block.
2. I also feel you should try a loop back test. Get rid of the embedded system from the loop and make the Packet output block send the packets to the Packet Input blocks. If the delay goes away, then the issue is with the embedded system. If the issue remains then perhaps RTWT is behaving differently, in which case please contact tech support.
I will have no further inputs on this.