LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop stop in sub vi from main vi?

Hi! I want to control from my main vi a sub vi consisting of a stepped sine function generator. This sub vi has a for loop. The problem is that I want to have the option of terminating the loop in the sub vi from the main vi. I tryed using global variables or an event stucture. The problem is that, in both cases, the "stop" variable in my main vi is only updated after the loop terminates in the sub vi. Can anyone please help me? Thank you very much.
 
Best regards,
Diogo Montalvão (Lisbon, Portugal)
0 Kudos
Message 1 of 9
(4,119 Views)

Diogo,

Without seeing your code, I am not sure if the following solution will work although I think it should.  The first thing is to replace the for loop in the subVI with a while loop (you can tunnel into and out of a while loop just as well as with a for loop, although this is not the default setting).  The second step would be to create a reference to your Stop conrol in the Main VI and have this wired into the Sub VI. You can create a Property Node for this reference in the SubVI and wire the Value property to the stop icon in the While Loop.  This way, when you press Stop in the Main VI it will also stop execution of your loop in the Sub VI without losing any functionality of your original for loop (except for a bit more software overhead by reading the property node in the while loop)

I hope this helps - I'm sure there are other possible implementations that might also solve your problem equally well.

Message 2 of 9
(4,106 Views)
Hi Diogo,
      This method (attached) works pretty well.
Cheers.
(P.S. I added a polled boolean, per ACEs suggestion - and named the button in his honor.)
 

Message Edited by Dynamik on 09-15-2005 07:31 AM

Message Edited by Dynamik on 09-15-2005 07:33 AM

When they give imbeciles handicap-parking, I won't have so far to walk!
Message 3 of 9
(4,109 Views)
Thank you all for answering.
 
Dynamic, if you read this (i don't know how to contact you), could you please send a print screen of the block diagrams? I am using Labview 7.0... Smiley Sad
 
Thanks again. Best regards,
Diogo Montalvão (Lisbon, Portugal)
0 Kudos
Message 4 of 9
(4,098 Views)

Hi Diogo,

      I saved it in 7.0 (first time) please let me know if it's OK.

Cheers
When they give imbeciles handicap-parking, I won't have so far to walk!
Message 5 of 9
(4,086 Views)

Thank you very much, Dynamik. It is exactly what I need! Now i shall implement it on my vi's. A.C.E was also right when he suggested using the while loop instead of a for loop.

Best regards,

Diogo Montalvão (Lisbon, Portugal)

0 Kudos
Message 6 of 9
(4,080 Views)

Hi,

 

I found this thread very helpful. May I ask one thing - what is the purpose of the Occurrence?? If I try it without implementing the Occurrence (neither in main VI or subVI), labview crashes when the subVI completes its task or is stopped from the mainVI.

 

Thanks for your help!

 

Hong

0 Kudos
Message 7 of 9
(3,420 Views)

occurrence

Regards
Guru (CLA)
0 Kudos
Message 8 of 9
(3,406 Views)

 


hong2011 wrote:

I found this thread very helpful. May I ask one thing - what is the purpose of the Occurrence?? If I try it without implementing the Occurrence (neither in main VI or subVI), labview crashes when the subVI completes its task or is stopped from the mainVI.


A lot of things changed in the last 6 years, so this thread is a bit stale and there are a few other ways to do it. (For example we can have a FOR loop with a conditional terminal).

 

You don't provide enough information to answer your question why it crashes. It would be more interesting to know what you are "using" and not what you are "not using". This is not something we can guess by elimination. 😉

 

LabVIEW should never crash, so please show us the code that crashes so NI can fix it. What LabVIEW version are you using?

 

0 Kudos
Message 9 of 9
(3,401 Views)