LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delay with STM using UDP communication

I'm currently communicating between two computers and sending 4 different types of information between them. From the host (1d array "Position" and a U32 integer "Buffer") and from the client (1d array of position difference "Feedback" and Boolean element "Stop"). I get about 4k loop hertz from Host and 10k loop hertz with no noticeable delay. However, when I introduce a wait function to limit the loop frequency to about 500 Hz, there is a noticeable delay that grows for position and feedback.

I'm trying to figure out what is causing it. Is there a built-in buffer for UDP or is the program looping a few times before getting the transmitted data? When I turn off the delay it still sends data at a delay but fixes itself over time.

The code I'm submitted is modified because the original is using unique libraries that allow communication with a haptic feedback controller to sample position data and give force instructions. I've replaced these with front panel inputs and outputs in order to replicate it. I've tested and was able to replicate the issue. 

Download All
0 Kudos
Message 1 of 4
(1,546 Views)

Update:

I've added inputs for the STM UDP READ and Write and set them to 5ms. After creating the input for STM UDP WRITE and setting it both read and write to 50ms timeout it seems like the issue is fixed. I'm still a bit confused how labview implements UDP read and write during loops when there are multiple writes and reads are implemented.

I've tried to integrate video from the client to the host but get a similar delay probably due to the fact that the video feed fixes the loop frequency to 30 hz. Creating a separate loop and UDP port for both the Host and Client specifically for the video feed seems to work.

0 Kudos
Message 2 of 4
(1,427 Views)

LabVIEW is dataflow driven. As long as there is no wire dependency, LabVIEW will happily execute most of its functions in parallel. That includes network functions. But before a loop can go to its next iteration every node inside the loop needs to have finished execution. This means that the iteration interval will be limited to the slowest execution path in it. Other functions inside the loop even if they only take a fraction of that time will still be executed with the same interval. If you have operations that need to operate at different loop rates you have to use multiple loops and if you need to pass data between the loops you need to use queues, events, notifiers or other similar methods.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(1,420 Views)

How does udp communication work in this instance? When I set it to 5 ms timeout my loops are faster (I have a Loop Rate Calculator in both programs) but I get a delay that grows to multisecond. Does UDP have a built-in buffer somewhere because it behaves like there's values in buffer that are waiting for the consumer to pull. It's not like I get a value sent in intervals it looks continuous.

I noticed that I only get these kinds of issues when the time for loop execution is nearing the timeout value. When I increase the timeout value it either runs from start fine or if it's running it'll slowly fix itself.

0 Kudos
Message 4 of 4
(1,388 Views)