LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

more terminals to sub vi

Hi, I would like to add more terminals than the maximum terminal pattern. Is this possible? I know I could pass arrays into sub vi with less terminals, however I would like to avoid that if possible to minimize memory.
0 Kudos
Message 1 of 12
(4,399 Views)

You can not increase the number of terminals but you should cluster the data into groups of common themes.  In software ingineering you should keep your functions simple, so if you need more than 10-12 input/outpous you should consider refactoring the function into several smaller subfunctions.  This will make your core easier to manage read maintain and reuse.  I have found out this over the last 10+ years of coding that simpler is better.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 12
(4,387 Views)
Hi resrcheng...,

there was a similar discussion just a month ago Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 12
(4,370 Views)
Paul, yes simpler is better. However, as with the post I am trying to avoid arrays. Building arrays I have noticed cuases more RAM storage. See for example the files attached below. I have two sets of vi's which do the same thing and the one for which I build an array and then send the array in requires approximately 200 kb than the case where I send in three inputs.
0 Kudos
Message 4 of 12
(4,343 Views)
Memory is cheap nowdays.  You don't have to use arrays, you can use clusters.  Bundle several inputs into one cluster and send the cluster to the subvi.  The subvi can then unbundle the elements.  Using a cluster of 32 elements is much better than having 32 terminals to connect.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 12
(4,336 Views)
I was refering to using clusters not arrays, here you can name the fields and it will improve the code readability.  Also make sure that you only pass the needed controls to subvis. 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 12
(4,334 Views)


@resrchengee wrote:
I have two sets of vi's which do the same thing and the one for which I build an array and then send the array in requires approximately 200 kb than the case where I send in three inputs.

You are kidding, right? The difference is more like 200bytes (0.2kb). Why do you think an array with e.g. 3 elements will take significantly more memory than 3 individual scalars.

Memory considerations are important once it gets into the tens of MB.

Once you have a million numbers, I dare you to use individual scalars instead of arrays! 😄

(Your thinking is like the idea of clipping toenails to significantly loose weight. 🐵

Much more important is your overuse of property nodes. They really cost you a performance penalty. Why do you need all these references? Why do you need a subVI to update a few controls? A better idea would be to use an array of controls, requiring only a single reference. (Or no reference at all if you would make the array an indicator and use a plain output connector from the subVI. No more references needed!)

 

0 Kudos
Message 7 of 12
(4,331 Views)
Why do I need references? I need them because I need to be able to change control values and indicators from within a sub vi. If there is another way to do that without having the references please explain?
0 Kudos
Message 8 of 12
(4,309 Views)
sure, if you know the names of the controls, you can  open a reference to the top VI, and get the control references  by name

Paul
0 Kudos
Message 9 of 12
(4,300 Views)


@resrchengee wrote:
Why do I need references? I need them because I need to be able to change control values and indicators from within a sub vi. If there is another way to do that without having the references please explain?

I certainly don't know the final purpose of your VI and what else will be there. There are always many different ways to do things and my comment simply meant that there might be other options.

To simply change a value of a control does NOT even need a subVI, especially since you seems to be so overly concerned about memory use and performance.

Maybe you can explain to all of us what you are really trying to do and why you think references are the best way. I have written thousands of programs and never updated controls that way, and never had the need to do so. 🙂

(And looping through control references by name as suggested by Stradis seems to just complicate things even more. I would always strive for the simplest solution! :))

Message 10 of 12
(4,297 Views)