LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to send data every second in UDP

Hi,
 
I have inherited a LabVIEW app that I need to modify to output 5 values onto a LAN once a second.
 
I have written the code into a UDP packet and I've set up a multicast send. This works fine and sends every 1000ms. However, to do this, a loop is entered and then waits the 1000ms and then sends. This causes the rest of the application to wait until the loop is finished until it can carry on. This results in the app becoming very 'glitchy'. Is there a way that I can just send every 1000ms, without using the wait?
 
Thanks,
 
Steve Smith
0 Kudos
Message 1 of 8
(2,999 Views)
Hi steve66,
one solution is to use a parallel loop to send the UDP data, and another solution is to set the wait to 100 or 10 and count the loop iterations. So that you send your data only every 10/100 loop.
 
Hope it helps.
Mike
0 Kudos
Message 2 of 8
(2,996 Views)
I take it, that if I want to use an iteration count, I would need to use a shift register to remember values between iterations. If this is so, how do I set up the shift register. Also, what should the n value be set to. I'm guessing 1?
0 Kudos
Message 3 of 8
(2,965 Views)
Hi steve66,
i´m not sure if in your case a for loop is the right selection. Use a while loop. Right click on the border a select create shift register. To initialize the shift register connect a constant to it.
 
Mike
0 Kudos
Message 4 of 8
(2,961 Views)
hi

to use a loop and count the iterations, with and without shift registers, you can see the attached image. i am sure if that is what you wanted to do.

but, to send data on udp after every 1 sec, without making your other actions wait, you can do this:

have a case structure. check if the delay of 1 second is complete.if yes, go to the case where data is sent on udp, execute it.
if the delay time is not complete, go to a case where you want to perform other functions.

have the loop check for 'delay over?' before every iteration.

i hope you got my point.
0 Kudos
Message 5 of 8
(2,958 Views)

Hi MScap,

for this example i would use a for loop now, after this.
http://forums.ni.com/ni/board/message?board.id=BreakPoint&view=by_date_ascending&message.id=4981#M49...

Smiley Happy

 

Mike

0 Kudos
Message 6 of 8
(2,951 Views)

Thanks for the help guys, I think I understand. I have tried to implement with a for loop and a while loop and have run into the same problem. Namely, how do I reset my count to zero. I need to output my UDP packet every second.

I tried to use a seperate while loop that will run only when i reach my 100 count, to initialize my registers to zero. but this didn't work!

I have then tried to nest a case structure into my loop so it will set the register back to 0 when i reach 100. This fails as it says I am creating a feedback loop !!! I'm stuck once again.

0 Kudos
Message 7 of 8
(2,932 Views)
Hi Steve S,
see the attached example.
 
 
Mike


Message Edited by MikeS81 on 06-02-2008 03:51 PM
0 Kudos
Message 8 of 8
(2,927 Views)