LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stopping a loop

Hi,

 

How do I stop a while loop that collects data from a home made instrument. I don't know how many bytes of data it is collecting. I want to repeat this loop n times but have to stop it after each cycle. Your help is appreciated. 

 

thanks

sbz

0 Kudos
Message 1 of 14
(3,837 Views)

While loop.  you stop them on a condition.  what type of condition do you want to stop on?

Message Edited by Jeff Bohrer on 05-19-2010 07:06 PM

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 14
(3,831 Views)

after collecting data i want to stop it but it's not a constant data coming back(each time might change) so i need sth to listen to it when data collection stops. Can't find any UDP listen function. 

0 Kudos
Message 3 of 14
(3,820 Views)

You are not explaining yourself very well.  Does your data come back in a burst, then no more data comes?  You could use a timer to stop after a certain time with no data being received.  Start timer.  If data is receive, reset timer.  If no data, check timer.  Do this until timer expires, then stop the loop.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 14
(3,770 Views)

Hi sbz,

 

UDP is not a protocol that "listens" in the sense that it will wait until bits appear or uses any handshaking. For that type of scheme you may have to move to TCP. I'm not sure a bit confused if the issue you're encountering involves network communication or loop condition. Please let us know how we can help.

Verne D. // Software R&D // National Instruments
0 Kudos
Message 5 of 14
(3,760 Views)

Hi sbz,

 

If I understand you correctly, you want to pause at the end of each iteration to check that data has come in on a UDP port.

 

 I am by no means an expert on this, but Labview does have some UDP functionality which might be what you need. The UDP Read function will wait for data until a specified timeout.

 

To find the UDP functions, go to Functions->Data Communication->Protocols->UDP or on the Functions palette, search for UDP.

 

These pages have more information:

 

http://zone.ni.com/devzone/cda/tut/p/id/4950

http://zone.ni.com/reference/en-XX/help/371361B-01/TOC28.htm 

 

Hope this helps.

0 Kudos
Message 6 of 14
(3,753 Views)

Thanks to all for replying. The data comes in burst and then stops. I have to press the stop button manually and then the next iteration will start. I don't want it to be manually.

 

thanks

sbz 

0 Kudos
Message 7 of 14
(3,746 Views)

Use a timer as I had described in my earlier post.  After 1 or 2 seconds of no data, stop the loop.  Do you need sample code to do this?  Can you try to code something yourself?

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 14
(3,738 Views)

I've never used a timer. will try to figure it out.

 

thanks 

0 Kudos
Message 9 of 14
(3,735 Views)

Here is an example:

 

ElapsedTime.png

 

- tbob

Inventor of the WORM Global
Message 10 of 14
(3,725 Views)