07-12-2020 09:48 AM
I use to program in C language in Microcontrollers.
Sometimes we make C code, which if we check for all the values it can take and check c code output, it takes lots of time since MCU are generally low speed.
What I want to do is:
Write C function in labview, and pass all values and see output range. Can it be done.
Implemeting by calling labview blocks is easy that I can do. I want to know if I can copy entire C code and pass parameters into it and see.
07-12-2020 11:56 AM
What is your OS? Under windows, you can turn your text code into a dll and call it in LabVIEW.
07-13-2020 02:34 AM
LabVIEW NXG can do this 😋: https://www.ni.com/documentation/en/labview/latest/c-prog/c-node-overview/
07-14-2020 03:34 AM - edited 07-14-2020 03:37 AM
wiebe@CARYA wrote:
LabVIEW NXG can do this 😋: https://www.ni.com/documentation/en/labview/latest/c-prog/c-node-overview/
The Formula Node in LabVIEW is a (less extensive) variant of this. It uses C syntax, with a few notable differences, and allows to execute simple C code in it. However you do not have libraries like ANSI C or similar available and definitely not other functions (but that last one is the same for the NXG node).
There also was the C node but that was only available if you had the LabVIEW C Generator Toolkit installed. This Toolkit was meant to allow translating VIs into (rather convoluted C++ code) that then could be compiled with the toolchain for a specific embedded controller target. But NI discontinued that somewhere around LabVIEW 2017 as it was pretty much unsupportable.
07-15-2020 02:15 AM
07-15-2020 03:41 AM
That won't be easy.
LabVIEW's threading model doesn't translate to C very well. Same for LabVIEW's polymorphism model and >1D arrays, just to name a few problems.
To support only 'trivial' VIs would require a definition of 'trivial'. But I suspect it will be limited beyond usefulness.
07-17-2020 03:42 AM
One extra complication in LabVIEW, to what Wiebe already names is the built in UI in every VI. Porting that to embedded targets is basically not a possibility, and even for NI's Linux realtime targets only for very specific models an option (with significant reduction in functionality in comparison to a desktop system).
Matlab started as text based scripting system in the first place and eventually gained some UI capabililities, although that really is tacked on to the whole and not a fundamental part of a function like in a LabVIEW VI. Translating that to C(++) is a comparably easy task, although even the resulting Matlab generated code isn't really very straightforward to follow. But it's simply sequential function calls that need to be translated to C, which is pretty much a 1 to 1 translation. A LabVIEW VI is a lot more than just a function even if it doesn't look like it when you work in LabVIEW.
07-19-2020 02:14 AM
labview c code generator was doing this no?
NI have discontinued the product though
07-19-2020 05:03 AM
@Vindhyachal.Takniki wrote:
labview c code generator was doing this no?
NI have discontinued the product though
Yes the C Code Generator was basically doing this. And it was discontinued because it was basically unsupportable.
People with the necessary knowledge to adapt the generated code to their specific target (you need some form of platform abstraction layer that translates between the LabVIEW generated code and platform specific resources like mutex, semaphore, threading and such rather complex mechanismes) won’t likely go to start code development in LabVIEW. If you know how to do that you are often much faster to do the rest in C(++) too.
Even if you can use the NI provided translation layers because your OS/compiler platform is exactly the same, most fail in getting the make scripts to produce a legit output. C(++) make scripts for non trivial library projects tend to get pretty complicated.