LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed sequence sub vi

Can someone tell me how to make a sub VI out of the two case structures inside a case structure that is inside the event structure. I would like to be able to scale this sequencer. To do that I don't want to rewrite the same tasks over and over. If there is a better way to do this altogether then I am open for suggestions. I need to have as many sequences as a random process will need. It could be 5 or 50. This is why I need the program to be scalable.  
0 Kudos
Message 1 of 2
(2,415 Views)

I'm not 100% clear on what you are trying to do and which 2 case structures you are talking about.

In the bottom of cases 1 through5, I see an case structure of that has identical code in the true and false cases.  That could all be a subVI.  Select the case structure, = comparison and the wires of the two booleans going into it.  Choose Edit then create subVI.  It will create a subVI out of what you selected.  You will likely need to clean up the connector panel on this subVI, and possible fix the names of the controls.  Then you can drop the subVI into all the other cases and eliminate the duplicate code.

I noticed in you AutoSBR subVI which is in the True case of that case structure you have a DAQ Create task and a couple of "Create DAQ channels".  But you never clear those DAQ channels at the end.  If you call this subVI repeatedly, you will be constantly creating resources that will eventually eat up your memory and call your application to crash.  You would be better off calling that subVI only once before your loop starts, or use a first call primitive and only execute that code on the first call of the subVI.

Be careful with your wiring, it needs to be cleaned up in some places where the wiring starts to flow from right to left instead of left to right.  See the attachment.  In here, there is no need for the second first call primitive.  Since the true case only gets called if it is the first call, then the second selector must also be true.

As for making any other subVI's, you will have to determine which parts of your code you have in common and turn that into a subVI.  If there are any parts that are similar, but vary depending on the case, you will have to use connectors on your subVI connector panel and feed constants into the subVI for whatever differs between the different cases.  This may even be feeding in references to different controls.



Message Edited by Ravens Fan on 07-25-2008 10:21 PM
0 Kudos
Message 2 of 2
(2,392 Views)