LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having a variable number of input ports on a subVI

Solved!
Go to solution

How can I have a subVI with variable number of input ports which can be changed in the other VI that uses the subVI?

0 Kudos
Message 1 of 24
(3,783 Views)

@Mmehrabin wrote:

How can I have a subVI with variable number of input ports which can be changed in the other VI that uses the subVI?


Oftentimes the question asked is the "wrong question".  I would ask you why you need this functionality, because I have a feeling that the solution to your real problem might be a whole lot easier than you imagined.  🙂

 

So what is it that you are trying to accomplish?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 24
(3,781 Views)

Actually, I am working on a system which should detect some signals that are simultaneous. Thus to make it modular, I need it works for any number of signals. It can be similar to some controls in LabVIEW whose input ports are variable.

0 Kudos
Message 3 of 24
(3,774 Views)

Ahh, so you mean something like the "Index Array" function where you can drag the icon lower edge to have as many outputs as you need?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 24
(3,772 Views)

Absolutely. 

0 Kudos
Message 5 of 24
(3,765 Views)

I am not aware of such functionality existing for user-made Vis, but can you bring in an array of data and iterate over it in a loop?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 24
(3,760 Views)

It is possible but I want to do that in VI Scripting. Do you have some information in this case?

 

0 Kudos
Message 7 of 24
(3,757 Views)

@Mmehrabin wrote:

It is possible but I want to do that in VI Scripting. Do you have some information in this case?

 


Sorry, I did not know your level of LabVIEW expertise so I imagined the simplest solution.  I am not well-versed in scripting.  My apologies.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 24
(3,752 Views)

Thank you.

0 Kudos
Message 9 of 24
(3,749 Views)
Solution
Accepted by topic author Mmehrabin

 You can't actually do what you're trying to do, the way LabVIEW is set up doesn't allow for user-created VIs with arbitrary inputs.  And to be honest, there's probably a better way to do whatever it is you want to do.

 

If you really truly want to do this though... you can kind of come close.

 

1. Create a new VI

2. Change its connector pane to the one with the most possible inputs and outputs (8-6-6-8, 28 terminals)

3. Create controls/indicators for whatever non-scaling inputs/outputs you want, then hook them up (i.e. error in/error out, reference wires, etc)

4. Hook them up to the connector pane

5. Count how many inputs are left and create one control input for each of them and wire them all up

6. Drop your VI on another VI's block diagram as a SubVI

7. Notice that when you mouseover it, it looks like a pincushion

8. Right-click the VI and uncheck "View as icon"

9. You can now "drag down" at the bottom of the VI

 

The terminals in the "drag down" section are like Bundle by Name or Property Nodes in that you can click them to reassign them to anything not already chosen.  The default is to do all of the inputs alphabetically, then all of the outputs alphabetically.  Whether or not you rename the terminals you use to have them appear in the order you prefer is up to you.

 

As for all of the terminals, the best you can do to detect if they are wired is to set them to a default value that should never be used.  If it's floating points, you can use "NaN" or "Inf".  If it's a cluster you made, add one more boolean element that is only True in the defaults to this VI input.  

 

Then just wire all of the identical terminals together into an array, filter out the elements that seem unwired, and do all of your processing on the remainder.

Message 10 of 24
(3,704 Views)