Connect to Measurement Hardware Using LabVIEW

Publish Date: May 19, 2017 | 8 Ratings | 4.12 out of 5 | Print | Submit your review

Overview

Use LabVIEW to connect to your measurement hardware, both NI DAQ devices and third-party instruments, to acquire or generate a variety of signal types. Learn how to acquire an analog signal using NI DAQ hardware and the NI-DAQmx driver with the provided sample code.

 



Table of Contents

  1. Connect to Your Measurement Hardware
  2. Create a Simulated Device
  3. Acquire a Signal Using the DAQ Assistant
  4. Acquiring a Signal Using NI-DAQmx
  5. Additional Resources

1. Connect to Your Measurement Hardware

To begin taking measurements using the sample code provided, download and install the NI-DAQmx driver to interface and configure your NI data acquisition devices. Use the code in the Connect to NI DAQ Hardware for this guide.

To connect to your hardware:

  1. Connect your NI DAQ device to your computer.
  2. Open Measurement & Automation Explorer (MAX) and expand the Devices and Interfaces drop-down. You can see your device listed as connected to your system.

Figure 1: Discovering hardware in MAX.

 

MAX is device management software installed with all NI hardware drivers for the configuration of NI hardware and software, replication of configuration data, performing system diagnostics, and updating NI software.

Back to Top

2. Create a Simulated Device

If you don’t have NI data acquisition hardware yet, you can use this guide by creating a simulated device that replicates hardware behavior to run functions or programs. To create a simulated device, open Create Simulated Device.vi from the attached sample code. Run the code by clicking on the run arrow. This VI creates a simulated device called SimuDAQ on your computer, which is discussed later in this guide.

Figure 2: If you don't have hardware, follow along with a simulated device.


Back to Top

3. Acquire a Signal Using the DAQ Assistant

  1. Open Acquire Analog Inputs Using the DAQ Assistant.vi from the Connect to NI DAQ Hardware.lvproj. This VI includes a prebuilt UI and analysis code. For this exercise, you need to add the code required to acquire a signal.


    Figure 3: Starting Point.


  2. The DAQ Assistant provides a step-by-step guide for configuring, testing, and programming measurement tasks. Start by adding a DAQ Assistant Express VI to your diagram. To do this, right-click on your block diagram and navigate to Measurement I/O»NI-DAQmx»DAQ Assistant, and then click and place the DAQ Assistant icon onto your block diagram. Alternatively, you can press <Ctrl-Space> to open Quick Drop, type DAQ Assistant, and select the entry from the list.

    Figure 4: Navigating to the DAQ Assistant.


  3. When you place the DAQ Assistant on your block diagram, the measurement configuration dialog box opens to help you set up your task. The first step is to select your type of measurement and channel. You have several options for an analog input acquisition. This exercise steps through a simple voltage measurement, but if you’re 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.

  4. Figure 5: Selecting Signal Type.


  5. The next step is to select your channels. If you are using your own NI data acquisition hardware, it is listed by device name. Dev1 is the default for a system with only one DAQ device plugged in. If you’re using the simulated device from Part 1 of this guide, it is listed under the name SimuDAQ. Select the appropriate analog input channel from your physical device (if available) or select ai0 if you’re using the simulated device.

Figure 6: Selecting Channel(s).


  1. Once you have selected your channel(s), click the Finish button. This launches the analog input task configuration page. Here you can select your acquisition type, sampling rate, number of samples, and voltage range. Under Timing Settings, use the default Acquisition Mode of N samples, change the number of samples to red to be 1k, and use the default sampling rate of 1 kHz. You can preview your data by clicking the Run button at the top of the window.

    Figure 7: Configuring and Testing Acquisition Parameters. 


  2. When you’ve finished configuring your acquisition parameters, click OK. The DAQ Assistant automatically generates the code required to implement your acquisition. To complete the system, wire the data output of your DAQ Assistant to the inputs of the analysis VIs as shown below.

    Figure 8: Completed Block Diagram. 

  3. Switch to the front panel and run the program to see your raw signal data and filtered data as well as the minima, maxima, and mean of the acquired signal.


Figure 9: Visualize raw data, filtered data, and points of interest. 


You can find the finished VI in the Solutions folder in the Connect to NI DAQ Hardware.lvproj.

»Use the DAQ Assistant for analog output, digital I/O, and counters.

Back to Top

4. Acquiring a Signal Using NI-DAQmx

Though 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.

Figure 10: The DAQmx API provides added programming flexibility. 


 

Open Acquire Analog Inputs using the DAQmx API.vi for an example of a more advanced application. Here you can configure channels, recording options, triggering options, and advanced timing settings.

»Solve 80 percent of your problems with 10 NI-DAQmx functions.

Back to Top

5. Additional Resources

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit