LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting labview VIs using python or C++.

I have several labview VIs that I want to script using a text based language. In particular, I want to be able to run the VIs within python or C++, whereby I can provide the VI arguments in the code and read any data it returns. Does anyone have any experience with this, and if so could you point me in the right direction to get a starting point?

 

Cheers

0 Kudos
Message 1 of 5
(345 Views)

By scripting, do you mean writing up a VI from scratch by defining the block diagram and front panel programmatically from a "text-lanaguage"?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 5
(319 Views)

I guess you want to call VIs (rather than script) from python or C++.

 

While in interpreted languages like python, the word "script" is used interchangeably with "code", in LabVIEW, "VI Scripting" has a completely different meaning. It is a LabVIEW code that can create or edit another LabVIEW code (block diagram / front panel).

 

You can of course call LabVIEW VIs from external code by first compiling them to a shared library (dll).

You can also compile them to a .NET assembly.

 

Then import the library in your code as you would do for a "standard" C dll or .NET dll.

 

Regards,

Raphaël.

Message 3 of 5
(296 Views)

LabVIEW contains the so called VI Server. This is an Inter Application Control interface which also can be accessed from inside LabVIEW (which is by far the most easy way to use it).

 

There are two other interfaces, one is TCP/IP based and the other is ActiveX based.

The TCP/IP based interface is a proprietary binary communication protocol that is undocumented. The only documented way to access that is from within LabVIEW itself with its VI Server property and method nodes. One possibility is to create a LabVIEW DLL or .Net Assembly that does the necessary scripting calls and provides functions to do what you need. These functions can then be called from any other application and programming language that allows you to call DLL functions or .Net assemblies.

 

The ActiveX interface is a fairly small subset of the VI server protocol but would work for what you want to do. It is however legacy technology (Microsoft would love if they could make users forget that there ever was something like ActiveX). And NI has not invested anything in this interface since over 15 years. It still works but documentation about it is getting harder and harder to find as NI tries to remove most references to that, since there is factually nobody who will help you when it doesn't work. Python can call this interface with the pywin32 module and use the win32com class.

 

A few interesting links that may get you a bit further:

https://labviewwiki.org/wiki/ActiveX

https://forums.ni.com/t5/Example-Code/LabVIEW-Executable-Used-as-ActiveX-Server-in-LabVIEW/ta-p/3527...

https://forums.ni.com/t5/Example-Code/Running-or-Calling-a-VI-using-the-LabVIEW-ActiveX-Automation/t...

https://rajsite.github.io/unofficial-lvdocs/lvconcepts/Using_ActiveX_with_LabVIEW.html

 

 

Rolf Kalbermatter
My Blog
Message 4 of 5
(167 Views)

You don’t provide enough detail to show the complexity of the data being sent and received. If they can be expressed as simple strings, then the web server interface may be the quickest solution. Open the LabVIEW project and enable the web server. Any Language can send an HTML request with the VI path and any parameters and parse the response as the result. 

Look for sample code in the LabVIEW examples.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 5 of 5
(128 Views)