LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing C code in LabVIEW

Solved!
Go to solution

Thank you, cbutcher .

 

From what BowenM and cbutcher said, I understand that it is impossible to use LabVIEW alone. I need another software to write and compile the C code. 

 

Thanks to everyone.

0 Kudos
Message 11 of 16
(300 Views)

@muneerkun wrote:

 

So, only if LabVIEW can deal with C codes, it will be a great alternative. I thought that any software is initially made using C codes and instructions. So, I thought any compiling software can compile C codes in the first place. 


I can't be sure that MS Word or MS Excel are written in C(++) but the chance is pretty good and they don't compile C(++) code either! Smiley LOL Just as many 100'000 other programs out there.

 

So your assumption is just that, an assumption and a wrong one at that. While it would be theoretically possible to add a full C node in LabVIEW and integrate a complete C compiler in it too, this is not really something most users want. Most C programmers do not want to use LabVIEW and most LabVIEW programmers do not want to use C, as that is one of the reasons they started with LabVIEW.

 

Also there are many not so trivial problems that would be pretty difficult to solve. A real C program (unlike the Formula Node) does require the programmer to allocate memory and deallocate it again afterwards, while the whole idea behind LabVIEW is that memory is usually fully managed in the background for you by LabVIEW. This is in fact one of several reasons that the Formula Node only supports the functionality it does. Make it simple enough to not introduce LabVIEW untypical things like having to worry about proper memory allocation and deallocation, converting between C datatypes and LabVIEW datatypes, worrying about C runtime specific flavors and gotchas, etc. etc.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 12 of 16
(268 Views)

@rolfk wrote:

@muneerkun wrote:

 

So, I thought any compiling software can compile C codes in the first place. 


I can't be sure that MS Word or MS Excel are written in C(++) but the chance is pretty good and they don't compile C(++) code either! Smiley LOL Just as many 100'000 other programs out there.

 



Thank you, Rolf, but both MS Word and Excel are not compiling softwares! Smiley Happy I made my assumption from the fact that C++ compiling programs (such as Visual Studio) can also compile C code. Even Arduino IDE can compile C and C++. Also, MATLAB can compile C using "mex function".

Anyway, I'm convinced of what you said in your last paragraph. Actually, LabVIEW graphical code is very great in programming, but it can't build codes on target embedded systems. It can only run codes using modules such as MakerHub LINX which is still limited for certain embedded systems like Arduino. That's why I still need C.

Thank you again.

0 Kudos
Message 13 of 16
(224 Views)
Highlighted

You could use LabWindows if you if you want to say in the NI ecosystem.  If you are wanting embedded type targets, there are embedded versions of the cRIO such as the System On Module and Single Board options.

 

In the end, I've had several places where the easiest thing to do was create my own peripheral using an MCU and serial communications to LabVIEW over through VISA calls.

Message 14 of 16
(210 Views)

I go the opposite way LabVIEW to text based langues, but the answer is still the same. Create a DLL. Once you have your c code, just compile it as a dll, and then import that into LabVIEW. You'll be able to call every function you have created directly in LabVIEW. Yeah, you do need to programs, but it doesn't make it any harder to do.

Message 15 of 16
(202 Views)

Thank you MHawk and randomguy77 

0 Kudos
Message 16 of 16
(111 Views)