LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Break a while loop when an inside VI has a time out

Hello,
 
I have inside of a While loop a VI that is waiting for something. In my example is an Dequeue element VI that has the timeout set to 20sec.
I want to Stop/Break/Get out from the loop when I'm pressing a Stop Button. I don't want to wait until I get the time out error.
 
The VI that is waiting for something can be anything: an Read Line/Counter from DAQmx, Dequeue, Enqueue.
 
Thanks,
LIH 
0 Kudos
Message 1 of 8
(4,973 Views)

Hi LIH,

it´s not possible like you do it. Use a parallel loop with an event case. Create a stop value change event there and destroy the queue refnum. If the queue refnum is invalid the dequeue block will stop waiting and generate an error. You can close the loop with the dequeue element in it, if you connect the error cluster to the loop stop condition.

See the attached examplel please.

Hope it helps.
Mike

Message 2 of 8
(4,970 Views)

Hello Mike,

Thanks for your replay. That solved the problem with the Queue.

I still have the same problem with DAQmx blocks. For example I want to measure the period and I'm using a DAQmx Read Counter VI. I've tried to Clear the Task in order to force the Reading VI to generate an error, but it didn't work.

 

Thanks,

LIH

0 Kudos
Message 3 of 8
(4,928 Views)

Hi LIH,

this works for me.

Mike

Message 4 of 8
(4,924 Views)
Hello,
 
I've made a small adjustment and it worked.
 
Thank you very much.
 
LIH
0 Kudos
Message 5 of 8
(4,919 Views)

LostInHelp wrote:
I've made a small adjustment and it worked.

Could you please share that adjustment, so that anybody looking at this thread will get knowledge about that.
 
Thanks,
Mathan
Message 6 of 8
(4,912 Views)
Hello,
 
unfortunately I celebrated the "victory" to early.
I have a separate board, from which the signals are going into the DAQ board. The supply for this board can be turn on/off from a digital output. In the Events structure I've inserted the part with turning off this board (this was the adjustment). When this bord is turning off, the signals from the input of the DAQ board are changing. If the signals are changing, the DAQ read counter notice that and it will "jump" over the timeout. It worked because the number of samples to be read was set to 10 . But if I set it to 1000 it's not working anymore (by turning off the power there won't be 1000 values to be read). I hope this explanation was not very confusing.
 
The example that worked for you (the one from the png file) works also for me, but only after the signals from the counter input are changing. If at the counter input the signal is only "1" or only "0" the VI gets stuck in the Counter Read Block, until timeout.
 
 
Regads,
LIH
 
PS: I'm a beginner in DAQmx and it is also hard for me to explain all this suff in English.
Message 7 of 8
(4,899 Views)

Thanks for sharing..... Catch my (first for you) five stars. Smiley Wink


LostInHelp wrote:
PS: I'm a beginner in DAQmx and it is also hard for me to explain all this suff in English.

Lol Smiley Very Happy


Message Edited by mathan on 08-11-2008 08:18 AM
0 Kudos
Message 8 of 8
(4,872 Views)