06-04-2010 01:01 PM
I am calling a DLL created in LabVIEW in Lab Windows CVI. I was wondering if it was possible for the LabVIEW program to send an ACK to the CVI program indicating its running and for the CVI program to use that value or for LabVIEW to setup a variable and for CVI to be able to access it??
Any help is appreciated!
Thanks
06-07-2010 04:25 PM - edited 06-07-2010 04:27 PM
Hi JCampos,
Yes, LV and CVI can both access Shared Variables. There's an example of this online at
CVI and LabVIEW Network Published Shared Variables
However, depending on what you want to do, it may be easier just to put another input in your function prototype and pass a value to your DLL that way from LabVIEW.
06-09-2010 05:04 PM
I decided to go with the network variables but on the LabVIEW side so there are two VI's that make up my DLL. In CVI, I run my program and a second thread calls the first VI is called and its written to do some setup, set a shared variable to true and wait for another global variable to be set to true. At the same time in CVI since the function call to the DLL was with a separate thread it continues and calls the second VI to then check if the first shared variable was set to true and if so it sets the second global variable to true which should then allow the first vi thats running to now continue on. When that call returns to CVI, the program continues. The shared variables work when running in the LabVIEW environment but running them as EXE's they don't.
Essentially I want to start running in CVI, create a thread to run a LabView program and I want the CVI to continue only if the LabVIEW program has reached a certain point in its code so as to avoid a race condition.
I hope it all makes sense and help would be great! Also Im running Windows XP, LabVIEW 8.6 and CVI 8.5.
Thanks!
06-10-2010 05:54 PM - edited 06-10-2010 05:55 PM
Did you deploy the shared variables from LabVIEW?
How Do I Deploy Network Shared Variables from a Compiled Executable?
If the variables aren't deployed that could definitely be a reason for it not working, I would try adding in the programmatic method of deploying the variables also.
06-11-2010 08:30 AM
Hi Eric S,
So I found that out yesterday so that resolved the EXE issue but now it will not work using the DLL. I have moved the files over to a different computer that does not have LabVIEW and I can see the variables in the variables manager but I cant change them using the DLL, only with the EXE's.
06-14-2010 05:53 PM
So you moved both of these files, the DLL and EXE to a new computer? Or is the EXE on one computer and the DLL on another?
Can you read the shared variables from the DLL or can it not communicate with the shared variables at all?
Are you getting an error when trying to write to the shared variables from the DLL or is it just not doing anything?
Does this new computer have both the LabVIEW Runtime and the CVI Runtime for the appropriate versions?
06-21-2010 09:36 AM
Yes both exe and dll are on this new computer. It cannot read or write to the shared variables through the DLL at all only through the exe. I'm not getting any type of error. It looks like it is making the function call but returning right away without returning an error. The computer has the LabVIEW runtime and the CVI runtime as well.
06-22-2010 12:12 PM
I can't say anything about the shared variables approach as I have never used that feature. What I would have done personally is used TCP/IP to maintain a connection. Doing so, I can send any sort of messages I want between programs.
There are other ways too, using COM and ActiveX but those would not be my way of doing this as I am less familiar with them and don't feel like going through the learning curve.
Just goes to show there are many ways to approach a problem.
06-23-2010 07:52 PM
Using TCP/IP or another protocol is certainly an option, though requires the learning curve on those protocols.
JCampos, have you tried calling this DLL from a different programming environment other than CVI? such as c#,c++, or even another LV VI?
The DLL you're trying to call was was compiled out of LabVIEW VIs, correct? What happens if you try calling that DLL from LabVIEW?
06-23-2010 07:56 PM
Eric, it's all about what you are comfortable with. I use TCP/IP because I know it intimately. I would have to go learn the shared variables approach.
We all have our comfort zones.