02-17-2006 01:39 AM
02-17-2006 01:54 AM
First, I'd say you just have to many nested loops.
Second, you have local variables of the outermost loops stopbutton inside the nested loops. The problem is, that your main stop button is just read during its first iteration - afterwards the inner loops are running and as the main stop button can not be read, the vi won't stop.
I'd suggest you to copy this vi, delete all operations from the loops (just leave a wait function in) and run the vi in highlighting mode and look what happens.
Thomas
02-17-2006 02:54 AM
02-17-2006 03:34 AM
02-17-2006 04:29 AM
02-17-2006 07:08 PM
02-18-2006 12:37 AM
Hi Bong,
I'll chime in on this one. The local variable is initialized outside the loops so that it will always start off in a known state...in other words, if it wasn't initialized, there's a chance its state would be True on the next run of the VI, causing the loops to stop immediately on their first iteration. Technically, the code isn't quite correct right now, because there is no data dependency between the initialization of the boolean and the loops themselves...there is the possibility that a race condition could occur if the loops started executing before the local variable was written to. To be correct, that local variable should be initialized in a sequence frame, and the wire should exit the frame and go into the loop border, ensuring the local gets initialized before the loops start.
As for your other question, the local variable is used to check the stop condition in the loop simply because the boolean's terminal is already being used elsewhere (specifically, in the Event Structure).
Hope this helps,
-D
02-20-2006 12:46 AM
02-21-2006 02:00 AM
Darren and Thomas,
Thank you very much for response. I understood your replies.
"To be correct, that local variable should be initialized in a sequence frame, and the wire should exit the frame and go into the loop border, ensuring the local gets initialized before the loops start."
When you say sequence frame, is it an another event structure? If its not asking too much, can you please teach me how can I make the initialization in a sequence frame using VI. This is for my future reference too. Thank you very much.
02-21-2006 02:47 AM - edited 02-21-2006 02:47 AM
No, the sequence-structure has nothing to do with the event-structure.
In the picture you can see it - in such a structure, each case is executed after the other.
Message Edited by becktho on 02-21-2006 09:47 AM