Professional Documents
Culture Documents
Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
2 Virtual Instruments with LabVIEW
Introduction
LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development
environment for a visual programming language from National Instruments. The graphical language is named
"G". Originally released for the Apple Macintosh in 1986, LabVIEW is commonly used for data acquisition,
instrument control, and industrial automation on a variety of platforms including Microsoft Windows, various
flavors of UNIX, Linux, and Mac OS X. The latest version of LabVIEW is version LabVIEW 2010. Visit National
Instruments at www.ni.com.
LabVIEW programs are called Virtual Instruments, or VIs, because their appearance and operation imitate
physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools
for acquiring analyzing, displaying, and storing data, as well as tools to help you troubleshoot your code.
Here we will go through some simple LabVIEW examples in order to learn basic LabVIEW programming. For
more background information about LabVIEW, see the tutorial “Introduction to LabVIEW”.
http://home.hit.no/~hansha/?tutorial=labview
You may also want to take a closer look at the “Interactive Training” called “LabVIEW Starter”:
http://home.hit.no/~hansha/training/labview/starter/
When you open a blank VI, an untitled front panel window appears. This window displays the front panel (the
user interface) and is one of the two LabVIEW windows you use to build a VI. The other window contains the
block diagram (the code).
In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls are knobs, push
buttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays.
Step 2: Create the block diagram (code) to make the program work as expected.
[End of Task]
Step 2: Create the block diagram for the program using a While Loop. The Date and Time strings should be
updated every second.
[End of Task]
You need to use a While Loop and an Event Structure inside the While loop to solve the problem.
The Event structure is used to respond to buttons clicks, such as when the user clicks the “Calculate” or “Stop”
buttons. When the user clicks the “Calculate” button, the answer should be calculated. When the user clicks
the “Stop” button, the program should stop running.
[End of Task]
Arrays
Arrays are very powerful to use in LabVIEW. In all your applications you would probably use both one-
dimensional arrays and two-dimensional arrays.
Task 4: Arrays
[End of Task]
SubVIs
Creating and using SubVIs are very important in LabVIEW. A SubVI is like a function or subroutine in other
languages. Here we will learn to create and use existing SubVIs.
Task 5: SubVIs
Step 1: Create a SubVI from the simple Calculator created in a previous task.
You have to create an Icon for you SubVI using the Icon Editor:
Step 2: Create a new program that uses the SubVI, like this:
[End of Task]
Plotting Data
LabVIEW have powerful features for plotting different kind of data. Below we see the Graph palette in
LabVIEW.
Task 6: Plotting
You may want to use the following function in order to create some random data:
[End of Task]
Virtual Instruments
Now you have learned the basic features in LabVIEW and you are ready to create your own “Virtual
Instruments”.
In this task you will need everything you have learned so far (and probably a little more).
1. Toolbar
2. Owned Label
3. Numeric Control
4. Free Label
5. Numeric Control Terminal
6. Knob Terminal
7. Numeric Constant
8. Multiply Function
9. Icon
10. Knob Control
11. Plot Legend
12. XY Graph
13. Wire Data Path
14. XY Graph Terminal
15. Bundle Function
16. SubVI
17. For Loop Structure
Below we see the front panel and the block diagram for the virtual instrument.
The SubVI (number 16) could be reading the temperature from a temperature sensor using a DAQ (Data
Acquisition) device, but in our case we will just create a simple “simulator” using, e.g. the built-in “Random
Number” VI to create random temperature values.
We will learn more about acquiring data from DAQ devices later.
Faculty of Technology
Kjølnes Ring 56
www.hit.no
E-mail: hans.p.halvorsen@hit.no
Blog: http://home.hit.no/~hansha/
Room: B-237a
Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01