LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

subVI design

I am currently designing a testing phase for a program to control a motor that I can runMotor.vi.  Given a set of parameters, I can run the motor and record its characteristics.  I've wrapped runMotor.vi into another new vi called testMotor.vi which calls runMotor.vi several times, but with different parameters defined within testMotor.vi.  Now I want to include this testMotor.vi into my main code as a diagnostic test prior to running the motor in a normal routine.  I want to control the subVIs from the main front panel so that when I press the stop button, the message is conveyed to the subVI.  This is a design question in terms of how to lay out the subVIs to provide for greatest control from the highest VI.  Should I create an occurence in main, testMotor.vi, and runMotor.vi so that upon clicking STOP in main.vi, there's an immediate response in the subsequent subVIs? I'm trying to avoid using global variables. I also want to set it up so that at each level, if there are any files open or communication connections open, that they're closed appropriately as well.   Any comments would be appreciated.
0 Kudos
Message 1 of 3
(2,779 Views)
Hi jimmy1981,

I would recommend making your subVI's re-entrant if you need to have multiple different instances of the same VI.  For more information on this topic, please take a look here.

If you have questions about the best method for calling your sub-VI, take a look at this KnowledgeBase.  It describes the differences between a couple of sub-VI calling methods.

Please let me know if you have any further questions.
Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
0 Kudos
Message 2 of 3
(2,744 Views)
This probably is not the best or the proper way of doing this but it works for me. I wrestled with the same problem and the following is the way I got around doing that:

1) The main VI passes the "refnum" of the stop button control to the subVI
2) In the subVI, I created an event structure that will respond to the events registered by the stop button control refnum.

Attached is a picture of what I mean.

Jae Ho Jeon


0 Kudos
Message 3 of 3
(2,728 Views)