LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a VI read data being generated by my C program and use the data for controlling other devices?

The VI and the C program cannot be integrated and need to run together continuously. Please help...
0 Kudos
Message 1 of 5
(2,838 Views)
Assuming you can change the C code as well you should be able to do this.
At the most primitive level you could use a file as a shared source.
You could use TCP to communicate between the applications.
You could write a function which will return the data and call it in a DLL.
You could export it using ActiveX.
There are probably other methods as well.
Have you read the LV documentation on integrating with other laguages (Help>>Search the LV Bookshelf [and one of the chapters in the user manual])?

If you need more details, you should probably write more about your setup.

___________________
Try to take over the world!
Message 2 of 5
(2,832 Views)
Would speed be an issue with the idea of using a file as a shared source? I like the idea as long as the speed is over a few KHz level. For example, based on a set of numbers obtained from my program at every msec, a VI needs to control actuators.

I am not much familiar with the other options of using TCP, calling data in a DLL, or exporting with ActiveX. Are there good resources about using TCP or writing a function to return the data for a DLL?

Yes, I've read the LV documentation but I thought there should be better ways. It would take considerable time to integrate both.
0 Kudos
Message 3 of 5
(2,821 Views)
A few KHz is definitely a problem because windows itself isn't deterministic at such resolutions.
I'm not sure what kind of speed you will get from using a file, but it probably won't be very good. Consider the fact the you constantly have to open and close the file and write to the disk and you will see why this isn't very good.

Look here for some material concerning this (particularly the link Integrating DLLs). I don't know if this will help or not, but you should check it.

Regarding TCP, I don't know of any resources about that, but you can start by looking up TCP tutorials here to see how it works in LV and look for some others for C on the net. The big advantage here (I think) is that you maintain a constantly open connection between the programs.
As for the DLL option, that depends on your program. I think the above link has something like that as well, but if not, it's basically writing a function which will return the data and exporting it as a DLL in your C compiler.

In any event, you will probably need to do some matching between the data types, because they're represented differently in LV. There should probably be some articles and threads discussing this.

___________________
Try to take over the world!
Message 4 of 5
(2,812 Views)
Tst,
I agree. Using a file doesn't seem to be a good idea.
Anyway, the link you gave me should be helpful for me to find a solution. Thanks.
0 Kudos
Message 5 of 5
(2,801 Views)