LabVIEW DAQ Hands On Manual
LabVIEW DAQ Hands On Manual
LabVIEW DAQ Hands On Manual
.
com/
eve
nts
Hands-
onInt
roducti
on
toDat
aAcquisit
ion
withL
abVIEW
ni
.
com/
uk
ni
.
com/
ir
eland
ni
.
com/
uk/hands
on
Introduction to LabVIEW and Computer-Based
Measurements Hands-On Seminar
Company Profile
• Leaders in Computer-Based
Measurement and Automation
Virtual Instrumentation
The software is the instrument
High-Speed Multifunction High-Resolution Instrument Dynamic Counter/ Machine Motion Distributed I/O and
Digitizers Data AcquisitionDigitizers and DMMs Digital I/O Control Signal Acquisition Timers Vision Control Embedded Control
Agenda
• Introduction to LabVIEW
Exercise 1: Create a simple LabVIEW VI
• Data Acquisition with LabVIEW
Exercise 2a – 2c: Introduction to Data Acquisition with LabVIEW
• Decision making in LabVIEW
Exercise 3: Controlling program execution
• Analogue Output and Digital Control
Multiple operations with Analogue IO
Introduction to LabVIEW
10
11
thread
thread
thread
12
13
14
15
• Signal conditioning
16
Channel 0 Channel 0
MUX AMP ADC
Channel 1
Channel 1
Interchannel delay
Simultaneous sampling
Channel 1
Channel 1 AMP ADC
No interchannel delay
17
18
19
Current Excitation,
RTDs
Linearisation, Filtering
20
NI CompactDAQ
Hi-Speed USB 2.0 Synchronized I/O
21
C Series Modules
Accelerometer Thermocouples
Strain Gauge 4 to 20mA
Load Cells High Voltage (60V)
Digital I/O RTD
22
23
Exercises 2a –2c:
Introduction to Data Acquisition with LabVIEW
What you will learn:
• Taking measurements from scratch
using NI CompactDAQ and
NI LabVIEW
• Create an application that
Measures from a thermocouple
Logs data to a file
24
25
26
Textual Math
Configuration
Oriented
27
LabVIEW Analysis
Built-in functions available for
signal processing, analysis and math
• Signal synthesis
• Curve fitting and interpolation
• FFT-based frequency analysis
• Mathematics
• Probability and statistics
• Time- and frequency-domain analysis
• Digital signal processing
• Waveform alignment and resampling
• Much more…
28
29
30
Presenting Data
Types of controls and indicators available:
• Graphs and strip charts
• Buttons and checkboxes
• Knobs and sliders
• Text and combo boxes
• Tree controls
• Tables
• ActiveX objects
• etc...
31
32
ni.com/tdm
33
• HTML • MS Office
• XML • DIAdem
Start
• Looping (For and While)
• Case structure
• Sequence structure
No
Is Limit Reset • State machines
Met? Output
• Event structure
Yes
Turn On • State diagram editor
Output • Timed loop
35
36
37
38
Channel 1
Channel 1 DAC
• 16-bit
• 100 kS/sec
• ±10 VDC, 0–20 mA
39
Exercise 4:
Multiple Operations with Analogue I/O
What You Will Learn
• Creating parallel operation in LabVIEW
• Create an application that
Outputs an analogue signal
Uses analogue input channel to acquire
and display on front panel
Time: 20 minutes
40
41
42
NI LabVIEW™ Everywhere
Platforms:
Micro-
• Desktop processors
• Mobile
FPGA
• Industrial
• Embedded Handheld
Wireless
Networked I/O
PC Boards
PXI
PC
43
Power
RAM
Supply
45
ni.com/idnet
46
Solution: CompactDAQ is used to control the height from which the helmet under test is
dropped, as well as acquiring data related to what a person's head would be subjected to
upon impact. The system was chosen as it had sufficient throughput to ensure that each
helmet test is thoroughly and accurately documented.
“A system upgrade such as the one we required is a major budget
consideration, and for this reason we were very deliberate in our
search for a new hardware package”
47
NI Customer Solutions 48
49
50
ni.com/training
51
Questions or Comments?
ni.com/labview
52
Functions Palette
Controls Palette
1. If you have not already done so, click the LabVIEW icon on your quick launch toolbar.
2. Click More…
3. Expand From Template. Notice the different categories on the left of the window that
correspond to the types of tasks from which you can choose. You can select Blank VI to
start from scratch. There are also Template VIs to use as a starting point for building your
application. Projects and Other Files are more advanced components and will not be
described in detail. To get more information on any of the listings in the New Dialog Box,
click the Help button in the lower right corner of the window.
Two windows appear. The gray window is the front panel, and the white one is the block
diagram. The front panel contains the parts of your VI used for presenting information,
whereas the block diagram contains the code that controls the functionality of the VI. You
can toggle between the two windows by selecting Window»Show Block Diagram or
Window»Show Front Panel. You can also switch between the windows by pressing <Ctrl-E>
on the keyboard.
5. Examine the front panel and block diagram of this template VI. The front panel contains a
Waveform Chart and a STOP button as shown in the following figure.
6. Switch back to the front panel by pressing <Ctrl-E>. Since the Run button (the white arrow
in the top left corner) is solid, you can run this VI as it is. Click the Run button and examine
the operation of the VI. When you are finished, click the STOP button on the front panel to
stop running the VI.
Note: As you will see later in the exercise, when the Run button in the upper left corner of
both the front panel and the block diagram changes from a solid white arrow, to a broken
gray arrow, this new icon indicates that the VI is currently not executable.
7. Now we can add some functionality to this basic VI. We will modify the VI to flash an alarm
whenever the signal value is above a certain level. Open the Controls palette (if it is not
open already) by right-clicking the front panel window. A small pushpin icon in the upper
left corner of this palette appears. Click this pushpin to force the palette to remain on your
screen.
9. Click the Express menu item on the Controls palette to return to the Express Controls
palette.
10. Click the LEDs subpalette, and place a Round LED on the front panel.
13. Switch to the block diagram by pressing <Ctrl-E>. Double-click the Simulate Signal Express
VI to bring up its properties window. Examine the different properties you can modify.
Change the Amplitude of the signal to 10. Click OK to apply this change and to close the
properties window.
15. When you place the Comparison Express VI on the block diagram, a dialog box appears.
Select RMS as shown below.
16. As shown below, wire the output of the Simulate Signal VI to Signals input on the
Amplitude and Level Measurements VI. Then right-click on RMS output and select
Create»Numeric Indicator from the context menu.
18. You can connect Controls, Functions, and Indicators on the block diagram by pointing to an
object and clicking it when the cursor changes to a spool of wire. You can then move the
cursor to the object you want to connect it to and click again. Connect the Limit control to
the Alarm indicator.
Note: The Run button in the upper left corner of both the front panel and the block diagram
has changed from a solid white arrow, to a broken gray arrow. This new icon indicates that
To delete this broken wire, press <Ctrl-B>. This keyboard shortcut removes all broken wires
from the block diagram.
21. Make your block diagram resemble the following image by completing the following steps.
a. Wire the Limit control to the Operand 2 input of the Comparison function.
b. Connect the wire between the Simulate Signals block and the Waveform Graph to the
Operand 1 input of the Comparison block.
c. Wire the Result output of the Comparison block to the Alarm indicator.
Your block diagram should now resemble the following:
25. When you are finished, stop the VI by clicking the STOP button on the front panel.
2. Expand New Examples for LabVIEW 8.5»Express and double-click on Select Signals.vi.
3. Run the VI and explore the block diagram.
4. Take a few minutes to look around at the other example programs available, search on
terms that you are familiar with, i.e., “analysis”, and try out as many as there is time for.
End of Exercise 1
Goals
Exercise Instructions
Set up hardware
1. Make sure that the NI CompactDAQ chassis (cDAQ-9172) is powered on.
2. Connect the chassis to the PC using the USB cable.
3. NI-DAQmx driver installed on the PC automatically detects the chassis and brings up the
following window.
Note: NI Measurement & Automation Explorer is a configuration utility for all National Instruments
hardware.
Configure Hardware
5. 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-
DAQmx compatible devices. By default, the NI CompactDAQ chassis NI cDAQ-9172 shows up
with the name “cDAQ1”.
6. This section of MAX also shows the installed modules as well as empty slots in the
CompactDAQ chassis.
7. Right-click on NI cDAQ-9172 and click on Self-Test.
8. The device passes the self test, which means it is configured properly and ready to be used
in your LabVIEW application.
LabVIEW
9. Open NI LabVIEW 8.5 and press <Ctrl-N> to open a blank VI.
10. Press <Ctrl-T> to tile front panel and block diagram windows.
11. Pull up the Functions Palette by right-clicking on the white space on the LabVIEW block
diagram window.
12. Move your mouse over the Express»Input palette, and click the DAQ Assist Express VI. Click
again on the white space of the LabVIEW block diagram to place the DAQ Assistant VI.
18. Right-click the data terminal output of the DAQ Assistant Express VI (the blue output arrow
on the right side) and select Create»Graph Indicator.
On the Scale tab, change the Minimum to 20 and the Maximum to 30.
25. To perform analysis on your data, select the Express»Signal Analysis»Statistics Express VI
and place it on your block diagram.
26. A properties window will appear. Make the following selections and click OK.
Statistical Calculations: Arithmetic Mean
27. Connect the data output of the DAQ Assistant VI to the Signals input of the Statistics VI.
29. Switch to the front panel and rearrange your controls and indicators to resemble the
following.
30. Save the VI in the Desktop\CustomerWork folder by using the File menu and name it
Exercise2.vi.
End of Exercise 2a
Goals
When you have completed this exercise, you will:
Know how to use Write to Measurement File express VI and how to log data to a file using
LabVIEW.
Exercise Instructions
1. Open the VI from exercise 2a.
2. Right-click on the block diagram and select Express» Output» Write to Measurement File
and place it inside the While Loop on the block diagram.
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 .
End of Exercise 2b
Goals
When you have completed this exercise, you will:
Know how to generate code automatically from the DAQ Assistant.
Have experience using some of the NI-DAQmx VIs.
Exercise Instructions
1. Open the VI from Exercise 2a.
2. Delete all the functions and terminals from the block diagram except the DAQ Assistant.
Delete all the wires as well.
3. Right-click on the DAQ Assistant and select Generate NI-DAQmx Code.
5. Double-click on the configuration VI (shown below) that NI-DAQmx generated for you on
your block diagram
6. The block diagram of the configuration VI should appear as shown below. This is an example
of how you can use the DAQmx VIs if you need to create customized DAQ code that includes
features beyond those offered by the DAQ Assistant.
DAQmx Timing.vi
To learn about each VI, hover your mouse over each one and press <Ctrl-H>. This will bring
up the Context Help which explains the parameters and functionalities of each VI.
7. Close the VI and do not save any changes.
End of Exercise 2c
Challenge Application
Using a While Loop, case structure, toggle switch and the Simulate Signal VI, create a simple
application that charts a sine or triangle wave depending on toggle switch position.
When you are done, save your VI as Exercise3-Decisions.vi. You will use it in the next
exercise.
If you are really up for a challenge add logic to the VI so it will stop either when you press the
stop button or when the loop iterations have exceeded 10,000.
3. Next we will add the simulate signal VIs two the case statement. Remember one will
output a triangle wave, the other a sine wave. From the Express»Input palette, select
Simulate Sig as shown below, and place it inside the case statement.
7. Repeat steps 3 and 4, except this time leave the default settings for the Simulate Sig VI
so it will generate a sine wave.
8. Switch to your front panel and place a Waveform Graph as shown below.
12. Next, wire the outputs from both of the Simulate Signals to the waveform graph. Note
that you will have to wire through the wall of case statement. Don’t forget wire both the
cases, True and False.
13. You are ready to test your VI by switching the toggle switch back and forth. You should
see the graph switch between a sine and triangle wave.
9. Place the array container at the bottom of the VI, as shown below.
16. Next we will increase the size of the array of Booleans so it contains eight elements. To
do this, click on the right side of the array container and drag it to the right until eight
push-buttons are visible.
18. Next configure the hardware to recognize these switches and control one digital output
per switch. Start by switching to the block diagram using <Ctrl-E>.
19. Next select the DAQ Assistant from the Express»Output palette
20. In the DAQ Assistant select Digital I/O»Line Output as shown below. Click Next.
24. Switch to the front panel and Run the VI. Use the push buttons to activate the digital
outputs on the NI 9472 module and watch the LEDs change as you select different push
buttons.
4. Wire as follows.
6. Change the constant to 10000 as shown below and Run the VI.
End of Exercise 3
Hands-on Introduction to Data Acquisition with LabVIEW 62
Exercise 4: Multiple Operations with
Analogue I/O
Exercise Overview
Objective
In this exercise, you will use the DAQ Assistant to build a LabVIEW VI that generates and
outputs an analogue waveform. You will then add a second loop that measures the waveform
using an analogue input channel.
Goals
When you have completed this exercise, you will:
Know how to generate signals in LabVIEW with NI CompactDAQ
Run loops in parallel for multiple analogue operations
Exercise Instructions
1. If you closed LabVIEW after the last exercise, launch it. Open a new VI.
3. Browse to the Input subpalette on the Functions»Express palette and click the Simulate
Sig Express VI as shown below. Place the VI on the block diagram.
5. In the Timing section of the window, set Samples per second (Hz) to 10,000. Click OK.
7. In the Create New window, select Analogue Output as the Measurement Type and then
select Voltage.
9. In the DAQ Assistant configuration window, select Generate Continuously from the Task
Timing tab in the lower part of the window. Uncheck Use timing from waveform data,
and set the Rate (Hz) to 10,000. Click the OK button.
11. To make the VI run continuously, create a While Loop. A While Loop causes all parts of
the program inside the loop to run continuously until a Stop button is clicked. To create
the While Loop, browse to the Exec Ctrl subpalette of the Functions palette and select a
While Loop.
12. Draw the While Loop around your entire block diagram. Your block diagram should
resemble the following figure.
14. Right-click the slide control and select Properties. On the Appearance tab, change the
label to Frequency. On the Scale tab, change the Scale Range so Minimum equals 0.00
and Maximum equals 1000.00. Click OK to close the Properties window.
15. Press <Ctrl-E> to switch to the block diagram. Notice the orange Frequency slide control
terminal. Move the control inside the While Loop to the left side of the Simulate Signal
Express VI. Wire the knob control to the Frequency input terminal of the Simulate Signal
Express VI (the second orange arrow on the left side of the Simulate Signal Express VI).
16. This VI will now use the frequency knob on the LabVIEW front panel to generate a sine
wave at the specified frequency. This sine wave is then generated on analogue output
channel 0 of the NI 9263 C Series module by the DAQ Assistant Express VI.
18. Increase the size of the block diagram window to make space for another While Loop to
go below the existing Analogue Output code.
21. Once you click OK, a dialog window will appear asking if you would like to create a While
Loop around the DAQ Assistant. Select Yes to automatically create a While Loop for this
continuous acquisition.
25. Locate the stop (F) Push Button control and right-click to replace it with a Stop Button
control, as shown on the diagram below. (Replace»Boolean»Stop Button)
29. The analogue output loop is generating a sine wave on analogue output channel 0,
which is wired directly to channel 0 of the analogue input module. Use the slider control
on the front panel to control the sine wave frequency, and look at the graph on the
front panel to monitor the sine wave.
30. Press both stop buttons to stop the execution of both loops.
For Loops can be used to generate arrays using a feature called automatic indexing, as shown in
the following figure.
Try building the following block diagram to further manipulate the waveform being generated.
End of Exercise 4