LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping while loops running in parallel with a single boolean without using local variables

Hi All,

 

I made a Vi ,which stops Two while loops running in parallel  with a single boolean without using local variables.

I thought this vi will be useful to other members also,So uploading it.

Check it up and let me know if u find any other better way of performing the same operation.

 

Regards,

Venky

0 Kudos
Message 1 of 12
(5,456 Views)
Could you post a screen shot of the block diagram?  I dont have access to LabVIEW at the moment.
0 Kudos
Message 2 of 12
(5,452 Views)

Hi Jmcbee,

 

Check out this Screenshot.jpg

 

 

Regards,

Venky

0 Kudos
Message 3 of 12
(5,446 Views)
You should look into using queues or notifiers to transfer data between parallel loops.  An Action Engine would also do the job nicely here.  Using the property node works but it is not a whole lot better than using a Local Variable as it still forces a front panel update.
Message Edited by jmcbee on 03-12-2009 05:06 PM
Message 4 of 12
(5,434 Views)

This is a simple way to do it with a Notifier.  A side benefit is that the first loop times the second.

Message Edited by jcarmody on 03-12-2009 08:13 PM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 5 of 12
(5,407 Views)
VENKATESH… ,

Such two-loop structure is not reliable. If the upper loop reads the STOP control first, the bottom loop does not stop. To test, increase the constant in the bottom loop (f.ex. to 1000 ms).

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 6 of 12
(5,379 Views)
In this case VENKATESH can use a switch action (instead of latch), although it is ugly.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 12
(5,369 Views)
jcarmody, yes, but use a switch action means more code to reset button (to default false).
_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 8 of 12
(5,353 Views)

_Y_ wrote:
VENKATESH… ,

Such two-loop structure is not reliable. If the upper loop reads the STOP control first, the bottom loop does not stop. To test, increase the constant in the bottom loop (f.ex. to 1000 ms).


_Y_

 

Only if you kill the Queue <BEFORE> the bottom loop reads from the queue.

Although you click stop and it will stop the loop, it will still enqueue the True value, which is then read from the bottom loop.

 

A trick is to kill the queue at the exit of the bottom loop.

 

I like Jim's solution.  It is missing the kill queue reference, which can be implemented in 2 ways.  After the bottom while loop, or after the top loop if there is additional delay outside the loop to take in consideration the amount of time to guarantee that the bottom loop reads the last queue element.

 

OR (better yet)  Jim's implementation, with the kill queue immediately after the top loop and the add an OR statement in the bottomwhile loop that connects the status of the error cluster which should return an error if it tries to read the queue after the queue has been killed.

 

R

Message 9 of 12
(5,339 Views)

The design pattern templates NI provides use the error wire from the Dequeue Element function to stop the bottom loop.  Doing that lets me use the Notifier to pass any data type (doesn't need to be boolean) to the bottom loop, or not pass anything at all (just use it to stop the loop).  Queues would work just as well.

 

Message Edited by jcarmody on 03-13-2009 07:29 AM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 12
(5,330 Views)