From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple UDP receivers in one vi?

Solved!
Go to solution

Hello again,

 

I use multiple UDP receivers on the PC host to receive from multiple ports. Then I have multiple vis on a cRIO, each one has one UDP senders. I am planning to sometimes use one or two UDP senders. But if one UDP sender is not sending, all UDP receivers stop working, not just the one without sender. What can I do? Everything works fine, when all UDP senders are working.

 

Thanks!

0 Kudos
Message 1 of 15
(3,618 Views)

Hi Steffen,

 

What can I do?

At first you could attach your VIs (or the whole project) to demonstrate your problem…

(There is something wrong with your VI but you aren't willing to show that VI?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(3,587 Views)

Hi Gerd,

 

I guess I found it. If I set the timeout of the UDP read vi to something more than the UDP sender loop time, its working. Timeout was set to infinite(-1).

Lets say, the sender vi on the cRIO sends every 500ms, then I set the UDP read to 550 ms and its all good. If its less than 500ms, the read value appears and goes back to 0.

Reading temperatures from a NI 9217 for instance.

 

Cheers,

 

Steffen

0 Kudos
Message 3 of 15
(3,584 Views)

Hi Steffen,

 

If its less than 500ms, the read value appears and goes back to 0.

You better handle the timeout error of the UDPRead function!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(3,581 Views)

Hi Gerd,

 

here the UDP receiver vis, not much in there.

 

Cheers,

 

Steffen


@GerdW
Download All
0 Kudos
Message 5 of 15
(3,553 Views)

Hi Steffen,

 

your "udp receiver" is missing a subVI. (Did you rename that subVI before uploading? In case you did: WHY did you do that?)

 

I used that 2nd "subVI" as a replacement for the missing subVI (even though it seems to call itself right now):

- Why don't you use autocleanup?

- Why do you use a single loop to handle 3 different devices in parallel? Use 3 loops in parallel!

- Why is this subVI NOT set to invariant? Right now the 3 instances of this subVI will NEVER run in parallel!

- Why is there a wait function in your loop? You already use the timeout input of the UDPRead function to let the loop wait for UDP messages!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(3,544 Views)

Hi Gerd,

 

this would be the missing vi

Have to think about that timeout. If its too short, it may miss the next value. Wouldn't the loop continue, if the timeout is longer than the loop time?

Reg. Cleanup, this is just a test vi

 

Cheers,

 

Steffen

0 Kudos
Message 7 of 15
(3,539 Views)

Hi Steffen,

 

If its too short, it may miss the next value.

Yes. But you get an error to recognize/handle this issue…

 

Wouldn't the loop continue, if the timeout is longer than the loop time?

Yes, the loop would continue - once UDPRead received a message OR the timeout occurs…

The point is: you don't need an additional wait in the loop with a reasonable timeout! The loop will iterate when a new message is received OR after the timeout occured…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 15
(3,537 Views)

ok, wait until next ms set to 1000 in sender and receiver, timeout to 150ms, works. If I set timeout to say 3000 the loop indeed is waiting 7-8 s, because 3 out of 5 receivers don't get data

0 Kudos
Message 9 of 15
(3,532 Views)

Hi Steffen,

 

the receiver should have NO additional wait in the loop!

Here I would just set a timeout of 1100ms as your sender will send a message each 1000ms…

 

If I set timeout to say 3000 the loop indeed is waiting 7-8 s, because 3 out of 5 receivers don't get data

AND BECAUSE your subVIs aren't set to invariant!

(If that would be the case your loop would wait just 3s instead of 7-8s…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 15
(3,529 Views)