Discussion:
Break a while loop when an inside VI has a time out
(too old to reply)
LostInHelp
2008-08-08 11:40:06 UTC
Permalink
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 


stop.vi:
http://forums.ni.com/attachments/ni/170/347826/1/stop.vi
MikeS81
2008-08-08 12:10:05 UTC
Permalink
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


stop_queue_LV80.vi:
http://forums.ni.com/attachments/ni/170/347827/1/stop_queue_LV80.vi
LostInHelp
2008-08-11 07:40:06 UTC
Permalink
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


stop.vi:
http://forums.ni.com/attachments/ni/170/348154/1/stop.vi
MikeS81
2008-08-11 07:40:08 UTC
Permalink
Hi LIH,
this works for me.
Mike


stop_DAQ.PNG:
Loading Image...
LostInHelp
2008-08-11 08:10:06 UTC
Permalink
Hello,
 
I've made a small adjustment and it worked.
 
Thank you very much.
 
LIH
mathan
2008-08-11 08:40:04 UTC
Permalink
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
LostInHelp
2008-08-11 09:10:15 UTC
Permalink
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.
mathan
2008-08-11 13:40:06 UTC
Permalink
Thanks for sharing..... Catch my (first for you) five stars. :smileywink:




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

Lol :smileyvery-happy:
Message Edited by mathan on 08-11-2008 08:18 AM

Continue reading on narkive:
Loading...