08-18-2010 04:19 PM
Is there a way for a front panel control that is not in a loop to pass a value into a while loop? Basically I have a program that will have multiple loops and I would like the ability to stop the program from outside the loops with one singular button that will work on any loop while the loop is still running.
A very simple diagram of what I would like to do is attached. I realize that the attached VI will not perform what I would like it to, but it demonstrates what I would like to accomplish.
Thanks!
Justin
08-18-2010 04:24 PM
I wasn't able to look at the example. Have you tried "or"ing in a control via use of local variables?
I'll make an example if that isn't enough.
08-18-2010 04:32 PM
Thanks for the suggestion.
Local variables will work, as long as the mechanical action of the button is not latching, if there is no other way, I will use this solution, but I was hoping for something that will allow me to keep the latching functionality of the button.
Thanks!
Justin
08-18-2010 04:34 PM
This example uses "latch on release" mechanical latching option.
08-18-2010 04:34 PM
please see: Producer-Consumer architecture on these forums.
08-18-2010 04:45 PM - edited 08-18-2010 04:48 PM
You could use a Notifier. In the following example, I used an event structure to capture the stop button event. When the stop button is pressed, set the notifier True. In the Timeout case, set the notifier to False. The timeout is needed so that the 2nd loop doesn't sit there waiting for a notifier. It will execute at the same speed as the timeout value.
This is a simplified producer-consumer architecture.
08-18-2010 04:47 PM
@Drewski wrote:
This example uses "latch on release" mechanical latching option.
Look again. The stop button uses Switched When Released. It even says so on the front panel. The disadvantage of this is that you have to set the stop button back to false either at the end of the program or at the beginning.
08-18-2010 04:51 PM
Oh yeah, switch on release. Yep, there are trade offs to all the possible ways of implementing the desired funtionality.
I guess the simple answer to the OP is, "Yes."
08-18-2010 04:55 PM
Yes the local variable will work (and I've used it) for stopping a loop from other locations. It does have the pitfall of not being able to extend to multiple loops if it is a latching boolean. The reason is pretty obvious if you think like a latching boolean. "The first time I'm read I'll go back to my default" so the value gets read once and changes state back to the original so it stops one loop and one loop only.
A more robust means would be to use queues and for---- sugessted. Look in the labview examples under queues for some great pointers on how to implement a Producer Consumer loop. you really are speaking of issueing a "command" to control the state of an independant loop so many synchonizatio methods are good starting points. Notifiers, Queues, or dynamic events are all possibilities for passing information into a loop (or even other sub-vis)
08-18-2010 05:55 PM - edited 08-18-2010 05:57 PM
Here's an example of why locals can be bad just due to having to reset the value....sometimes this VI stops...sometimes it doesn't...
Edit: shoudl have used the Code Capture tool instead...