LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Entering C code in Labview

Hi,

Is there a way to directly enter and run C code in a VI, like how it is possible to enter math formulas using the formula node?

If not, what is the simplest way of running C code in LabView - thru creating DLLs?

Thank you so much for your help,
KMN
0 Kudos
Message 1 of 6
(2,538 Views)
A formula node has nothing to do with C code.

To use external code, have a look at e.g. this discussion.

LabVIEW itself is very powerful and full featured, so there is typically little need to resort to anything text based. What kind of formulas do you have in mind? I'm sure we'll be able to ease your transition to graphical programming. You won't regret it :).
0 Kudos
Message 2 of 6
(2,528 Views)
Thanks for the link.

The problem I am facing is that I have large amounts of legacy code (written in C); I would like to make VIs for all of them. I was originally thinking of just cutting-and-pasting the code into some kind of "C-code-node" in labview, but it sounds like this is not possible.

What would be the best way of doing this? The C code I have are all for data acquisition and a little bit of analysis.

Thanks a lot!
KMN
0 Kudos
Message 3 of 6
(2,525 Views)
Personally, I prefer to compile them into a DLL. Then you can embed them into simple VIs, similar to many of the tools e.g. in the analysis palette (e.g. look at the diagram of Sine Pattern.vi, it simply calls the NI advanced analysis library lvanlys.dll).
0 Kudos
Message 4 of 6
(2,517 Views)
If compiling the C code into Dll's is an option then that would be one way, although if the calling conventions, or the compiler isn't compatible with LabVIEW then this might be a lot of work. The better way (IMHO)is if you have good definition of what your C code is doing, both in DAQ and in analysis, writing it in LabVIEW. DAQ and analysis are what it shines at. For the most part you shouldn't suffer performance hits, and it should be much easier to maintain, particularly if, as it appears, you are moving to LabVIEW anyway.


Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 6
(2,514 Views)
There is a Code Interface Node (CIN) in LabVIEW. You will need to do more than just cut and paste to use it though. You might want to give it a try if your c-code is not very complicated.

Try searching the NI site for "LabVIEW CIN" (without the quotes).

The best way is usually to create a C-wrapper. This is a DLL that has public calls to each of your c-functions. you can then use a Call Library Node to access these functions. If you look at most of the advanced analysis VIs in the full or pro packages of LabVIEW, their subVIs are mainly just Call Library Nodes.

Hope that this helps,
Bob
0 Kudos
Message 6 of 6
(2,511 Views)