LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use programmatically generated events?

Dear fellow Engineers!
I need your help again! I have the following problem.

I am designing a VI. I have many while loops executing concurrantly in the same frame. Each while loop has a certain distinct code running within it. Now, when certain conditions are fulfilled, one particular while loop, lets call it W1, terminates its execution. When this happens, I want all the other while loops(W2, W3, W4...,etc) to also stop executing. So, in effect, the 'stop' conditions for all the other while loops depends on the termination of W1.
    
1.  I want to know if I can use the condition that causes W1 to terminate as a 'programmatically generated event', and then use this event to stop all the other while loops through event driven constructs. If yes, how do I go about it?

2. Is there any other better idea or algorithm that will help me realise this.

I await your suggestions and help.
Thanking you,

With warm regards,

Aparna Suchindranath

Student
Uni,Ulm
Germany.
0 Kudos
Message 1 of 10
(4,201 Views)
Shall u post ur code .
 
-Kumar B.
0 Kudos
Message 2 of 10
(4,194 Views)
Hi Aparna,
   I use a very raw method to do this, but it works...

  I use a global variable (or local, ti depends...), which is wired to each STOP symbol of each while loop.  hen W1 has to stop, you can set this global variable to TRUE (I forgave to say it's a boolean variable!), so that it stops all loops.

   Of course, don't forget to initialise this variable to FALSE at the beginning of the program, and to reset it to FALSE after each while loop is stopped.

   Anyway, I'm interested in discovering more elegant ways for accomplishing this task, so feedbacks are wellcome!

graziano
Message 3 of 10
(4,194 Views)

You can have a subVI like this, which will allow each loop to stop all other loops. You just need to place it on the stop wire for each loop.

Look at jpdrolet's post here for a more advanced version (post #3).


___________________
Try to take over the world!
Message 4 of 10
(4,185 Views)
You could use an occurence.

Regards,

Wiebe.
0 Kudos
Message 5 of 10
(4,185 Views)
Thank you all for the helpful suggestions. : )
I would like to know what are 'occurances' and how does one use them in light of the VI I am designing.
 
I await useful insights from all of you,
 
With warm regards,
 
Aparna.
 
Student,
Uni,Ulm,
Germany
0 Kudos
Message 6 of 10
(4,180 Views)
You can find occurences in the Synchronisation>Occurences function palette (or Advanced>Synchronisation>Occurences in 7.1).


An occurence has three parts, Generate Occurence, Wait On Occurence and Set Occurence.


Before all the loops, you use Gererate Occurence. In each loop you use Wait On Occurence, and set the time out to 0, or any time you like your loop to cycle at. To stop all the loops, use Set Occurrence.


I'm not too fond of occurrences. But they are intended for this purpose. Usually, I have all my loops in dynamically started sub vi's that are stopped with user events. But something like tst suggested is also a good solution.


Regards,


Wiebe.
0 Kudos
Message 7 of 10
(4,161 Views)
I would prefer a named notifier to an occurence, because you can obtain it seperately in each VI, but since it seems that in this case the point is just to stop all the loops, I would still go with my original suggestion.

___________________
Try to take over the world!
0 Kudos
Message 8 of 10
(4,160 Views)

If you are concidering using occurences, this Nugget may be helpful. Smiley Happy

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 10
(4,150 Views)

One great method for running many loops with flexability is to create each loop as a state machine and give each loop a queue.  Make one state 'check message' where the loop will read the queue and change use this as the next state.  This will allow for good synchronization between loops.  Yoe can even broadcast by writing to all queues the exit message.  This architecture is easy to miplement, very responsive (checking queues takes almost no time) and scalable.  This might be an overkill if you just want to send a single type of message, but might be worth learning.  The advantage is that the queue can pass different messages (strings are what I use) as well as clusters which can have parameters if needed.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 10 of 10
(4,134 Views)