LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a while loop with array outside

Solved!
Go to solution

Hi,

 

I have a problem to stop running a vi which uses a while loop and outside an array with two values of intervals of time. I would like to stop the VI when the different values in the array are elapsed. I attached here the code if you like to help me please I thank you in advance.

0 Kudos
Message 1 of 57
(5,102 Views)
If I understand correctly your application, I'd use a for loop instead, executing n times (obtain n with the "array size" function), activating indexing where the array enters the for loop, and timing with the "wait (ms)" function.
0 Kudos
Message 2 of 57
(5,087 Views)

You have a units problem. You seem to be specifying the time intervals in milliseconds (at least I think they're milliseconds), and then dividing by 1000. That makes them microseconds. You are then comparing to a difference calculation which is in milliseconds. I think you want to specify the time intervals in seconds, and multiply by 1000 to get milliseconds. Also, watch your coercion dots. The constant of 2 should have a representation of I32.

 

A better solution would be to use the Elapsed Time function. 

0 Kudos
Message 3 of 57
(5,080 Views)

"I would like to stop the VI when the different values in the array are elapsed"

 

It is not clear to me, what you want.

 

Does this help ?

0 Kudos
Message 4 of 57
(5,078 Views)
I want to make a criterion to stop the Vi when the two values in the array are elapsed so here the Vi would stop after 2 seconds.
0 Kudos
Message 5 of 57
(5,062 Views)

As xdaf mentioned, all you really need to do is this:

 

If there is a reason to make it any more complicated, please explain why or should we just post your program to the Rube Goldberg thread?

Message Edited by Dennis Knutson on 11-21-2008 08:46 AM
0 Kudos
Message 6 of 57
(5,055 Views)
Thank you very much all for your quick help.
0 Kudos
Message 7 of 57
(5,044 Views)
There is one caveat that you should be mindful of. When I looked at your time values it seemed as if you were wanting to wait for long periods of time. The simple implementation provided by Dennis will have the effect of not allowing you to stop the program when it's waiting unless you press the Abort button in the toolbar. My presumption was that you wanted to be in a loop waiting and be able to stop at any time. Of course, that was my presumption. I'm not really sure what your overall goal is.
0 Kudos
Message 8 of 57
(5,002 Views)
Yes I would like to stop after all the values from the array pass the while loop.
0 Kudos
Message 9 of 57
(4,996 Views)
I'm sorry, I don't understand what you mean by that. Do you understand how the example provided by Dennis works? What does it not do that you need to do?
0 Kudos
Message 10 of 57
(4,961 Views)