You are on page 1of 4

1/4 www.ni.

com
1.
2.
3.
4.
1.
2.
LabVIEW Evaluation Series: Connect to Hardware
Publish Date: Mar 20, 2014
Overview
LabVIEW enables you to easily connect to any measurement hardware to acquire or generate a variety of signal types. This guide will show you how to acquire an analog signal using NI DAQ
hardware and the NI-DAQmx driver.
Table of Contents
Before You Begin: Download Sample Code and NI-DAQmx
Create a Simulated Device
Acquire a Signal Using the DAQ Assistant
Acquiring a Signal Using DAQmx
1. Before You Begin: Download Sample Code and NI-DAQmx
There is sample code that accompanies this guide. Scroll down to the bottom of this page to download it before you start. You must also , a free device driver for National install NI-DAQmx
Instruments data acquisition hardware, to follow along with this guide.
2. Create a Simulated Device
If you dont have NI data acquisition hardware yet, you can still use this guide by creating a simulated device. To create a simulated device, open from the attached Create Simulated Device.vi
sample code. Run the code by clicking on the run arrow. This VI creates a simulated device called on your computer. Youll use this device later in this guide. SimuDAQ
Figure 1: If you don't have hardware, follow along with a simulated device
3. Acquire a Signal Using the DAQ Assistant
Open from the . This VI includes a pre-built UI and analysis code. In this guide, youll add the code Acquire Analog Inputs Using the DAQ Assistant.vi Connect to NI DAQ Hardware.lvproj
required to acquire a signal.
Figure 2: Starting Point
The DAQ Assistant provides a step-by-step guide for configuring, testing, and programming measurement tasks. Start by adding a DAQ Assistant ExpressVI to your diagram. To do this, right
click on your block diagram and navigate to , and then click and place the DAQ Assistant icon onto your block diagram. Alternatively, you can Measurement I/O NI-DAQmx DAQ Assistant
press <Ctrl-Space> to open Quick Drop, type , and select the entry from the list. DAQ Assistant
2/4 www.ni.com
2.
3.
4.
5.
Figure 3: Navigating to the DAQ Assistant
When you place the DAQ Assistant on your block diagram, the measurement configuration dialog box will appear to help you set up your task. The first step is to select your type of
measurement and channel. There are several options for an analog input acquisition. In this guide we will step through a simple voltage measurement, but if youre using your own device and
sensor you can select the appropriate measurement type and channel for your system. Configure your measurement by selecting . Acquire Signals Analog Input Voltage
Figure 4: Selecting Signal Type
The next step is to select your channels. If you are using your own NI data acquisition hardware, you will see it listed by a device name. is the default for a system with only one DAQ Dev1
device plugged in. If youre using the simulated device from Part 1 of this guide, youll see it listed under the name . Select the appropriate analog input channel from your physical SimuDAQ
device (if available), or if select if youre using the simulated device. ai0
Figure 5: Selecting Channel(s)
Once you have selected your channel(s), click the button. This will launch the analog input task configuration page. Here you can select your acquisition type, sampling rate, number of Finish
samples, and voltage range. Under Timing Settings, use the default Acquisition Mode of , change the number of samples to read to be and use the default sampling rate of . N samples 1k 1 kHz
You can preview your data by clicking the button at the top of the window. Run
3/4 www.ni.com
5.
6.
7.
Figure 6: Configuring and Testing Acquisition Parameters
When youve finished configuring your acquisition parameters, click . The DAQ Assistant will automatically generate the code required to implement your acquisition. To complete the system, OK
wire the data output of your DAQ Assistant to the inputs of the analysis VIs as shown below.
Figure 7: Completed Block Diagram
Switch to the front panel and run the program. You will be able to see your raw signal data and filtered data, as well as the minima, maxima, and mean of the acquired signal.
Figure 8: Visualize raw data, filtered data, and points of interest
You can find the finished VI in the folder in the Solutions Connect to NI DAQ Hardware.lvproj.
Use the DAQ Assistant for analog output, digital I/O, and counters
4. Acquiring a Signal Using DAQmx
While the DAQ Assistant provides a quick and easy way to acquire or generate data without programming, more advanced users may need added flexibility and lower-level control than what the
DAQ Assistant offers. The NI-DAQmx driver features a comprehensive API of basic and advanced functions for control over such parameters as timing, synchronization, data manipulation, and
execution control.
4/4 www.ni.com
Figure 9: The DAQmx API provides added programming flexibility
Open i for an example of a more advanced application. Here you can configure channels, but also recording options, triggering options, and Acquire Analog Inputs using the DAQmx API.v
advanced timing settings.
Solve 80% of your problems with 10 DAQmx Functions

You might also like