LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start VI from C program and deliver/get parameters

Hello there!

I suggest you hear this question very often and I wouldn't have posted it, if I hadn't looked for it before!
I am trying to run my vi from my c program, after I built a dll with labview. I suggest there must also be methods to set parameters (controls in the vi) and get their values after the vi has finished!?

I'd be very happy if someone could give me a hint how I can do this, or a good tutorial!

something like "StartVi(viname)" 🙂

kind regards peter
0 Kudos
Message 1 of 6
(3,018 Views)
Hi Peter,

You should use the activex interface (on windows) see here

for a discussion on setting data from within python.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 6
(3,002 Views)
Hello Ton,

first of all thank you for your reply.

I read the posts you gave me the link to and have a general question:

changing the controls and running the vi are to different things!?

with phyton I can change the value of the controls (before I start the vi):

import win32com.client
labview = win32com.client.Dispatch("Python.Application")

//this is the path of the vi, isn't it?
VI = labview.getvireference(r'c:\temp\python.exe\python.vi')
VI.setcontrolvalue('Numerisch','5')

-> I'm using windows .net 2003.... I can't imaging that this is the code I have to write in my .c file?


And how can I call the vi using the generated dll?

kind regards peter


0 Kudos
Message 3 of 6
(2,997 Views)
First let me ask you why don't you call the DLL?
I think that is the reason you build a dll?
I'm not sure how to load a dll and keep it in memory...

With an executable it is possible to load the VI into memory, edit the controls, execute it and read the indicators. But if you've build a dll you can use that interface which is better and better protected.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 6
(2,993 Views)
Hello Ton,

I know how to include the generated DLL, that's not the problem.

I just don't know what to do next? how can I set the value of a control using the dll-functions (for example the control "frequency")?
and how can I run the VI using the dll-functions?

kind regards peter

0 Kudos
Message 5 of 6
(2,987 Views)
Calling a LabVIEW DLL is no different than calling any other DLL. You have a function name with some parameters and you assign variables or constants to these in your c program and call it. The .h file that is created when you built the DLL will have this information.

If you don't have any parameters in your .h file, then you built the DLL incorrectly. When you specify the source file, you are asked to define the DLL prototype. Depending on which version of LabVIEW you have, you may had to click the '+' button to add the VI's inputs and outputs to the prototype.
0 Kudos
Message 6 of 6
(2,973 Views)