07-03-2013 04:38 AM
Hi All:
I add two controls on front panel, a "single" button, and a "continuous " one.
When "single" is pressed, the sub VI will execute only once.
But when "continuous" is pressed, the sub VI will execute continously.
I think I can use a while event structure , which captures the button events,
for "single button clicked event ", I just put sub VI into the diagram.
For "continuous" condition, I will circle the sub VI with a while loop, inside the event diagram.
But now the problem is : how should I wire the stop button for this while loop?
I think it should stop as soon as "single " button clicked, because now I am going to switch to "single" state.
Maybe I should wire the single button to the stop button?
Do you have other solutions?
Any suggestions will be greatly appreciated. Many thanks.
Solved! Go to Solution.
07-03-2013 04:51 AM
can post your vi or the snippet of what you are doing
07-03-2013 05:12 AM
without seeing what you have got. remember a while loop always executes at least once. use you single/continuous boolean control wired straight to the stop terminal of the while loop.
As asked for though will be easier to answer if we can see the code
hope it helps though
07-03-2013 05:20 AM
Hi Julia,
Please have a look on this VI.
I think this will resolve your query.
07-03-2013 05:46 AM
@Julia2013 wrote:
I add two controls on front panel, a "single" button, and a "continuous " one.
Any suggestions will be greatly appreciated. Many thanks.
Why to add two controls, rather keep single 'Toggle' switch:
07-03-2013 05:50 AM
i was suggesting link this mode control to the stop in the while loop
07-04-2013 01:44 AM
Hi All:
I am really grateful to so many people helping! Thank you all. I will give kudos as I look into more details.:)
Attached are two VIs. subVI is "LED blink once.vi"
I want to make the LED blink once, when single button is clicked.
And it blinks continously when continuous button clicked.
For the continuous event, I use one more while -event structure,
where I put the subVI inside its "timeout" event, while pass "true" to stop this while loop inside "single mouse down" event.
But the VI runs with problems.
As soon as it run, after I clicked the "single" button once, I can no more click on any other buttons such as continous or stop!
The same problems with the other two buttons.
Seems I can only click on one button as soon as it starts to run, all other buttons failed to respond.
Why ?
07-04-2013 06:45 AM
First of all, I highly recommend using the Value Change event instead of the Mouse Down.
Secondly, you shouldn't have an event structure inside of an event structure. In general, you should have 1 event structure in a VI. The reason is because there are many caveats of the event structure, and just using 1 of them alleviates most of those.
What you really want here is a version of the Master/Slave architecture. You have 1 loop for handling the events and another loop to control your blinking. You can use a notifier to communicate between the loops.