LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Translate C code into LabVIEW

Hi, I have a function in C/C++, and I am wondering how I can have it translated into LabVIEW.

 

Thanks,

Andrea

0 Kudos
Message 1 of 4
(2,796 Views)

You can either create a dll from it or actually translate and use LabVIEW functions. Depends on how much you understand C/C++.

0 Kudos
Message 2 of 4
(2,779 Views)

You can re-write it in LabVIEW (obviously! Smiley Tongue) or you can call the C code (you'll need to create a DLL) with the Call Library Function Node.

 

EDIT: Too slow again!

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 3 of 4
(2,773 Views)

There are three ways to use the code in LV.

 

First create a DLL or .Net assembly and call it from LV.

 

Second use a Formula Node. You can enter your C code directly there.

 

Third rewrite the code in LV.

 

Which is approiate will depend on your Code.

 

Rewriting in LV will cost most work and you need to have a good experience in programming in C and LV.

 

Most language constructs of C are available in LV but not all, e. g. there is no while loop. The While loop in LV is a do { ...} while loop. It will execute at least once. For a while loop you must use a Case with a containing While loop. since your termination expression must be used twice create a subVI for it.

Another thing which will go not easy to handle is the switch statement. Basicly the Case structure is the same but you must take care of the following code in C:

 

case <value1>
  {
...
  }

case <value2>
  {
...
  }
  break;

case <value3>
  {
...
  }
  break;

 

 

You must handle this by additional nested Case structures.

 

Most runtime functins are available or can be build using two or more LV function, e. g. fprintf can be created by Format Into String followed by a File Write.

 

If your code contains functions pointer thats no problem. VI references are function pointers. Open VI Reference creates a function pointer and Call by Reference uses it.

 

Since you are mentioning C++ you may need to have a look to the object oriented programming in LV.

 

OK, I'm the last one, but Ihe written the most text and some hints. Smiley Happy

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 4
(2,763 Views)