Can LabVIEW C?
Table of Contents
Introduction
For many years, the LabVIEW graphical programming language, with its integrated graphical user interface, has been known as an easy-to-use development tool for building data acquisition and instrument control applications and is especially well suited for quickly prototyping systems. However, in some ways, the simplicity and speed of developing a system with LabVIEW has hidden the fact that LabVIEW is in fact a complete programming language, suitable for handling the biggest and most complex applications that engineers and scientists face today.
LabVIEW has many components that are similar to C and is flexible enough to allow developers to incorporate existing C code or other external code modules in their LabVIEW applications. In addition, LabVIEW provides a streamlined development experience that reduces time to measurement due to various ease of use and built-in measurement features. This paper outlines the similarities in functionality of C and LabVIEW and how to use these standard programming structures and methods. Since this paper discusses the general programming capabilities of LabVIEW, the examples below are not industry-specific.
Note:
- Performance: Although performance is mentioned when appropriate, this paper is not designed to be a performance comparison between C and LabVIEW.
- User interface: Many C development tools include user interface editors. However, the ANSI C examples used in this paper do not include a user interface in order to allow for maximum portability. For reference, this paper also includes LabWindows/CVI executables that include ANSI C user interfaces comparable to the LabVIEW user interfaces.
Recommended Software:
- To view and run the LabVIEW examples: Evaluate LabVIEW online, by download, or by DVD
- To compile and run the C examples: A C compiler or LabWindows/CVI Evaluation Software
- To run the LabWindows/CVI executables: LabWindows/CVI Run Time Engine or LabWindows/CVI Evaluation Software
Example 1 - Basic Structures and Methods
![]() |
LabVIEW contains all the basic programming structures and methods found in C, such as loops and arrays. The following application note compares C and LabVIEW examples that generate and sort an array of random numbers. These examples illustrate the concepts of loops, arrays, and data manipulation in C and in LabVIEW. |
Application Note: Can LabVIEW C? - Example 1: Basic Structures and Methods
Example Code: Generating and Sorting Numbers in LabVIEW and C
Example 2 - More Complex Programming Concepts
![]() |
The following application note illustrates the concepts of data structures, code modularization, file I/O, and data analysis in C and LabVIEW. Specifically, the examples perform tasks commonly used by a teacher’s assistant such as entering enter student information and grades and performing analysis on the data. |
Application Note: Can LabVIEW C? - Example 2: More Complex Programming Concepts
Example Code: Teacher's Assistant in LabVIEW and C
Example 3 - Code Reuse in LabVIEW
![]() |
The previous two examples demonstrate the similarities between LabVIEW and C, as well as LabVIEW’s capability as a full-featured programming environment. Additionally, LabVIEW graphical programming techniques and built-in features often allow for faster and more efficient ways to solve problems. |
At the same time, there are certain tasks that may be better suited for a traditional programming language such as C, or there may be times when an engineer is restricted to using a specific programming language as his primary development environment but still wants to take advantage of the unique features of LabVIEW.
LabVIEW offers multiple solutions for both scenarios. LabVIEW can call external code contained in dynamic link libraries (DLLs) or shared libraries, and code exposed through ActiveX or .NET interfaces. In addition, LabVIEW code can be reused in other programming languages by building a LabVIEW DLL or shared library, or by using ActiveX. The following application note consists of two parts: the first part focuses on calling a C-built DLL from LabVIEW, and the second part focuses on calling a LabVIEW-built DLL from C.
Application Note: Can LabVIEW C? - Example 3: Using the Right Tools with LabVIEW
Example Code: Calling a C-built DLL in LabVIEW to Generate and Sort an Array of Numbers
Example Code: Calling a LabVIEW-built DLL In C to Acquire, Analyze, and Present Data
Advanced Programming Techniques
LabVIEW users must follow much of the same procedures as developers using more traditional languages like C, but at times there are unique tools and practices that simplify the development process. For example, LabVIEW can perform tasks not easily achieved in C, such as object-oriented programming and parallel programming. Focusing on parallel programming, the advent of multicore processors has made many software developers realize the need for a better way to design parallel code. As a graphical programming language based on the core principles of dataflow programming, LabVIEW offers the programmer a simplified approach to parallel programming, one which allows the software developer to immediately take advantage of the processing performance available from the latest generation of multicore processors.
To learn more, read the Multicore Programming Fundamentals white paper series.
Conclusion
This paper discussed a small sampling of the programming capabilities of LabVIEW that are also available in C, including array manipulation and support for DLLs. To learn how to use advanced programming techniques in LabVIEW such as object-oriented programming, and how to implement standard software engineering practices in LabVIEW, visit the Software Engineering resource page.
With the unique approach to programming using block diagrams and dataflow, and ready-to-use features such as measurement analysis libraries, LabVIEW saves development time for engineers and scientists when compared to traditional languages such as C. To evaluate the capabilities of LabVIEW for yourself, try LabVIEW online.
Reader Comments | Submit a comment »
Apples and Oranges
This discussion did not include C with
Objects C++ nor did it discuss the cost per
deployment as well as the cost for the tool
chain.
When rapid reconfiguration such as research
and laboratory work LabView rocks but in
production where cost per production unit is
a factor the high cost per license, the large
footprint for deployment, and the lack of
transportable source makes LabView not the
language and environment of choice. The
advantages touted of ease and speed of
development is erased when good proven
libraries are present in the C and C++
toolchain.
LabView and C/C++ are both great tools but
not in the same arena.
- Jul 15, 2008
Inappropriate comparison
This comparison is disingenuous. C is
an old language with faster execution
and a more primitive development
environment.
It would be more appropriate to compare
LabVIEW to a fair competitor like Visual
C++ or Java.
To compare like with like, consider the
total development environment
(including the preferred source code
control solution). Consider factors such
as development time, execution speed,
code reuse, and user interface
experience.
- Jul 15, 2008
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).



