- Community Home
- :
- Discussion Forums
- :
- Most Active Software Boards
- :
- LabVIEW
- :
- Creating a VI that requires any (x-1) of x outputs.

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

02-02-2018 03:20 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Labels:

Is there a way to create a VI with a set of three input terminals of which two are required and the third has a default value if not wired? The complication is that it may be any two of the three terminals which are wired.

02-02-2018 07:45 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

only in a kind of hackish or very complicated and unsupported way.

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019L20SAE

If Tetris has taught me anything, it's errors pile up and accomplishments disappear.

02-02-2018 08:04 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Is this a calculation where you want the vi to recognize which inputs are wired and then branch to use the correct formula based on that? (An example might be an ideal gas law calculation PV=nRT. A subvi might require the caller to wire exactly 2 of P,V,T and then it solves for the the other one).

For something like this to be feasible, you'd typically need the default value of each input to have a special "sentinel" value. This should be a value that'd be illegal if wired. Then you're able to recognize whether or not that particular input was wired by comparing to the sentinel value.

I've often done this using "NaN" as my default value for floating point inputs. (If someone actually wires a "NaN" value, well, the calculation's gonna be in trouble anyway.) Sometimes -1 can work for integer inputs that are only valid/sensible when positive.

The mechanics of it aren't too bad, it's more a question of whether your problem allows for it. You need a problem where there's a known range of legal possible values for your inputs so you can choose an illegal value as a default sentinel. However, some problems don't lend themselves to such assumptions.

-Kevin P

02-02-2018 04:07 PM - edited 02-02-2018 04:08 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

To follow up along the same lines as Kevin's excellent reply:

Another real world math problem I once implemented as a single VI is the pressure-altitude computation... given any two of {barometric pressure, station altitude, ambient pressure}, compute the third as an output.

I found it easier to just create one three-input, three-output VI, and each output is independently the result of the other two entities as input (although there are some common elements of the internal math). In this case, rather than using NaN as a sentinel, I just used zero altitude and standard pressure as default values. The resultant single VI can be used regardless of "what you know" vs. "what you need to compute", and documents more easily.

Would an approach like that work in your case?

Best regards,

Dave

David Boyd

Sr. Test Engineer

Philips Respironics

Certified LabVIEW Developer

Sr. Test Engineer

Philips Respironics

Certified LabVIEW Developer

02-05-2018 11:29 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Another technique is to use variants on the inputs, then convert the variant values to the desired type. Unconnected inputs will yield an error on the conversions.

"If you weren't supposed to push it, it wouldn't be a button."

02-06-2018 03:05 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

R-click the input on the connector pane, select "This input is -> Required". For the recommended ones (the standard) the default value in the VI is what you'll get if unconnected.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."

02-06-2018 03:16 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

A couple other thoughts.

1. Polymorphic VI's.

2. A VI that that has an enum input where the enum would be "Given ABC", "Given ABD", Given "ACD" (Or "Solve for A", "Solve for B", "Solve for C") Since you need to drive a case structure depending on what is given and what you are solving for because the formula to solve for an unknown variable will be different based on which variable is the unknown.

#2 is what I used when I wanted a subVI to solve the geometry of a somewhat defined quadrilateral and in some cases I knew the angles and in others I knew the lengths of the sides.

02-06-2018 03:28 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Similar in concept to Paul's reply, you could use arrays as inputs to your vi.

Then convert your scalar values to arrays when used.

steve

--------------------------------------------------------------------------------------------------------------------------

Help the forum when you get help. Click the "Solution?" icon on the reply that answers your

question. Give "Kudos" to replies that help.

--------------------------------------------------------------------------------------------------------------------------

Help the forum when you get help. Click the "Solution?" icon on the reply that answers your

question. Give "Kudos" to replies that help.

--------------------------------------------------------------------------------------------------------------------------

02-06-2018 10:33 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

02-07-2018 12:34 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I thought this would work; but I don't understand why the 3rd instance is broken.

"If you weren't supposed to push it, it wouldn't be a button."