LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make loop count wait

I have a main VI that runs 8 sub-VI. The user input the tests that they want done in a listbox. The listbox is indexed, and the program runs the tests that are listed in the listbox. When the sub-VI is called, the user still has control over the main VI (the user is able to scroll up and down in a listbox to see the test result clusters). I have a while loop that index the listbox. I need each test to be done until the next test is executed. When I use the while loop index, the tests run parallelly. Thanks
0 Kudos
Message 1 of 5
(2,937 Views)
If you have the sub-VIs in separate cases and each sub-VI has Error In/Error Out clusters, add a shift register to your while loop. In each case, wire the left shift register to the Error In and wire Error Out to the right shift register. Then, based on LabView's data dependency model, the loop will wait for one sub-VI to complete before executing the next loop.
If you're calling the sub-VI's by reference, use the Error In/Error Out of the Call by Reference Node wired to the left and right shift registers respectively.
0 Kudos
Message 2 of 5
(2,937 Views)
Another idea is to use a semaphore. Create a semaphore reference in your
main vi and pass it to the sub-vi's. Force the sub-vi's to acquire the
semaphore before they run. They will then release it when they're done so
the next sub-vi can acquire it.

"Al S" wrote in message
news:506500000005000000813B0100-1068850981000@exchange.ni.com...
> If you have the sub-VIs in separate cases and each sub-VI has Error
> In/Error Out clusters, add a shift register to your while loop. In
> each case, wire the left shift register to the Error In and wire Error
> Out to the right shift register. Then, based on LabView's data
> dependency model, the loop will wait for one sub-VI to complete before
> executing the next loop.
> If you're calling the sub-VI's by re
ference, use the Error In/Error
> Out of the Call by Reference Node wired to the left and right shift
> registers respectively.
0 Kudos
Message 3 of 5
(2,937 Views)
This is a great idea, and easy to implement (despite the strange name).

Check out the example program available at this site:

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3EAE956A4E034080020E74861&p_node=DZ52071&p_source=External

This should serve as a great place to start. Good luck, and happy coding!

Liz Fausak
National Instruments
0 Kudos
Message 4 of 5
(2,937 Views)
Semaphores might give you more flexibility in some circumstances, but they put more of a burden on the sub-VI and its calling VI. Using semaphores can make it hard to run a sub-VI stand-alone.
Data dependency is built into LabView at every level. If you make a practise of adding Error In/Error Out to your VIs, they can be easily run stand-alone or called by another VI and put into a chain to control the execution order.
For the application described in the original question (a simple test executive), you're picking one VI to run at a time and waiting for it to complete before continuing. That can be implimented with a very strait-forward application of data dependency.
In test executives like this, you may want to directly call an instru
ment driver VI supplied by NI or the instrument manufacturer. It is very common in these instrument drivers to have Error In/Error Out. If you want to use semaphores, you'll need to modify their code rather than using a built-in feature.
0 Kudos
Message 5 of 5
(2,937 Views)