LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a VI (with interface) in another program by DLL

Solved!
Go to solution

Good afternoon,

I have a problem I cannot solve at all. I have an understoodable VI. It runs properly. I can make a dll of this VI. And I want to call this dll in another program. The problem is, I have to wrap the dll with VS 2003 C++ to run in Digital Micrograph. When I call the dll, I can not control it since I cannot access to the graphical interface of Labview. Is there a way to export the graphical front panel in another software on the basis of a dll ?

Thanks for any help.

0 Kudos
Message 1 of 28
(3,461 Views)

I am not sure if you are able to view the front panel elements to manually change them, but you can set up the front panel elements using the Connector Pane and then reference them in the function prototype during the DLL build:

 

  1. Connect the front panel elements to the Connector Pane

io.png

 

2. Build a DLL using the Build Specifications item in the Project

 

shared.png

 

3. Export your VI in the Source Files section in the pop-up that lets you configure your VI. 

 

select.png

 

4. Once you click the blue arrow in step 3, you will be presented with a new popup to configure the function prototype (how you will call the function in Visual Studio).

 

prototype.png

 

This is where you can map the front panel elements to the C function.  The "x", "y", and "return" refer to the controls/indicators in the first image.  (For instance, the sample VI I used just summed 2 numbers using "add" function.)

 

NOTE:  You must have the LabVIEW Run Time Library installed on any computer where you wish to reference this DLL. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 28
(3,449 Views)

I thank you very much for your answer. But unfortunately, I knew this and I did this. The problem is when I execute this, there is a general loop in the VI. This loop does not stop unless we click stop. And by a C++ language, I cannot send a stop like it is done in Labview to stop the loop.

0 Kudos
Message 3 of 28
(3,440 Views)

@gautierdufourcq wrote:

I thank you very much for your answer. But unfortunately, I knew this and I did this. The problem is when I execute this, there is a general loop in the VI. This loop does not stop unless we click stop. And by a C++ language, I cannot send a stop like it is done in Labview to stop the loop.


Oh... I see.  Now I understand 😉

 

In that case, I personally would just re-write that little segment.  For instance, have the code wait for a TCP command to stop.  Then instead of clicking a button to stop, you can have the C++ code send a command to stop.

 

Perhaps someone with a little more familiarity with LabVIEW built DLLs can suggest a more elegant solution.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 4 of 28
(3,436 Views)
The default build behavior for a dll is to remove the front panel. You can change this but why would you have a loop that needs to be stopped? Pretty irritating behavior to anyone that calls the dll.
0 Kudos
Message 5 of 28
(3,430 Views)

Thank you again. I want to control temperature and I want to stop when I want or I want to communicate with the dll like if I was with Labview. But I can change values when the dll is running because it behaves like a C++ function.

0 Kudos
Message 6 of 28
(3,426 Views)

@gautierdufourcq wrote:

Thank you again. I want to control temperature and I want to stop when I want or I want to communicate with the dll like if I was with Labview. But I can change values when the dll is running because it behaves like a C++ function.


Then similarly to my last post, why even bother with a DLL?  You are looking for something more like interprocess communication -- TCP (easiest in my opinion), shared memory, files, etc.

I highly recommend a client/server setup using TCP.  I use this a lot as it is quite basic and LabVIEW has excellent VIs to do this.

 

EDIT:

 

I just thought of another idea... you could make a DLL function that triggers a stop boolean to flick.  Then you could have a "stop()" function in the LabVIEW DLL.  That may just work.  For instance using a queue, functional global, etc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 7 of 28
(3,422 Views)
Behaving like a c++ function is the usual need. You need front panel controls that you pass parameters to. You need multiple functions in the dll (i.e. initialize, Read, Close), and a loop in the c++ code for multiple reads. In my opinion, your architecture is wrong.
0 Kudos
Message 8 of 28
(3,410 Views)

The fact is, my software (DM), can only understand dll. So I must build dlls. So, it can be a bad solution, it is probably one, but I cannot do otherwise. Then, my knowledges are limited and I do not know TCP for daq. Is it possible to implement things like queue, create particular functions to handle values from C ? But I do not understand what you mean.

0 Kudos
Message 9 of 28
(3,391 Views)
I did NOT say that building a dll was the wrong solution though there is a c/c++ api for DAQmx. What I dais was that your current implementation is badly designed. There is absolutely no reason that your dll has to have a front panel that must be shown. A dll still most commonly consist of multiple functions. That means building the dll with multiple VIs. Each VI that you include in the dll would have parameters that get passed to it and return values. That means for example, an initialize function that you pass configuration parameters and returns the task id. You would have a read function that gets the task id passed to it. The c program would have a loop for multiple reads.
0 Kudos
Message 10 of 28
(3,379 Views)