02-27-2012 03:26 PM
I would like to create a DLL in LabVIEW that can be called from a C program.
The purpose of the DLL is to display a dialog along side a C program user interface and display a picture is updated continuously in the program.
The LabVIEW DLL would
1. would be a dialog that open along side the user interface of the C program.
2. the DLL would be called regularly with parameters passed by the C program.
3. the dialog would contains a picture that is updated by the parameters from the C program continously.
Is this feasible? I assume that the DLL has to run as a daemon, since the DLL is a dialog that has to run along side the C user interface. To run a DLL written in LabVIEW, does the PC needs the run time engine?
Solved! Go to Solution.
02-27-2012 03:57 PM
The general answer to your question is that yes, it can be done. How you do it depends a lot on what you need. There are numerous ways to do this. For example, you could have a VI that launches this dialog as a dynamic VI. This "launcher" VI would be mapped to a function that you'd call from your C code. You'd save the reference to the dialog VI in your LabVIEW code so you could pass it the parameters from C. You'd do this by creating another VI that accepts these parameters and then passes them to the dialog VI. The details on this really depend on what these "parameters" are.
As for the Run-Time Engine, yes, you would need to install the Run-Time Engine on the target computer so the LabVIEW code could run.
02-27-2012 04:27 PM
Let me try to summarize
1. create a launcher vi that is compiled into a DLL.
2. The C prgram would called the DLL and activate the launcher vi
3. The launcher vi would launch a dialog vi.
4. The C program would get a reference of the dialog vi from the launcher vi to pass paramters into the dialog vi for continuous update.
The test station that runs the C program will need the following:
1. the c program
2. the dll that contains the launcher vi
3. the dialog vi that get launched
4. LabVIEW run time engine
5. LabVIEW development system is not needed
02-27-2012 04:31 PM
No, that's not what I meant. I meant to have everything in the DLL. Remember that when you create a LabVIEW DLL you specify individual VIs as DLL functions (exported VIs). Thus, the launcher and the "set parameters" VIs would be separate functions in the DLL.
Of course, as I mentioned there are other ways to skin the cat.
02-27-2012 05:44 PM
You meant both the launcher and the dialog vi are in the DLL, right? What did you mean by set parameters vi? The paramters is passed into the dialog through the C program
02-27-2012 10:48 PM
Yes, I was referring to having everything in the DLL. The "set parameters" I mentioned was a way to have a proxy between the C code and the LabVIEW code. The C code wouldn't be able to access the dialog VI directly. It would call this "set parameters" VI with the values it wants to set, and this "set parameters" VI could set the values in the dialog. Since it's inside the DLL it could access the dialog VI.
02-28-2012 10:10 PM
Why can't I pass the parameter from the c program directly to the dialog vi inside the DLL?
If I can't pass parameters directly to the dialog vi inside the DLL, why can I pass parameters to a set parameter vi that is also in the DLL?
02-29-2012 09:40 AM
Because when you compile the LabVIEW code into a DLL, the C code simply sees functions. The "Dialog" VI becomes a function call. If you call it directly that way, then the C program is going to wait until the function call (i.e., the VI) has finished before continuing to the next line of code. Since the VI is running, it can't do that, so it's not like you can call it again with new parameters.
02-29-2012 12:20 PM
Does the dialog vi needs to be inside the DLL as well? Or does it have to be a vi stored somewhere on the PC?
Let me try to summarize again
1. create a launcher vi that is compiled into a DLL.
2. create a set parameter vi that is compiled into a DLL.
3. create a dialog vi that is compiled into a DLL
4. The C prgram would call the launcher vi from the DLL.
5. The launcher vi would launch the dialog vi.
6. The C program would get a reference of the dialog vi from the launcher vi and use it to call set parameter vi for continuous update.
The test station that runs the C program will need the following:
1. the c program
2. the dll that contains the launcher, set parameters, and dialog vi
3. LabVIEW run time engine
4. LabVIEW development system is not needed
02-29-2012 01:27 PM
Everything was correct up to 5. For 6 you do not get a reference to anything from C. You just call the exported function that is the "set params" VI.
I've included a sample project to give you an idea. The LabVIEW code is written in LV 8.2 and is the project with a build spec for a DLL. I used C# for this example, but you can easily translate it to C if you need to.