Professional Documents
Culture Documents
LabVIEW Handson Manual
LabVIEW Handson Manual
Graphical Programming
Hands-On Seminar
Customer Manual
Copyright
2010 National Instruments Corporation. All rights reserved.
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including
photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of
National Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by
copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to
others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable
license or other legal restriction.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section
on ni.com/legal for more information about National Instruments trademarks.
Product and company names mentioned herein are trademarks or trade names of their respective companies.
Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have no
agency partnership, or joint-venture relationship with National Instruments.
Patents
For patents covering National Instruments products/technology, refer to the appropriate location: HelpPatents in your software, the
patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 457990-0, Belgium 32 (0) 2 757 00 20, Brazil 55 11 3262 3599,
Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00,
Finland 358 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000, Israel 972 3 6393737,
Italy 39 02 41309277, Japan 0120-527196, Korea 82 02 3451 3400, Lebanon 961 0 1 33 28 28, Malaysia 1800 887710,
Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466, New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60,
Poland 48 22 3390150, Portugal 351 210 311 210, Russia 7 495 783 6851, Singapore 1800 226 5886,
Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00,
Switzerland 41 56 2005151, Taiwan 886 02 2377 2222, Thailand 662 278 6777, Turkey 90 212 279 3031,
United Kingdom 44 0 1635 523545
iii
ni.com
Contents
National Instruments Overview..................................................................................................................... 1
Exercise #1: Open and Run Final Application...................................................................................... 15
Exercise #2: Simulate Signal to Graph ................................................................................................. 28
Exercise #3: Taking a Basic Measurement ........................................................................................... 43
Exercise #4: Add Analysis and Output ................................................................................................. 57
Exercise #5: Write to File ..................................................................................................................... 67
Next Steps ................................................................................................................................................... 70
LabVIEW Modules and Toolkits ................................................................................................................ 77
iv
ni.com
Welcome to the Introduction to LabVIEW Graphical Programming HandsOn Seminar. This seminar introduces you to building measurement and
automation applications using graphical development. Through hands-on
exercises, you learn the concept of graphical programming and how you
can use it to build powerful instrumentation and data acquisition systems.
In some exercises, you will build LabVIEW virtual instruments (VIs). In
other exercises, you will run completed LabVIEW VIs. All of the examples
demonstrate the power and flexibility of the LabVIEW graphical
development paradigm.
By the end of this seminar, you will learn that no matter what
measurement you need to make, LabVIEW provides a solution.
ni.com
During todays seminar you will learn the basics of the LabVIEW
environment and create a data acquisition application that does the
following:
Acquires a temperature signal
Determines if the temperature is above a chosen level
Outputs a warning to the screen and a digital output to the hardware
Writes acquired data to file
In addition to those basic exercises we will review several case studies of
companies that have used LabVIEW and National Instruments hardware to
build advanced applications. For more examples of how engineers and
scientists have used our products please visit
http://www.ni.com/solutions.
Finally, information regarding modules and toolkits that increase
LabVIEWs functionality in different industries can be found in the
appendices.
ni.com
ni.com
Industrial
Software-defined
behavior
Modular
I/O
Embedded
4
ni.com
What is LabVIEW?
LabVIEW is designed to help you solve technical challenges you face daily.
Regardless of what industry you are in, LabVIEW has built in functions for
common tasks such as data acquisition and analysis, to more specialized
functions for applications such as control design, simulation, or RF design.
For those with a programming background, you will find all the
programming constructs you relay on such as case statements, For and
While loops, etc., as well as a wide array of ready to use functions
including string parsing, file i/o, and array manipulations.
You do not need to be a programmer to use LabVIEW, there are features
designed for both the non-programmer and for those who have extensive
application development background. For the non-programmer LabVIEW
offers Express VIs which are interactive, configuration oriented functions
which you parameterize and connect together to perform tasks such as
data acquisition, analysis and reporting.
Regardless of your programming experience LabVIEW has thousands of
built-in analysis functions, and a wide array of toolkits and modules that
offer specific functionality in areas such as real-time control, RF design,
SCADA application development, motion control and machine vision, to
name just a few.
ni.com
G
Programming
Language
Hardware Support
Analysis and
Technical Code
Libraries
Technology
Abstraction
Models of
Computation
ni.com
ni.com
Debugging tools
Assistants
Configurable functions
I/O Finder
Easy UI Development
Software Engineering Tools
Performance Tools
ni.com
ni.com
10
10
ni.com
Cameras
Hundreds of PLCs
11
What makes LabVIEW the superior choice for acquisition and control
applications is its ability to integrate with hardware to acquire real-world
data. LabVIEW delivers seamless connectivity with a wide range of
measurement hardware. You can use LabVIEW to quickly configure and
use almost any measurement device, from stand-alone instruments to
USB data acquisition devices, motion controllers, image acquisition
systems, and programmable logic controllers (PLCs).
If you use bench top instruments such as an Agilent Network Analyzer, or
other standalone instruments to make measurements, there are over
6,000 instrument drivers from over 250 instrument providers available
online that enable you to control these instruments from LabVIEW. You are
also opening yourself to use a wide range National Instruments hardware
products allow you to create solutions including rugged industrial
monitoring applications, bench top data acquisition, Real-Time process
control, prototyping embedded control systems, and handheld applications
running on a PDA to name just a few.
Given the time constraints of todays seminar we are going to focus on
how to acquire, analyze and present data using LabVIEW. However its
important to recognize that the capabilities of LabVIEW extend far beyond
simple data acquisition to include areas such as PID control, vision
inspection, Embedded design, rapid prototyping and so on.
11
ni.com
LabVIEW Fundamentals
12
12
ni.com
13
ni.com
14
ni.com
The LabVIEW Getting Started window appears each time you launch LabVIEW to assist you in
creating new applications or opening existing applications. Additionally you can use links on the
Getting Started window to find local and online help resources or open example programs to aid in
application design.
15
ni.com
2. Open the Intro to LabVIEW-DAQ Hands-on.lvproj Project in the Open section of the Getting
Started window or navigate to it by pressing Browse link and going to the LabVIEW
Handson folder on the desktop. Once opened, the Intro to LabVIEW-DAQ Hands-on Project
Explorer looks like this:
The Project Explorer provides a central location for you to include the different elements of an
application including LabVIEW code and other files like Microsoft Word and Excel documents. You
can include any file in a LabVIEW application. You can create folders and sub-folders to organize the
files in an application. Here, a few folders have been created as part of the example.
3. Expand the Solutions folder in the Project Explorer and open the 5-Write to File
(Solution).vi by double-clicking on it or right-clicking and selecting Open.. Every LabVIEW
application is made of a front panel and a block diagram. The front panel is the user
interface, whereas the block diagram contains the code that controls the functionality of
your application. You can toggle between the two windows by selecting Window Show
Block Diagram or Window Show Front Panel to see the other window. You can also switch
between the windows by pressing <Ctrl-E> on the keyboard or clicking either window if both
are present on your monitor.
16
ni.com
Hover the cursor over the different objects on the front panel. Notice that your cursor turns to a
pointer finger when above the Stop button, and turns into a text editor when above a text field. By
default, LabVIEWs Automatic Tool Selection will change the cursor depending on what operations
are possible. Also notice that as you move over any object, resizing boxes appear on its edges. Try
resizing a few objects sizes.
4. Notice the menu bar at the top of the window. We will discuss many of its basic items in
future pages and exercises. For now, the most important button to review is the Run
button, found on the left edge of the menu bar.
You must press the Run button to begin any LabVIEW application, and a broken run arrow tells you
that there are some unresolved errors in the code. Since LabVIEW is continually compiling code
throughout development, you can press the broken Run button at any time and a list of current
errors will appear.
5. Make sure that your CompactDAQ chassis is powered on, that its connected to your PC with
a USB cable and that the I/O modules are plugged in firmly to the chassis. Now press the Run
button in the LabVIEW application and watch as the application begins to record
17
ni.com
temperature data from the module plugged into the first slot of the CompactDAQ chassis.
Contact the instructor if your application isnt running as described.
Hold the end of the thermocouple and watch the values on the graph rise and fall accordingly.
Change the Alarm Level control to different values and hold the thermocouple so that it rises
above and below the value youve entered on the front panel.
As temperature rises and falls around the Alarm Level, look at the NI 9472 module in the
CompactDAQ chassis. One digital output line on this module has been programmed to drive a 5V
signal whenever temperature is greater than the value of Alarm Level. The modules LEDs indicate
the status of each digital line. These lines could be connected to other hardware, like a light or
buzzer, or other 5V devices.
6. Press the Stop button on the front panel once you are ready to move on.
Navigate to the block diagram.
LabVIEWs graphical programming makes application execution intuitive. In this case our application
does the following:
1. Acquires temperature data with the DAQ Assistant and displays it on a chart
2. Compares acquired data with Alarm Level
3. Outputs 0V or 5V to the digital output module based on the comparison in #2
4. Writes acquired data to file.
7. Distribute the front panel and block diagram windows so that both are visible in your
monitor. Once created, navigate to Window Tile Left and Right to tile the front panel and
block diagram on your monitor, or press <Ctrl + T>.
18
ni.com
Notice that for every object on the front panel, there is a terminal with the same name on the block
diagram. The functions and wires on the block diagram connect the inputs (controls) and outputs
(indicators) on the front panel. As you add objects to the front panel in future exercises youll see
that terminals are automatically created on the block diagram.
Additional Steps
8. The LabVIEW help system is a great way to learn about LabVIEW and answer your
programming questions. Press <F1> on the keyboard to start the help system. More
assistance can be found from the LabVIEW Help menu.
9. Expand Fundamentals LabVIEW Environment and explore the information available here,
click around and get a feel for how it is organized.
10. Take a few minutes to explore other topics in the help system.
11. Click on the Search tab and try searching on analysis functions for features you might need in
your applications.
End of Exercise 1
19
ni.com
Knobs/Dials
Graphs/Charts
Buttons
Digital Displays
Sliders
Thermometers
Customize and
create your own
15
The LabVIEW front panel includes over 300 controls and indicators
designed specifically for measurement applications. Each object is
configurable, enabling you to create professional graphical interfaces. A
control is a front panel object for user input. Simple examples of controls
include buttons, slides, dials, and text boxes. An indicator is a front panel
object that displays data to the user. Examples of indicators are graphs,
thermometers, and gauges. When you place a control or indicator on the
front panel, a corresponding terminal is placed on the block diagram.
20
ni.com
or
16
Build a front panel by dragging and dropping controls and indicators from
the Controls palette. Similar objects are divided into subpalettes for
easier navigation. Right click on any open space on the front panel to
bring up the Controls palette, and navigate through the palettes by
hovering over the category icon of object you want to add. Left-click on
an object in the palette and it will be placed on your cursor. Move the
object to the desired location and left-click to drop it onto the front panel.
Once placed you can move or resize the object, or right-click on the object
to adjust other properties.
To access front panel objects by name, press <ctrl + Space> while the
front panel is active and the Quick Drop dialog will appear. Search for
objects using any part of its name and a list of possible choices will appear
below. Double click on the name of the object you want it will be placed
on your cursor for use on your front panel.
21
ni.com
Configuration Based
Express VI
Standard VIs
17
We will now move to the block diagram window, where you will create the
VIs functionality. Individual functions, or subVIs, are wired together to
create your application logic. Functions can be broken into two types:
standard VIs and Express VIs. Both types of VIs can work together in an
application and both serve unique use cases.
Standard VIs are low level building blocks for an application. Each VI
performs a particular function and will output based on the inputs
provided. We will discuss how subVIs communicate on the following page.
Standard VIs provide a way to create customized functionality and
execution control. For todays exercises well use Express VIs, which are a
great way to learn LabVIEW, as well as make basic applications. As your
applications get more complex you will begin to use the standard VIs
more and more.
Express VIs are designed to streamline your application development.
There are over 40 Express VIs included in LabVIEW that enable you to
create complete measurement programs in seconds. These VIs were
created for the most frequently built applications with your productivity
and efficiency needs in mind. The power you have with Express VIs is
found in the configuration pages for each that you can individually
customize simply by double-clicking them. This will significantly reduce
the number of objects on your block diagram and the time needed to add
additional functionality.
22
ni.com
Dataflow Programming
23
ni.com
19
24
ni.com
Integer Numeric
String
Scalar
1D Array
2D Array
21
21
25
ni.com
For Loop
Run N times
22
Use While or For loops to enable sections of your LabVIEW code to run
repeatedly. A While loop will continue to execute until a stop condition is
specified. The stop condition can be a simple button press, or a series of
specific logical conditions. The For loop will execute a predetermined
number of times as specified by the number of iterations you wire to the N
input. You may also connect an array wire to the edge of a for loop and
leave the N input unwired. The For loops number of iterations will be
determined by the array size that is wired at its edge. This is called Auto
indexing.
To find the While and For loops, as well as other control structures, leftclick on any empty space on the block diagram and navigate to
Programming>>Structures.
26
ni.com
27
ni.com
28
ni.com
Click and then drag diagonally to form the While loop to the area you desire. You can resize the
While loop by dragging any of the resizing boxes that appear when your cursor hovers above the
loops edges.
4. You can also create a While loop by pressing <Ctrl + Space Bar> to bring up the Quick Drop
dialog. Begin typing While Loop and it will appear in the list of possible objects. Doubleclick its name and it will appear on your cursor for use on the block diagram. Since youve
already placed the while loop, release the while loop you found using Quick Drop by rightclicking.
5. While loops have two terminals in their bottom left and right corners.
29
ni.com
30
ni.com
Left-click where you would like to place it on the front panel. Enlarge the Stop button by moving your
cursor to one of the buttons edges and dragging the resizing boxes.
7. Look again at the block diagram. Notice that a terminal for the stop button has appeared.
This terminal acts as the connector from the front panel to the functionality of the block
diagram. Click the stop terminal and drag it next to the loop condition terminal in the While
loop.
8. Move your cursor to the right edge of the stop terminal and notice that the edge of the
terminal is blinking and the cursor now looks like a spool. This is the wiring tool that lets you
draw wires between different objects on the block diagram. Left-click the edge of the stop
terminal and drag the cursor until you are hovering over the left edge of the While loops
condition terminal, and then release. The wire is now connected between the stop terminal
and the conditional terminal.
or
With the While loop now having a way to exit, the broken Run arrow is replaced with a Run arrow
and your application is ready to run, but youll need to add more code to accomplish the tasks of this
exercise.
9. The other terminal in the while loop, the loop iteration counter , outputs the number of
times the While loop has iterated. That information may be useful depending on your
application, but we will not be using it today, it is not required that we do anything with it in
order to run our program.
10. Create a simulated signal. Press <Ctrl + Space Bar> to bring up the Quick Drop dialog and
begin to type Simulate Signal. Double-Click Simulate Signal once you see it in the box
below where you are typing and the Simulate Signal Express VI will automatically appear on
your cursor.
31
ni.com
11. Double-click to place the Simulate Signal Express VI inside the While loop and its
configuration dialog will appear.
12. Change the Signal Type, Amplitude, Frequency, Offset and Phase values in the Signal portion
of the dialog and see the changes in the Results Preview portion. Deselect the Use signal
type name box in the Signal Name section and enter Simulated Signal as the name.
Once you have chosen the signal you want to display, press OK. The Simulate Signal Express VI has
now been customized based on the settings you provided.
13. Connect the simulated signal to a chart by moving to the front panel and bring up the Quick
Drop dialog and type the word chart. Place the Waveform Chart on the front panel at the
location you prefer.
14. Return to the block diagram and move the charts icon into the While loop, to the right of the
Simulate Signal Express VI. Connect the output of the Simulate Signal Express VI (Simulated
Signal) to the chart terminal. Notice that the chart terminal changed colors to reflect the
data type it received.
32
ni.com
15. Return to the front panel and Run the VI. The simulated signal you created in the Express VI
is now displayed on the chart. Press the Stop button when you are ready to move on.
16. Add controls to adjust signal frequency and amplitude while the program is running. Rightclick on an empty space on the front panel to bring up the Controls palette, find the knob
control (Modern Numeric Knob) and place it on the front panel. Double-click on the
knobs label and change it to Amplitude.
17. Repeat step #13 to make another knob for frequency. Change its label to Frequency. Doubleclick the maximum value on Frequencys scale and change it to 50.
Front Panel
33
ni.com
Block Diagram
18. On the block diagram, move the Amplitude and Frequency controls inside of the while loop
and connect them to the associated inputs of the Simulate Signal Express VI. Once both
terminals are inside the while loop, on the left side of the Simulate Signal Express VI, hover
your cursor over the right side of each terminal until the wiring tool appears on the cursor.
Left-click and drag the connection to the identically named input on the Express VI. Your
block diagram should look like the image above.
19. Run the VI. Press the Run arrow, manipulate Amplitude and Frequency and notice the chart
display changes accordingly. The Charts y-axis auto-scales to maximize the signals size on the
display. To disable that feature, right click the chart and deselect AutoScale Y.
You can now change the upper and lower ranges of the Y-axis by clicking on the numbers along the
axis and typing in new values.
20. Stop the VI by pressing the stop button.
34
ni.com
Helpful tips
LabVIEW provides several tools that can help you develop your applications. The next few steps will
show how to use some of the most important programming assistance tools.
Block Diagram Cleanup
21. Use Block Diagram Cleanup to organize your block diagram. As you program, and especially
as you learn how to program in LabVIEW, you are not always thinking about layout and
readability. This can result in a poorly organized block diagram.
LabVIEW Block Diagram Cleanup is a built-in tool that organizes your code, making it easier for you
and others to understand how your program functions. Press the Block Diagram Cleanup icon found
on the menu bar.
Your block diagram should now be organized, with cleaner wires and an even distribution of code
elements.
To customize how the Block Diagram Cleanup tool organizes your code, navigate to the Options
menu at Tools Options and scroll to the Block Diagram Cleanup section.
This menu lets you customize how far wires, structures, functions and terminals will be spaced from
each other and from the edges of your block diagram. Click OK when you are ready to move on.
35
ni.com
Highlight Execution
22. Use Highlight Execution to observe how your application runs. Press the Highlight Execution
button on the menu bar. Notice that the light bulb icon now appears to be on.
23. Run your application with Highlight Execution turned on. Press the Run arrow and watch as
your code executes step-by-step. While not always necessary for simple applications, the
Highlight Execution tool is a powerful resource for trouble shooting complex programs and
determining if your code performs as expected.
Context Help
24. Use Context Help to identify object details while programming. Press the Context Help
button in the upper right portion of the block diagram.
25. With the Context Help active, hover your cursor over different objects on the block diagram
and front panel of Simulate Signal to Graph.vi. As you do so, the Context Help Window
provides details including descriptions and wiring diagrams.
36
ni.com
26. Right-click on the block diagram and navigate around the palettes. Notice that the Context
Help window provides details on the objects while they are in the palettes. Also notice that
for some objects, the Context Help window provides a link for Detailed Help This link will
open the LV Help and give you more information.
27. Save 2-Simulate Signal to Graph.vi and close.
End of Exercise #2
37
ni.com
Highlight Execution
Highlight Execution Use the Highlight Execution tool to see how your
code executes. This tool will slow down execution speed and allow you to
see the input and output values of the different VIs in your application and
compare them to what you expect. This feature can be turned on or off
while an application runs. You can also place break points in your code so
that it begins step by step processing at certain points of interest.
Block Diagram Cleanup The Block Diagram Cleanup tool organizes
terminals and functions in an orderly way that you can customize, allowing
you to spend more time on improving your application and less time
worrying about arranging objects in an orderly way. To customize the
Cleanup tools algorithm go to the Block Diagram: Cleanup sections in
the Options Menu found at Tools>>Options.
Context Help The Context Help window provides information on any
front panel and block diagram object. Hover over any object and a brief
description will appear. If available, the window will also provide a link to
more information in the LabVIEW Help (Help>>Search the LabVIEW
Help).
38
ni.com
Data Acquisition
with LabVIEW
29
39
ni.com
NI DAQ Platforms
One application,
multiple targets
Wireless / Ethernet
USB
PCI / PCIe
PXI / PXIe
CompactDAQ
Modular USB
31
40
ni.com
Built-in Signal
Conditioning
Hot-swappable modules
Direct sensor
connectivity
NI CompactDAQ
32
41
ni.com
42
ni.com
4. Click Configure and Test This Device Using NI Measurement & Automation Explorer.
Note: NI Measurement & Automation Explorer is a configuration utility for all National Instruments
hardware.
5. The Devices and Interfaces section under My System shows all the National Instruments
devices installed and configured on your PC. The NI-DAQmx Devices folder shows all the NI-
43
ni.com
8. The device passes the self test, which means it has initialized properly and is ready to be used
in your LabVIEW application.
Program LabVIEW Application
9. Create a new VI from the Project Explorer. Right click the Exercises folder and select New
VI. Once opened, Save the VI in the Exercise folder under the name 3-Basic
Measurement.vi.
10. Press <Ctrl +T> to tile front panel and block diagram windows.
11. Pull up the Functions Palette by right-clicking the white space on the LabVIEW block diagram
window.
12. Move your mouse over the Express Input palette, and click the DAQ Assistant Express VI.
Left-click the empty space to place it on the block diagram.
44
ni.com
45
ni.com
15. Change the CJC Source to Built In and Acquisition Mode to Continuous Samples. Select the
correct thermocouple type (J or K) Click the Run button. You will see the temperature
readings from the thermocouple in test panel window.
Note:
Thermocouple types can often be
identified by their lead wire colors:
Type
+
J
White
Black
K
White
Green
16. Click Stop and then click OK to close the Express block configuration window to return to the
LabVIEW block diagram.
17. LabVIEW automatically creates the code for this measurement task. Click Yes to
automatically create a While Loop.
18. On the front panel, right-click to bring up the controls palette and add a waveform chart
indicator (Express>>Graph Indicators>>Chart). Rename Waveform Chart to Temperature
46
ni.com
19. Notice that a connection is made to the block diagram. Move the Temperature icon inside
the while loop. Wire the DAQ Assistant with the Temperature Chart.
20. Your block diagram should now look like the figure below. The while loop automatically adds
a stop button to your front panel that allows you to stop the execution of the loop.
21. Save your VI, as Exercise 3.vi. You will re-use this in exercise 4.
22. Run the VI
Additional Steps
Express VIs make creating basic applications very easy. Their configuration dialogs allow you to set
parameter and customize inputs and outputs based on your application requirements. However, to
optimize your DAQ applications performance and allow for greater control you should use standard
DAQmx driver VIs. Right Click the block diagram and select Functions Measurement I/O Palette
NI-DAQmx.
23. Before you generate DAQmx code you need to remove all the code that was automatically
created by the Express VI. Right click on the while loop and select Remove While Loop.
Then click the Stop button control, and press the <Delete> key to remove the Stop button.
Repeat actions for any unconnected wires that may remain. You can press <Ctrl + B> to
remove all unconnected wires from a block diagram. You can leave the Temperature Chart
on the diagram.
47
ni.com
24. Convert Express VI code to standard VIs. While not all Express VIs can be automatically
converted to standard VIs, the DAQ Assistant can. This will allow for greater application
control and customization. Right-click on the DAQ Assistant Express VI you created in this
exercise and select Generate NI-DAQmx Code.
25. Move the Temperature indicator inside the while loop and connect it to the same wire the
data indicator is at. Then delete the data indicator.
As you noticed the Express VI has been replaced by four VIs. Well examine their functionality in the
following steps.
26. Open Context Help by clicking the Context Help icon on the upper right corner of the block
diagram. Hover your cursor over each VI and examine their descriptions and wiring diagram.
27. DAQmx Start Task.vi starts the acquisition based on the parameters it receives from the
currently untitled VI on the far left.
28. DAQmx Read.vi reads data from preconfigured FIFO memory location.
29. DAQmx Clear Task.vi stops the current acquisition and releases the resources (memory,
configured hardware clocks, etc.).
30. Double-click the untitled VI and open that VIs block diagram (code shown below).
48
ni.com
All the parameters that are wired as inputs to the different DAQmx setup VIs reflect the settings you
originally configured in the DAQ Assistant Express VI.
Note: By moving these parameter and setup VIs onto the block diagram, you can now
programmatically change their values without having to stop your application and open the Express
VI configuration dialog. This can save development time and possibly optimizing performance by
eliminating unnecessary settings depending on your application.
31. Return to the main VI and run it.
32. Close the VI, do not save any changes.
Using the LabVIEW Example Finder
The LabVIEW Example Finder provides hundreds of example application to use as reference or as the
starting point for your application.
33. Open the LabVIEW Example Finder to find DAQ examples that use DAQmx standard VIs. Go
to Help Find Examples to launch the LabVIEW Example Finder.
34. Browse to the DAQmx Analog Measurements folder from the Browse tab at Hardware Input
and Output DAQmx Analog Measurements>>Temperature and open Acq Thermocouple
Sample.vi..
49
ni.com
36. Set the Thermocouple type and the Physical Channel to match the CompactDAQ chassis
channel (cDAQ1Mod1/ai0) and run the application.
50
ni.com
Press the Run button several times while holding and releasing the thermocouple on the
CompactDAQ chassis and observe the value change on the front panel.
37. Open the block diagram and examine the code. This VI only uses standard VIs instead of
Express VIs, which allows much more customization of inputs and run-time configuration.
Acq Thermocouple Sample.vi has no while loop to allow for continuous execution, and the
remaining steps of this exercise will focus on adding that functionality.
38. Add a While loop and Stop button to Acq Thermocouple Sample.vi. Right-click the block
diagram to bring up the Functions palette. Find the While Loop on the Programming
Structures palette and drag a while loop over the DAQmx Read.vi. You may need to spread
the VIs across the block diagram so that there is room. You can create additional space by
holding the <Ctrl> key and dragging a box on the block diagram or front panel.
39. Right click the While Loops Conditional terminal and select Create Control. This
automatically wires a Stop button to the terminal.
51
ni.com
Notice that the Stop button has appeared on the front panel.
40. Run the VI. Acq Thermocouple Sample.vi now runs continuously.
41. Stop the VI.
42. Save the customized example VI to the Project. Go to File Save As, select Copy
Substitute Copy for Original and name the VI Thermocouple Customized Example.vi. Save
this VI in the same folder as the rest of your project files. This allows for further development
without overwriting the original LabVIEW example.
Note: Compare the modified example to the VI you build earlier in this exercise.
What are the differences? Discuss the difference with the other attendees and the instructor. What
are the benefits of the each method?
End of Exercise 3
52
ni.com
Analysis and
Signal Processing
36
53
ni.com
Mathematics
Waveform Generation
Waveform Conditioning
Waveform Monitoring
Waveform Measurements
Signal Generation
Signal Operations
Windows
Digital Filters
Spectral Analysis
Transforms
Point-by-Point
Numeric
Elementary and Special Functions
BLAS/LAPAC-based Linear Algebra
Curve Fitting
Interpolation / Extrapolation
Probability and Statistics
Optimization
Ordinary Differential Equations
Geometry
Polynomial
Formula Parsing
1D & 2D Evaluation
Calculus
37
Often, raw data is not the only information sought after in a measurement
application. LabVIEW provides more than 450 built-in comprehensive
tools designed specifically for analyzing measurements and processing
signals. Incorporate LabVIEW functions into your applications in order to
perform in-line analysis and to add decision-making capabilities to your
applications. Available functions include mathematics libraries, with linear
algebra functions based on the industry-standard LAPACK/BLAS
algorithms, advanced signal processing tools, and measurement analysis
functions, such as FFT and power spectrum, signal generation, digital
filters, and curve fitting. There are 12 Analysis Express VIs for even more
ease of use in your analysis needs. In this seminar we will not cover these
analysis functions in depth. For more information, visit ni.com/analysis.
In addition, National Instruments offers a series of toolsets that extend
the analysis capabilities of LabVIEW for more specialized applications,
such as sound and vibration analysis, order analysis, and digital signal
processing. By building analysis capabilities directly into your application,
you eliminate the need for performing post-acquisition analysis and obtain
results quickly.
LabVIEW Full / Pro offers general-purpose signal processing, analysis, and
math tools to simplify development for a broad variety of applications.
54
ni.com
Text-based
MathScript Node
38
Like other functions in the block diagram, analysis functions are available
in standard VIs and Express VIs. Standard VIs will give you greater
control over the order, inputs and execution of your applications analysis.
Express VIs make adding analysis functionality quick and easy at the
expense of some control in your applications execution.
In addition to the over 600 analysis VIs in LabVIEW, there is LabVIEW
MathScript, which enables you to implement your algorithms textually and
incorporate your .m files into your application. This seminar does not
include further detail concerning LabVIEW MathScript. For more
information visit ni.com/mathscript.
55
ni.com
56
ni.com
3. Create an alarm that signals if acquired temperature goes above a user-defined level. Rightclick the front panel to open the Controls palette (Modern Numeric) and place a numeric
control on the front panel.
57
ni.com
4. Change the numeric control's name to "Alarm Level." Double-click the control's label and
replace the generic text with "Alarm Level"
5. Use the Comparison Express VI to compare the acquired temperature signal with the Alarm
Level control. Switch to the block diagram, right-click on an empty space and open the
Functions palette. Place the Comparison Express VI (Functions>>Express>>Arithmetic &
Comparison>>Comparison) on the block diagram, inside the while loop.
6. Once placed on the block diagram, the Comparison Express VI's configuration dialog will
appear.
58
ni.com
Select "> Greater" in the Compare Condition section and "Second signal input" from the Comparison
Inputs section then click OK.
7. Connect the acquired temperature data and Alarm Level inputs to the Comparison Express
VI. Hover over the output of the DAQ Assistant until the spool icon appears on your cursor,
then left-click and drag you mouse to the Operand 1 input on the Comparison Express VI.
Perform the same hover, drag and connect to wire the Alarm Level control and the Operand
2 input on the Comparison Express VI. Your block diagram should now look like this:
8. Display the result of the Comparison Express VI on the front panel. On the front panel, right
click, open the Controls palette and add a Square LED indicator. The square LED is found at
Controls Modern Boolean. Resize the Square LED so that it is easier to see and rename it
"Alarm." Your front panel should look like this:
59
ni.com
9. On the block diagram, wire the output of the Comparison Express VI to the input of the
Alarm indicator's terminal.
10. Run the application. Press the Run button and then change the Alarm Level control to some
level above the current acquired temperature signal. Hold the thermocouple until the
temperature exceeds the Alarm Level value. The Alarm LED turns on when the acquired
temperature signal goes above the level set on the front panel.
60
ni.com
12. Select Generate Signals Digital Output Line Output from the Create New Express Task
window.
61
ni.com
13. Select the physical channel you want to use as output. Expand the + sign next to
cDAQ1Mod4 in the following window and select port0/line0, then click Finish.
14. Press OK in the DAQ Assistant window that appears, since all of its default settings are
correct for the application.
15. Create an additional wire that connects the Comparison Express VIs Result output to the
data input on the new DAQ Assistant Express VI. A Convert from Dynamic Data function
appears automatically. LabVIEW will always try to coerce unlike data types when two nodes
are wired together. In this case, the output of the Compare Express VI is a Dynamic Data
type, and the input of the DAQ Assistant is Boolean. LabVIEW placed the Convert from
Dynamic Data node in between the two nodes so they could be connected. You can doubleclick the Convert from Dynamic Data to view its configuration. Your block diagram should
now look like this:
16. Run the VI. Press the Run button. Notice that the LED bank on the CompactDAQ 9472
module turns on and off to match Alarm's value on the front panel.
17. Save and close the VI.
End of Exercise 4
62
ni.com
Reporting and
Data Visualization
42
63
ni.com
43
64
ni.com
TDM(S) *
Binary
Excel
HTML
Word
XML
Datalog
LVM
Databases
44
A main part of your applications will include saving data to disk for later
analysis and reporting. You have several choices in LabVIEW to save data
in a variety of different formats. If you do not want to worry about the
details of saving your data, LabVIEW has several options to save data in
industry standard formats that are portable to applications such as Excel.
If you do need to conform to a particular data format standard, LabVIEW
offers all the low level file I/O functions you need to write data out exactly
as you need it.
File I/O can be a major pain point for companies, especially when multiple
people need to share data. To help solve these challenges NI developed a
file format called TDM. TDM is designed to help you make your data
search ready. To see how you can benefit from TDM, see the additional
information included in this manuals appendix.
65
ni.com
66
ni.com
3. A configuration window will appear. Configure the window as shown below, note the file
location in the File Name window, and click OK.
67
ni.com
4. Wire the output of the DAQ Assistant Express VI to the input of the Write to Measurement
File Express VI.
5. Your block diagram should now resemble the following figure.
6. Save the VI in the project folder by using the File Save As menu, select the Copy Open
Additional Copy and name it 5-Write to File.vi.
7. Run the VI momentarily and press Stop to stop the VI.
8. Your file will be created in the folder specified.
68
ni.com
9. Open the file using Microsoft Office Excel or Notepad. Review the header and temperature
data saved in the file.
10. Close the data file and the LabVIEW VI.
End of Exercise
69
ni.com
Next Steps
48
70
ni.com
49
71
ni.com
51
72
ni.com
52
73
ni.com
Together, the National Instruments training and certification programs deliver the
fastest, most certain route to increased proficiency and productivity using NI software
and hardware.
NI Training: Build Your Knowledge
NI training helps you build the skills to
more efficiently develop robust,
maintainable applications. We provide
several training options including
classroom, self-paced, online, or on-site
training at your facility.
53
74
ni.com
expenses but also give you the opportunity to modify the courses for your
company's specific needs.
Self-Paced Courses
National Instruments understands that you may not have the time or the
resources to participate in an instructor-led training program. To
accommodate your unique needs, we offer a variety of instructional
packages and tools designed to educate you on our products and
technologies - on your own and at your own pace.
Accreditation
All NI courses are accredited by the National Society of Professional
Engineers. You are eligible for continuing education units (CEUs) after
satisfactorily completing any NI courses.
LabVIEW
Core 1
LabVIEW
Core 2
Senior Developer
Software Architect
/ Project Manager
Managing
Software
Engineering
in LabVIEW
Certified LabVIEW Architect
Exam
Advanced
Architectures
for LabVIEW
LabVIEW
Core 3
Certified LabVIEW Developer
Exam
54
75
ni.com
Hardware APIs
Analysis Libraries
Deployment Targets
Technology Abstractions
Programming Approaches
56
76
ni.com
LabVIEW Modules
and Toolkits
57
59
77
ni.com
LabVIEW also provides a cycle accurate ARM simulator for running ARM targeted
application on a development system.
78
ni.com
62
The National Instruments LabVIEW Datalogging and Supervisory Control (DSC) Module is
the ideal LabVIEW add-on for developing your HMI/SCADA or high-channel-count
datalogging applications. With the NI LabVIEW DSC Module, you can interactively
develop a distributed monitoring and control system with tags ranging from a few dozen
to tens of thousands. It includes tools for logging data to a networked historical
database, real-time and historical trending, managing alarms and events, networking
LabVIEW Real-Time targets and OPC devices into one complete system, and adding
security to user interfaces.
System ID Toolkit
StateChart Module
Simulation Interface
Toolkit
NI Motion Control
LabVIEW Real-Time
LabVIEW FPGA
LV Microprocessor SDK
Targets
PXI
cRIO, cFP
RIO/DAQ Devices
32-Bit mp
63
Before we dive into each area of the control design process, wanted to first introduce
some of the main LabVIEW software and hardware tools for controls. Well be using
several of these tools today to explain capabilities throughout the design process.
79
ni.com
variable
Portable low-cost USB DAQ
64
The National Instruments LabVIEW Mobile Module extends the LabVIEW graphical
development environment to handheld devices, so you can easily create custom
applications to run on Microsoft Windows Mobile for Pocket PC devices.
The NI LabVIEW Mobile Module is compatible with several NI data acquisition devices,
including the USB-6008, USB-6009, CF-6004, DAQCard-6062E, DAQCard-6024E, and the
DAQCard-6036E. Using these hardware devices, you can build handheld measurement
systems for applications ranging from automotive service to field diagnostics to
physiological monitoring.
In addition, the LabVIEW Mobile Module works with the NI PCMCIA-4050 digital
multimeter (DMM), so you can build a customized DMM on your PDA. Using the LabVIEW
Mobile Module and an NI PCMCIA-CAN card, you can construct portable Controller Area
Network communication devices.
With the LabVIEW Mobile Module you can:
Create custom handheld applications for Windows Mobile, Pocket PC, and select
Windows CE OS devices.
Acquire data using NI CompactFlash DAQ and PCMCIA DAQCards, DMMs, and CAN
devices.
Communicate using Bluetooth, Wi-Fi (802.11), SMS text messaging, e-mail, IrDA,
and serial protocols.
Target standard and industrial PDAs, PDAs with phone capabilities, and touch-panel
displays.
Academic
Unmanned Systems
Fixed-Base Industrial
Research
Teaching
Autonomous Ground
Systems
Mobile Robot research
(medical)
Underwater, Aerial, Surface
Vehicles
NI Vision
Denso Toolkit
Search algorithms
Robotics visualization
Obstacle avoidance
Kinematics
Robotics Examples
Sensor drivers
Actuator drivers
Driver project wizard
66
80
ni.com
65
Customize
behavior
withNetwork
LabVIEW
LabVIEW node
Wireless
Sensor
(WSN) Module
67
81
ni.com
Enhance images
Check for presence
Locate features
Identify parts
Measure objects
68
The NI Vision Development Module is a suite of software tools that offers high-level
interactive software as well as low-level image processing functions. The Module includes
Vision Assistant, an interactive prototyping tool that accelerates your development, and
the Vision libraries, a collection of over 200 image processing and analysis functions.
These tools work together for fast application development for industrial and scientific
imaging applications
Vision Assistant is easy-to-use inspection software that does not require programming
yet is scalable to programming environments such as LabVIEW, Visual Basic, C, and
C++. Vision Assistant is ideal for applications where fast time to market and low cost of
ownership is a must. With Vision Assistant software you can quickly setup and
benchmark an imaging strategy using over hundreds of image processing and analysis
functions.
Enhance Images Filter noise, remove distortion, apply real world units. In the image,
were measuring the wrench in mm, not pixels
Check for Presence Simplest vision inspection. Is everything there? Results in a P/F
result.
Locate Features Usually with a pattern match. Often to find a fiducial in order to build
a coordinate system. Results in a location and rotation angle
Identify Parts Reading text, tracking bar codes, classifying objects for sorting. Usually
returns text.
Measure Objects Distance, radius, size, area. Usually returns a numerical value.
82
ni.com
Stepper or Servo
Drive Interface Module
Deterministic
Ethernet
NI 9144 expansion chassis for CompactRIO
Stepper or Servo
Drive Interface Module
Deterministic Ethernet
69
70
Additionally, LabVIEW offers you the flexibility of incorporating motion control into your
application. To facilitate this process, National Instruments offers a complete selection of
motion control software, controllers, and power drives that quickly and seamlessly
integrate into your automated test and machine control systems. The reduced
development time, easy connectivity, and integrated solutions combine to make you
even more successful.
The NI Motion Assistant is a flexible and easy-to-use development tool for building and
prototyping motion applications. Similar to the Vision Builder, the Motion Assistant can
83
ni.com
also convert your motion prototype to LabVIEW code. The NI SoftMotion Controller for
CANopen and IEEE 1394 enables you to program intelligent drives with LabVIEW for your
distributed motion control applications.
NI SoftMotion Development Module for LabVIEW is for machine builders and OEMs
creating custom motion controllers for better machine performance and for researchers
implementing advanced control design algorithms for motion control. The module
includes functions for trajectory generation, spline interpolation, position and velocity PID
control and encoder implementation. Using the NI SoftMotion development module you
can create your custom motion controller in software.
NI TPC-2006
71
With the National Instruments LabVIEW Touch Panel Module, you can develop custom
human-machine interface (HMI) monitoring and control applications for select Windows
CE touch panel devices, such as the NI TPC-2006. These HMI touch panel applications
are useful for communicating with and displaying information from headless devices such
as the National Instruments Compact FieldPoint, CompactRIO, and Compact Vision
System programmable automation controllers (PACs) or any other LabVIEW Real-Time
target. The LabVIEW Touch Panel Module includes built-in features and tools for user
interface development, data analysis, and communication.
84
ni.com
72
73
The Sound and Vibration Toolset extends the functionality of LabVIEW to handle system
calibration, frequency analysis, transient analysis, sound level measurements, and
fractional-octave analysis, providing you with a customizable software foundation for
your sound and vibration applications. Sound and vibration analysis often begins with
signal acquisition using microphones, accelerometers, displacement probes, or
tachometers.
Following the acquisition, you can associate the incoming signal with characteristics such
as sensor sensitivity, an engineering unit, or a dB reference. The built-in fractionaloctave analysis and sound level measurement routines also feature averaging, allowing
you to perform fractional-octave analysis with any number of bands at several different
bandwidths. Octave and sound level measurement functions offer tools for linear
averaging, exponential averaging, and peak hold. Exponential averaged measurements
provide arbitrary, standard, slow, fast, and impulse time constants.
85
ni.com
74
Order analysis is a tool for examining dynamic signals generated by mechanical systems
that include rotating or reciprocating components. As with frequency-domain analysis,
you can think of order analysis as a signal scalpel that can dissect sound, vibration, and
other dynamic signals into components that relate to physical elements of mechanical
systems. Unlike the power spectrum and other frequency-domain analysis standards,
order analysis works even when the signal source undergoes rotational speed variations.
The LabVIEW Order Analysis Toolset gives the power to create applications for order
tracking, order extraction, and tachometer signal processing. The toolset employs Gabor
Order Tracking, a patent-pending algorithm based on the ideas of Joint Time-Frequency
Analysis (JTFA).
Fuzzy Logic
Control strategies
Decision making
75
To quickly develop automated control applications, the PID Control Toolset provides
sophisticated control algorithms for PID and fuzzy logic control. The PID tools implement
a wide range of PID algorithms and feature autotuning and gain scheduling to improve
system performance. For nonlinear or highly complex systems, the fuzzy logic tools
accelerate development by implementing control strategies through simple linguistic
rules. You can also use the tools for decision making, such as pattern recognition or fault
diagnosis.
86
ni.com
76
The LabVIEW Report Generation Toolkit for Microsoft Office is a library of flexible, easyto-use VIs for programmatically creating and editing Microsoft Word and Excel reports
from LabVIEW. The Toolkit supplies powerful functions to quickly create professional
reports, giving you the flexibility you need to manage every facet of your presentation,
from content to layout and appearance.
With this toolkit, you can:
Create and edit reports containing text, tables, graphs, and pictures
Create reports from templates using Word bookmarks or Excel named ranges as
placeholders
Set report formatting (headers, footers, page numbers, fonts, borders, colors, text
alignment, and so on)
Sort data in Excel worksheets
E-mail reports
Run Visual Basic (VBA) macros in reports
Create custom report generation functions
87
ni.com
Automotive
Biomedical
Seismology
Radar/Sonar
77
Now that we have seen the vast analysis capabilities built into LabVIEW, lets take a look
at some of the specialized analysis you can perform with the LabVIEW Add-on Toolsets.
The Signal Processing Toolset provides powerful tools for Joint Time-Frequency Analysis
(JTFA), digital filter design, super-resolution spectral analysis, and wavelet/filter bank
design.
With the JTFA portion of the toolset you can simultaneously examine the time and
frequency domain representations of a signal. Quickly design lowpass, highpass,
bandpass, and bandstop FIR and IIR filters interactively and output filter coefficients for
use in LabVIEW and other applications. Super-resolution spectral analysis provides a
model-based alternative to the FFT and delivers estimates of amplitude, phase, damping
factor, and frequency of the damped sinusoidal components of a signal.
The wavelet and filter bank design component decompose a signal into multiple bands,
representing the signal in terms of varying time and scales through a bank of filters. This
decomposition facilitates extraction of signal features, noise reduction, and other
operations.
88
ni.com
78
The LabVIEW Database Connectivity Toolset is a set of high-level tools for accessing local
and remote databases from LabVIEW. It incorporates the latest technologies, such as
Microsoft ActiveX Data Objects (ADO) to deliver high-speed performance with low
memory overhead.
With the Database Connectivity Toolset, you can:
Insert and select data from databases
Create and drop database tables
List the tables and columns in a database
Accept or reject multiple database operations (transactions) based on user-defined
criteria
Execute Structured Query Language (SQL) statements
Execute stored procedures in a database
Select information in a database and save it to a file in Extensible Markup Language
(XML) format
The Database Connectivity Toolset readily connects to popular databases such as
Microsoft Access, SQL Server, and Oracle. It also can connect to other databases if you
install the appropriate ADO-compliant OLE DB provider or ODBC driver from Microsoft or
the database vendor.
The Database Connectivity Toolset is part of the Enterprise Connectivity Toolset.
79
89
ni.com
80
Input Values
Output
VI Under Test
Unit Test
Framework
Expected Output
Automated
Report Generation
81
The idea behind unit testing is elegant and simple, but can be expanded to enable
sophisticated series of tests for code validation and regression testing. A unit test is
strictly something that exercises or runs the code under test. Many developers
manually perform unit testing on a regular basis in the course of working on a segment
of code. In other words, it can be as simple as I know the code should perform this
task when I supply this input; Ill try it and see what happens. If it doesnt behave as
expected, the developer would likely modify the code and repeat this iterative process
until it works.
The problem with doing this manually is that it can easily overlook large ranges of values
or different combinations of inputs and it offers no insight into how much of the code was
actually executed during testing. Additionally, it does not help us with the important task
of proving to someone else that it worked and that it worked correctly. The cost and
time required is compounded by the reality that one round of testing is rarely enough;
besides fixing bugs, any changes that are made to code later in the development process
may require additional investment of time and resources to ensure its working properly.
The ability to prove it works requires the creation of documentation or evidence that the
software fulfills its intended purpose and meets all other criteria. The LabVIEW Unit Test
Framework enables automated generation of documentation in XML (ATML), HTML or
ASCII formats. Information included in this report can be configured, but typically
includes the time of test, duration of each test, test vector inputs, the results, and
aggregated code coverage metrics.
90
ni.com