LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do the outputs and inputs of a sub vi seem to be backwards?

I'm very new to LabVIEW and am having trouble creating a main vi that contains a sub vi.

The problem is, the sub vi is supposed to have one input (an indicator text box) and a few outputs (boolean click buttons), but when I set these as the "pins" of the sub vi, the outputs are inputs and vice versa.

This seems backwards to me - shouldn't I be able to make a control text box in the main vi, change the text there and have it change the text in the sub vi's indicator box? I got the sub vi's front panel to pop up when the program runs, and the idea was to press the buttons there and have them affect the main vi (since they should be outputs).

I am sure I have the wrong idea about how this is supposed to work. Please help!


Adam
0 Kudos
Message 1 of 7
(2,681 Views)
Hi,
In LabVIEW we have "controls" (inputs) and "indicators" (outputs). To pass values into a sub-vi the value is passed into one of its controls, and to get values out of a sub-vi they come out of the indicators. Of course, this is all ignore control references, property nodes, etc. that allow you to "cheat". So when your main vi writes some text into the sub-vi it is to a string control. You can make this control "off screen" or invisible, and then wire it to an indicator, but it isn't necessary. Now, if you have buttons to signal the operator's response to the message sent in they would be wired to indicators, which also may be "off screen" or invisible, which would be wired to the connector pane. In the standard usage the inputs (controls) are wired to the left hand of the connector pane, the outputs (indicators) to the right hand ones.

If this isn't what you need, keep asking and we'll keep answering!

P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 7
(2,671 Views)
Well the problem is that you have mixed up the control and indicators.

When you set any widget to be a control that mean it is an input (whether from a user or to a SubVI). So first thing you got to do is to make your text box a control instead of the indicator. This will also allow the user to modify the text entered in your main VI, in your SubVI as well. If you want to stop the user from editing the text in the subVI right-click the text field, go to advanced and disable the text field. This way the user can't edit this control.

When you set any widgets to be an indicator that means it is an output (output to be displayed on screen or the output of the subVI). Therefore the button in your Sub VI should be an indicator. However if you make it an indicator the user can't click it. Now one easy way around this one is to have two buttons: one indicator and one control. You will have to wire the control to your indicator in side your loop so that when ever the user clicks the control button it is as if the user has pressed the indicator button. Set the Output "PIN" in your sub VI to the indicator button and hide the indicator button in the front panel by right clicking on it and going to advanced sub menu.

I hope this helps.

Nariman
0 Kudos
Message 3 of 7
(2,663 Views)
Ok both replies make sense, it's annoying to make these "workarounds" though...I guess sub vi controls and indicators are most often used in a different way than in the application i'm using.

Thanks for the help!
0 Kudos
Message 4 of 7
(2,652 Views)
Did you create the vi?

If so, you can "customize" the look of your vi box. You select an empty box with the number of sockets around it. You the select the control or indicator for each of the socket. Although it is good practice to place inputs (or controls) at the front and output (or displays) at the back, there is nothing prohibiting oyu from mixing them up.

What you may have experienced is the automatic creation of the vi box. For instance, let's say that you have 2 inputs (controls) and 8 outputs (displays). The automatic placement may choose one of the following:

2 at front, 4 at back, 1 on top and 1 on bottom.

OR

2 inputs at the front with 2 outputs at the front with 4 outputs at the back. I seem to recall these weird ones from the days of LV-6.. 😉

But when using the manual placement, you can become quite creative... 😄

Have fun!

JLV
Message 5 of 7
(2,649 Views)
attach your application, I wonder that the subvi usage is different from a subroutine in another language but maybe you started with the wrong idea. What should the subvi bring to the main vi and what is the input for the subvi

starting in labview looks different from other languages but in fact is almost the same, except for ease of debugging, writing and a lot of parallellism
greetings from the Netherlands
0 Kudos
Message 6 of 7
(2,642 Views)
Awesome - It all works fine now, thanks to all for saving me so much time!

Adam
Message 7 of 7
(2,627 Views)