Professional Documents
Culture Documents
LabVIEW Handson Manual PDF
LabVIEW Handson Manual PDF
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 Technical Support and Product Information
ni.com
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
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
Over the last 20 years LabVIEW has earned a strong reputation as the
software tool for creating measurement solutions. LabVIEW users have an
advantage of traditional text based programmers by reducing
development time, and taking advantage of functionality that is pre-built
for test and control applications. This enables users to reduce
development time by up to 40% and easily create complex data
acquisition and control applications which previously required extensive
knowledge of software design.
Automated
Test
Modular
I/O
Industrial
Software-defined
behavior
Embedded
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.
To quote one of our software developers, We write low level code so you
dont have to. Our team of developers continually trying free LabVIEW
users up to focus on the bigger problems and tasks they are trying to
solve.
Some people need every component. Others only use some parts.
However, everyone who uses LabVIEW is aware of the productivity and
empowerment that comes from abstracting unnecessary complexity and
being able to focus on the challenge at hand, not the challenges typically
associated with creating custom software.
I/O Finder LabVIEW has built-in wizards that help you automatically
detect and set up hardware for your application. We will use several of
these wizards to set up hardware for input and output in todays
exercises.
Software Engineering Tools LabVIEW has the tools you will need as
your applications become more complex, and more than one developer
works on a single application. Manage your code base with the LabVIEW
Project Explorer and integrate with the source code control applications.
Map graphical code in LabVIEW to requirements documents and distribute
professional, end-use applications with LabVIEW Application Builder.
Performance Tools After you have created your program, use tools
like VI Analyzer and VI Profiler to optimize your codes appearance and
behavior.
10
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).
12
You can arrange the front panel and block diagram to stand side-by-side
by pressing <ctrl + T>. It is important to note that adding an object to
the front panel creates an associated terminal on the block diagram that
allows for functions to be performed on the inputs (controls) and then be
routed to the appropriate output (indicator).
Larger applications are made by adding lower level VIs to a main VI. VIs
that are part of another application are referred to as subVIs. For
example, you might create several VIs that perform different signal
analysis and then use them as function blocks in your overall application.
14
This exercise gives you a chance to see what youll complete by todays final application. Youll also
explore important elements of the LabVIEW environment.
1. If you have not already done so, launch LabVIEW. Click the LabVIEW icon on your quick
launch toolbar, or click Start Programs National Instruments LabVIEW 2010.
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.
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.
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
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.
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
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>.
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
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.
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.
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.
1 2 3
18
thread
thread
thread
19
Lets first review what the LV compiler does for you behind the scenes. LV
automatically divides your program into two threads a user interface
thread and an execution thread to separate the two fundamental parts
of a program that can bog down your application. Because updating the
UI can be time-consuming, or because the UI could become sluggish or
non-responsive when it is bogged down by procesor-intensive processing
LV Vis are automatically divided into these two threads so the OS can
manage your app better.
The user doesnt have to know anything about threads to take advantage
of multicore processing and get better performance.
21
21
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, left-
click on any empty space on the block diagram and navigate to
Programming>>Structures.
26
1. Open a blank VI from the Intro to LabVIEW-DAQ Hands-on Project Explorer by right-clicking
the Exercises folder and selecting New VI.
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. Double-
click 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 right-
clicking.
5. While loops have two terminals in their bottom left and right corners.
6. On the front panel, right click on any empty space to bring up the Controls palette and
navigate to Modern Boolean Stop Button. Left click on the stop button and it will be
automatically placed on your cursor.
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.
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.
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.
Front Panel
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.
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.
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.
End of Exercise #2
Highlight Execution
Context Help
27
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.
29
Wireless / Ethernet
USB
31
Note: you may want to reference the WSN modules too, although this
uses a slighlty different api.
Built-in Signal
Conditioning
Hot-swappable modules
Direct sensor
connectivity NI CompactDAQ
32
35
1. Make sure that the NI CompactDAQ chassis (cDAQ-9172 or cDAQ-9178) is powered on.
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-
8. The device passes the self test, which means it has initialized properly and is ready to be used
in your 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.
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
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.
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).
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.
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..
36. Set the Thermocouple type and the Physical Channel to match the CompactDAQ chassis
channel (cDAQ1Mod1/ai0) and run the application.
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.
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
36
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.
Programmatic,
Low-Level VIs
Configuration Based
Express VIs
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.
1. Confirm that the CompactDAQ chassis is powered on and connected to the PC via the USB
cable. If not, or if it is not behaving as expected, repeat steps #1-8 from Exercise #3
2. Exercise 4 is functionally the same as the end result of Exercise 3. You can open Exercise 3 or
Exercise 4 to match with the illustrations in this section. Open 4-Analysis and Output.vi from
the Exercises folder in the Project explorer. The VI will appear like the image below, with
additional space on the block diagram to add functionality:
3. Create an alarm that signals if acquired temperature goes above a user-defined level. Right-
click the front panel to open the Controls palette (Modern Numeric) and place a numeric
control on the front panel.
6. Once placed on the block diagram, the Comparison Express VI's configuration dialog will
appear.
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:
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.
11. Use another DAQ Assistant Express VI to output Alarm's status to the CompactDAQ's 9472
module. Open the Functions palette on the block diagram and find the DAQ Assistant Express
VI at Functions Express Output.
12. Select Generate Signals Digital Output Line Output from the Create New Express Task
window.
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 double-
click 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
42
43
LabVIEW also contains functions for storing your data in a variety of ways.
You can write data to ASCII and binary files, publish it in standard formats
such as HTML or XML, and programmatically create custom reports.
LabVIEW offers several reporting options, including documentation-
generation tools, HTML reports, programmatic generation of Microsoft
Word and Excel reports, and interactive report generation with NI
DIAdem.
ASCII 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.
3. A configuration window will appear. Configure the window as shown below, note the file
location in the File Name window, and click OK.
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.
End of Exercise
48
49
There are also more than 100 LabVIEW User Groups located around the
world. These groups of LabVIEW users meet regularly to share their
LabVIEW expertise and help their local community of users to improve
their skills. This is a very active community who work together to share
presentations and best practices for helping their User Groups succeed. To
locate a User Group near you, visit LabVIEW Zone for a list of all LabVIEW
User Groups.
As mentioned earlier, many third-party organizations develop LabVIEW
toolkits. Quite often, these toolkits are available from individuals who
solved a particular application and want to share their expertise with the
entire LabVIEW Community. For a complete listing of available LabVIEW
add-ons, visit ni.com/labviewtools.
Finally, there are literally thousands of example program, tutorials, and
application notes available from LabVIEW Zone. LabVIEW Zone is your
portal to the LabVIEW Community and gets you in touch with the
worldwide community of users. If you are just starting to use LabVIEW,
you will find very helpful tutorials and application notes to help you get
started. As you continue to develop your skills, LabVIEW Zone can get you
in touch with other users of your skill level.
51
52
Together, the National Instruments training and certification programs deliver the
fastest, most certain route to increased proficiency and productivity using NI software
and hardware.
53
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.
Managing
Advanced
LabVIEW LabVIEW LabVIEW Software
Architectures
Core 1 Core 2 Core 3 Engineering
for LabVIEW
in LabVIEW
Certified LabVIEW Associate Certified LabVIEW Developer Certified LabVIEW Architect
Developer Exam Exam Exam
54
56
Technology Abstractions?
LabVIEWs compiler abstracts complex technological problems like
multicore, virtualization, memory allocation and network communication.
Hardware APIs?
Over 8000 drivers for instruments and a wide-range of USB, PCI, and PXI
instruments make it easy to real-world signals into software.
G Programming Language
G is a complete programming language, capable of solving the most
complex and advanced problems today. There are a variety of other
programming approaches in LabVIEW, but G is the language that ties
them together
57
.
LabVIEW Real-Time Module
Rapidly develop deterministic
applications with graphical
programming
Easily architect distributed control
and monitoring systems
Eliminate time spent integrating
diverse I/O
59
The LabVIEW Embeddded Module allows developers to Target over 260 different ARM
61
processors. LabVIEW provides integrated solutions for device drivers to access analog
and digital hardware. Depending on the hardware target LabVIEW can provide for
ethernet ,analog and digital I/O, Pulse Width Modulation, SPI/I2C, LCD, Power
Management. Additionally, a interrupt manager allows LabVIEW code to handle
hardware interrupts.
LabVIEW also provides a cycle accurate ARM simulator for running ARM targeted
application on a development system.
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.
Simulation Interface
PID and Fuzzy Logic Toolkit NI Motion Control
Toolkit
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.
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.
66
65
This functionality originally included in LabVIEW Base and Professional Packages, has
been reengineered for optimal performance in a Real-Time Operating System. Structural
changes to the underlying MathScript engine were made to ensure the most optimized
compiled code, resulting in the technology being packaged in the LabVIEW MathScript
RT Module for LabVIEW
Customize
LabVIEW node behavior
Wireless withNetwork
Sensor LabVIEW(WSN) Module
Onboard processing averaging/scaling
Increase battery life
Increase acquisition performance
Interface with wide array of sensors
67
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.
Stepper or Servo
Drive Interface Module
Deterministic
Ethernet
NI 9144 expansion chassis for CompactRIO
Stepper or Servo
Deterministic Ethernet
Drive Interface Module
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
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.
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 fractional-
octave 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.
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).
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.
76
The LabVIEW Report Generation Toolkit for Microsoft Office is a library of flexible, easy-
to-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
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.
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
80
VI Under Test
Unit Test
Expected Output Automated
Framework
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.