LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a C program in Labview

hi, I am a senior in electrical engineering at purdue university and new ot LabView. I have a program in C that i would like my labview program to call up and run. Currently, I have a video camera which will be following a little car in a terrain. The C program uses pattern reognition to determine the location of my little car in the terrain. Right now I am trying to get my LabView code to recognize the pattern recognition software i have already programed in C. It will be outputting a few intagers which i will then manipulate via Labview. What I would like to konw is:
 
1) Do I have to have a pre compiled C program executable sent to the Labview program OR is there a way i can send my C code to the program and have it execute it?
 
2) What blocks might i use to implement the system? and what functions pallate is required?
 
I would appreciate any help on the project.
0 Kudos
Message 1 of 12
(5,204 Views)


@JohnBui wrote:
hi, I am a senior in electrical engineering at purdue university and new ot LabView. I have a program in C that i would like my labview program to call up and run. Currently, I have a video camera which will be following a little car in a terrain. The C program uses pattern reognition to determine the location of my little car in the terrain. Right now I am trying to get my LabView code to recognize the pattern recognition software i have already programed in C. It will be outputting a few intagers which i will then manipulate via Labview. What I would like to konw is:
 
1) Do I have to have a pre compiled C program executable sent to the Labview program OR is there a way i can send my C code to the program and have it execute it?
 
2) What blocks might i use to implement the system? and what functions pallate is required?
 
I would appreciate any help on the project.


It is not clear how your pattern recognition software works. Is it an executable that will return certain parameters on each call? Is it an executable that has some interprocess communciation such as TCP/IP to communicate with other software? Or is it jsut a bunch of functions that you want to call from within LabVIEW?

And no, LabVIEW can not interprete or compile C code so you will have to use a C compiler to turn your code into an executable form. If it is just a command line tool that retunrns some parameters on each call you would use System Exec.vi. More likely it is a bunch of functions you want to call in LabVIEW and therefore you would create a DLL from your C code and call it through the Call Library Node.
Another interesting approach would be an application that has a built in TCP/IP server so that you could launch it from LabVIEW through System Exec.vi and using LabVIEW's TCP/IP functions you could communicate with the application.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 12
(5,198 Views)
rolfk pretty much addressed the issue - please tell us more about the code and how you want to use it, because there are several ways to do this and thus the answer is "it depends".
 
From what you've said so far, it sounds like the best plan is to compile your C code into a DLL and then call it from LV. You want to watch the data types in your C functions as structures with pointers are going to make your life difficult, etc. So feel free to post back with your API or thoughts...
 
Finally, I had to jump in and say something as I graduated from Purdue with a BSEE back in 91 🙂 Good to find another Boilermaker on the devzone.
0 Kudos
Message 3 of 12
(5,186 Views)
When installing LabVIEW you also get a bunch of useful manuals. One of these is how to call external code from LabVIEW. You can see the online version here. There's also examples that ship with LabVIEW showing you how to call code written in C. These are in the "examples\dll\datapassing" directory of your LabVIEW installation directory.
0 Kudos
Message 4 of 12
(5,184 Views)


@Lycangeek wrote:
 
Finally, I had to jump in and say something as I graduated from Purdue with a BSEE back in 91 🙂 Good to find another Boilermaker on the devzone.


Did you get to NI directly after that or have there been other stations in between? Just asking because I started in April 1992 with NI Switzerland and happened to be in Austin for 4 months back then.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 12
(5,177 Views)
We might have passed each other - I went to UT for my masters and started at NI part time in the fall of '92 while I wrote my thesis. But I was in the DAQ SW group at that point, so I doubt we ran into each other work-wise. Ah, the good ol' days 🙂
0 Kudos
Message 6 of 12
(5,168 Views)


@Lycangeek wrote:
We might have passed each other - I went to UT for my masters and started at NI part time in the fall of '92 while I wrote my thesis. But I was in the DAQ SW group at that point, so I doubt we ran into each other work-wise. Ah, the good ol' days 🙂


Smiley Happy I can only echo that good ol' days! I went back to Switzerland sometimes in September so we had most probably not a real chance to meet. I was situated in the AE department as everybody starting with NI had to go through there back in those days 😉 and of course I was to be the local AE in Switzerland for about the next 4 years.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 12
(5,157 Views)
Thank you for your help, what we decided to do was use the C program and write the output to a text file. We are then using Labview to read the text file and convert that text string into an array of intagers.  Do you think this is a good way to solve the problem?
0 Kudos
Message 8 of 12
(5,136 Views)


@JohnBui wrote:
Thank you for your help, what we decided to do was use the C program and write the output to a text file. We are then using Labview to read the text file and convert that text string into an array of intagers.  Do you think this is a good way to solve the problem?

It's not a very elegant way, of course. But if it is working and fast enough for what you need, then I would say: go for it!

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 12
(5,119 Views)

Hi guys.. I am also trying to do same sort of thing I hope someone can refer me some help article or can send me some example code... 

 

Actually I have a program which is in C language and it is CRC check for the commands I will send now what I am trying to do that I am making a VI which will send the command and then I need to execute CRC code I don't think I will be able to make that CRC code which is in C in LabVIEW so what I am thinking is to execuate that C code after sending the command and make this whole as a single vi.. any suggestion or some other idea I will really appreciate.. 

 

Thanks,

Naqqash

Naqqash
0 Kudos
Message 10 of 12
(4,606 Views)