LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Methods to use functions from another VI

Hello, all,

 

I want to use functions from another VI in my VI. I would like to know how many possibilties I can have to reach this purpose in LabVIEW. Could you please let me know also the disadvantage and advatage of the solutions from you?

Thanks for all the contribution in advance. 

 

Regards,

qf2599  

0 Kudos
Message 1 of 14
(2,800 Views)

Hi,

 

you can use functions of a VI in another VI by integrating the VI in another VI. So you have a VI (main) which has included another VI (named SubVI).

What you need to make the connections to the SubVI on the MainVI-block diagram is to connect the inputs and outputs to the SubVI connector pane. See the following link how it works:

 

Tutorial: SubVIs: http://www.ni.com/white-paper/7593/en

 

Hope this helps.

 

Best regards

Suse

______________________________
Certified LabVIEW Developer (CLD)
0 Kudos
Message 2 of 14
(2,763 Views)

Hello, Suse,

Thank you very much for your reply.

This is one of sulotions.

Do you know any other posibilities?

 

 

Regards,

qf2599

0 Kudos
Message 3 of 14
(2,752 Views)

Hi,

 

you can use variables if you use both VIs in your project and if you only want to get the result of a function.

But be carefull. Variables can also cause race conditions. Functional Global Variables (FGV) prevent race conditions.

 

Basic Functional Global Variable Example: http://forums.ni.com/t5/forums/replypage/board-id/170/message-id/743796

Are LabVIEW global variables good or bad, and when is it OK to use them?: http://www.ni.com/white-paper/5317/en

 

You can also use Queues to transmit data to other VIs or loops as well as notifier.

 

Have a look at this link: Webcast-Serie: Erfolgreich durchstarten mit NI LabVIEW!: http://www.ni.com/white-paper/14178/de

And watch the including Webcast named "Fortgeschrittene Entwurfsmuster – das Erzeuger-Verbraucher-Prinzip in LabVIEW"

 

LabVIEW Core 1 and 2 training courses also give information to SubVIs, variables, queues and notifier:

http://www.ni.com/training/d/

 

Best regards

Suse

______________________________
Certified LabVIEW Developer (CLD)
0 Kudos
Message 4 of 14
(2,744 Views)

Hi,Suse,

Thanks again for your reply.

I have tried FGV, Queue and DVR. In my case, these don't help so much. I have no idea about this called VI so far. But I need to call the functions from this VI.

There're 2 sulotions so far for me. Call VI by reference and Call DLL.

Do you know what's the disadvantages and advantages of these two ways? Do you have any other solutions?

 

BR

qf2599

0 Kudos
Message 5 of 14
(2,738 Views)

Hi,

 

you can post your code so I can say what's better.

 

Best

Suse

______________________________
Certified LabVIEW Developer (CLD)
0 Kudos
Message 6 of 14
(2,736 Views)

Hi, Suse,

My code is very simple. A simple subVI is created, whose exact functions included is unimportant and careless.

In my main VI,

1st solution: Call this subVI by reference and use invoke nodes to run VI and use get Ctrl value and set Ctrl value to pass data with main VI.

2nd solution: Build DLL from subVI. In main VI , use call library node to call this DLL and select the function to get output results.

3rd solution: Directly leave the subVI in main VI, wire the respective terminators. Danymically call subVI or stastically call subVI can be considered.I have made a test. It seems that stastically call subVI is faster than Danymically call subVI when exectue the subVI the same times.

 

Any other solutions? why? Advantages and disadvantages?

0 Kudos
Message 7 of 14
(2,730 Views)

What is the point of this exercise?  Just use the subVI in your main VI.  That is by far the simplest and most efficient.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 14
(2,722 Views)

Thanks for your reply.

The point is to find out how many possibilities in LabVIEW to use the functions from another VI.

 

BR

qf2599

 

0 Kudos
Message 9 of 14
(2,718 Views)

Hi,

 

there is no need to make a dynamic call of the VI or create a DLL.

I would recommend to use the SubVI statically in the mainVI. This is the easiest way.

 

Best regards

Suse

______________________________
Certified LabVIEW Developer (CLD)
0 Kudos
Message 10 of 14
(2,713 Views)