LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curious Loop Behavoir

Solved!
Go to solution
I know I'm going to get schooled on this curious loop behavior but felt like posting.  The desired behavior of Fred 2.vi is to interrupt an existing ms delay in Delayed Fred.vi to allow for faster exit of a sub-routine once STOP is pushed.  I'm guessing this can be done a number of way possible the quickest with an event routine checking for stop, but I honestly don't know. I decided to show a guy how to do it with a simple conditional for routine but to my surprise it doesn't work.  Then I convinced myself that the TRUE variable is local to the function and should not update.   What is the correct way to do this and why doesn’t the way I did it work? J   I need some feedback since I honestly don't know what is wrong. Regards, -SS

 

 

Message Edited by ShotSimon on 03-02-2010 03:34 PM


Download All
0 Kudos
Message 1 of 12
(3,666 Views)

The stop boolean is not being polled, so the loop is not going to stop from a user input.  Not sure is that the problem or not.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Message 2 of 12
(3,660 Views)
Delay Fred reads the incoming Boolean once and keeps the value, thus never changing. Thus no interrupt.
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 12
(3,653 Views)
Sorry I pulled out the boolean during testing, but if you put it inside it doesn't change operation for me?  I reposted the vi above since I was under the 15min edit window.  -SS


0 Kudos
Message 4 of 12
(3,646 Views)
Solution
Accepted by topic author ShotSimon

Classic dataflow problem. When you run Fred_2 the values of its front panel controls are passed to the subVI. Changing these while the subVI is running does absolutely nothing to the subVI. Furthermore, while the subVI is running, the Stop button on its front panel is only read when it starts. While the for-loop in the subVI is running it is using the value from when the loop first started since it's being tunneled in.

 

If you want the loop inside the subVI to stop based on a stop condition of a Stop button on the front panel of the main VI then you need to pass a reference to the top VI's Stop button to the subVI. Inside the subVI's for-loop use the Value property to read the state of the top-level VI's Stop button. Note that you will need to change the latching action in order to be able to read the value.

Message 5 of 12
(3,642 Views)
Pass a reference to the boolean in your higher level VI to the subVI.  Instead of the stop button in your subVI (which can't change because the subVI's front panel doesn't open) you will read the value of the reference to the stop control passed in.
Message 6 of 12
(3,635 Views)
Yeah I knew it was a classic.  I guess I'm surprised that I always managed to avoid this issue. Thanks guys. -SS


0 Kudos
Message 7 of 12
(3,630 Views)

OK it's not solved sorry:)  I tried to create a reference and llink it to the from panel and I get a conflict between strict and regular boolean reference.

 

How do I make a happy connection here, please see attached.

 

Regards,

 

-SS

Message Edited by ShotSimon on 03-02-2010 04:34 PM


Download All
0 Kudos
Message 8 of 12
(3,593 Views)
You didn't change the mechanical action of the Boolean like I said in my last sentence of my reply. You need to use one of the "switch" actions.
0 Kudos
Message 9 of 12
(3,579 Views)

smercurio_fc ,

 

Sorry you'll have to forgive me.  At the time I didn't see how editing the front panel would help make the reference a different type.

 

I guess my little LabVIEW world was turned upside down learning that in all these years I never had to use a reference, like this:)

 

I guess I should share with other that to place a reference you have find it in the library and then set it by right clicking and chosing:

VI Server Reference -> Generic -> GObject -> Control -> Boolean

 

You also have to make sure include data type is selected on the front panel control.  The working updated vi is attached.

 

Regards,

 

-SS



0 Kudos
Message 10 of 12
(3,536 Views)