Introduction to LabVIEW Programmers develop software applications every day in order to increase efficiency and productivity in various situations. LabVIEW, as a programming language, is a powerful tool that can be used to help achieve these goals. LabVIEW (Laboratory Virtual Instrument Engineering Workbench) is a graphically-based programming language developed by National Instruments. Its graphical nature makes it ideal for test and measurement (T&M), automation, instrument control, data acquisition, and data analysis applications. This results in significant productivity improvements over conventional programming languages. National Instruments focuses on products for T&M, giving them a good insight into developing LabVIEW.49438
This chapter will provide a brief introduction to LabVIEW. Some basic topics will be covered to give you a better understanding of how LabVIEW works and how to begin using it. This chapter is not intended to teach beginners LabVIEW programming thoroughly. Those wishing to learn LabVIEW should consider attending a National Instruments LabVIEW Basics course. Relevant information on the courses offered, schedules, and locations can be found at www.ni.com/training. If you have prior experience with LabVIEW, you can skip this chapter and proceed to the advanced chapters.
First, VIs and their components will be discussed, followed by LabVIEW’s dataflow programming paradigm. Then, several topics related to creating VIs will be covered by explaining the front panel and block diagram. The chapter will conclude with descriptions of icons and setting preferences.
1.1 VIRTUAL INSTRUMENTS
Simply put, a Virtual Instrument (VI) is a LabVIEW programming element. A VI consists of a front panel, block diagram, and an icon that represents the program. The front panel is used to display controls and indicators for the user, and the block diagram contains the code for the VI. The icon, which is a visual representation of the VI, has connectors for program inputs and outputs.
Programming languages such as C and BASIC use functions and subroutines as programming elements. LabVIEW uses the VI. The front panel of a VI handles the function inputs and outputs, and the code diagram performs the work of the VI. Multiple VIs can be used to create large scale applications, in fact, large scale applications may have several hundred VIs. A VI may be used as the user interface or as a subroutine in an application. User interface elements such as graphs are easily accessed, as drag-and-drop units in LabVIEW.
IGURE 1.1
1.1.1 THE FRONT PANEL
Figure 1.1 illustrates the front panel of a LabVIEW VI. It contains a knob for selecting the number of measurements per average, a control for selecting the measurement type, a digital indicator to display the output value, and a stop button.An elaborate front panel can be created without much effort to serve as the user interface for an application. Front panels and LabVIEW’s built-in tools are discussed in more detail in Section 1.5.
1.1.2 BLOCK DIAGRAM
Figure 1.2 depicts the block diagram, or source code, that accompanies the front panel in Figure 1.1. The outer rectangular structure represents a While loop, and the inner one is a case structure. The icon in the center is a VI, or subroutine, that takes the number of measurements per average as input and returns the frequency value as the output. The orange line, or wire, represents the data being passed from the control into the VI. The selection for the measurement type is connected, or wired to the case statement to determine which case is executed. When the stop button is pressed, the While loop stops execution. This example demonstrates the graphical nature of LabVIEW and gives you the first look at the front panel, block diagram, and icon that make up a Virtual Instrument. Objects and structures related to the code diagram will be covered further in Section 1.6.
LabVIEW is not an interpreted language; it is compiled behind the scenes by LabVIEW’s execution engine. Similar to Java, the VIs are compiled into an execut- able code that LabVIEW’s execution engine processes during runtime. Every time a change is made to a VI, LabVIEW constructs a wire table for the VI. This wire table identifies elements in the block diagram that have inputs needed for that element