04-10-2014 01:18 PM
Hello All. I have a calling sub-vi with a "Start Test" button on the front panel. I passed a control reference for that Start button into a sub-vi that runs in a while loop. The while loop is monitoring that Start button and other things.
Problem: Once the sub-vi runs, it no longer takes updates from that Start button. My program never leaves that while loop in response to my Start button.
Is there some way I can make the sub-vi take an updated value from the calling vi?
Attached is the sub-vi (top level, LabVIEW 2011). Please note that I have already tried putting the Start Test terminal inside the loop, but that did not help. I put comments in the block diagram and the front panel to help identify the problem code.
I am going to get around this problem by running this whole vi through a loop in the calling vi, where I can easily respond to button changes. This is mainly an academic or curiosity problem now.
Thank you, Richard V
Solved! Go to Solution.
04-10-2014 02:00 PM
You should look at the Syncronization pallette and become familiar with the Queue and Notifier constructs. These are very useful for passing data between VI's.
04-10-2014 02:01 PM - edited 04-10-2014 02:04 PM
Lets just whip up a little example then shall we?
The subvi you see contains:
Go ahead and run the top vi. Press OK and watch the value of Value change (up to 20 times per second but that is faster than your eyeball).
Why the difference between this simple example and what you are seeing?
If I had to guess (And, I do since the caller wasn't encluded) I would suspect that you misswired the reference. With that over-burdened connector pane and no required terminals it would be fairly easy to do.
And thats where you might want to ricght-click the vi and deselect view as icon.
You'll find out that its a lot easier to wire the right terminals that way. Also, changing the terminals to "Required" for anything that is as important as an exit condition is a good idea. Perhaps even exit if the reference is null although that should cause an error on the property node. Did you shut off automatic error handling?.... Nope you didn't so there is a valid reference going into the sub-vi. But a reference to what? maybe not the button you think.
04-10-2014 02:11 PM
I would also end the love affair with the stacked sequence structure. She will only cause heartache down the road. 😉
04-10-2014 04:00 PM
@aputman wrote:
You should look at the Syncronization pallette and become familiar with the Queue and Notifier constructs. These are very useful for passing data between VI's.
I actually think this approach is over-complicated for what you had in mind...
04-10-2014 04:06 PM
@billko wrote:
I actually think this approach is over-complicated for what you had in mind...
Actually, I agree now that i have had a chance to see the code. But i think there are other issues.
Are you sure the subVI is running as you stated? I am assuming you push the start button to start the test (duh) so the initial value is TRUE. But a TRUE value stops the loop. So my question is are you sure the subVI is running?
The center while loop really bugs me. I'm not sure what is going on there but there is likely a race condition with the Start Test local variable.
04-10-2014 04:11 PM
@aputman wrote:
@billko wrote:
I actually think this approach is over-complicated for what you had in mind...
Actually, I agree now that i have had a chance to see the code. But i think there are other issues.
Are you sure the subVI is running as you stated? I am assuming you push the start button to start the test (duh) so the initial value is TRUE. But a TRUE value stops the loop. So my question is are you sure the subVI is running?
The center while loop really bugs me. I'm not sure what is going on there but there is likely a race condition with the Start Test local variable.
I was only highlighting it becasue it was accepted as a solution. I actually assumed exactly what you said - that your post was before you were able to obtain all the available data. 🙂
04-10-2014 04:16 PM
What i mean is if your button is set to a latching action, your VI may be reading the value properly from the reference but the local variable is reading it before the control updates so the test never starts.
04-10-2014 04:29 PM - edited 04-10-2014 04:30 PM
@aputman wrote:
What i mean is if your button is set to a latching action, your VI may be reading the value properly from the reference but the local variable is reading it before the control updates so the test never starts.
I was just commenting on the first part of your post above, but I admit that I didn't even notice there was a local variable there (even thought it was right in front of me).
So is the reason for your concern becaus there is no coupling between the control update and the local variable read that enforces data flow?
Err, well I know that using a local variable breaks data flow already... but I hope you know what I mean.
04-11-2014 10:44 AM
No biggie man. I agreed with your comment that it was a little overcomplicated but it would work just fine. I am by no means a LabVIEW expert. Sometimes I get in a rush to type out my answer without thinking things thru fully.
So is the reason for your concern becaus there is no coupling between the control update and the local variable read that enforces data flow?
Yes, that is one of my concerns. I think execution may get stuck in the center while loop depending on the mechanical action of the button in the main VI. If it latches, I could see that the subVI never gets the updated value. But if it is set to switch, I don't see why the OPs code doesn't work.