1. Connect to Hardware

Connecting Your DAQ Hardware Using LabVIEW

Learn how to connect, test, and validate an NI USB data acquisition device with LabVIEW.

Before You Begin

Before using NI LabVIEW software to take measurements with an NI DAQ device, you need to set up and configure the device. This module explains how to install the proper driver and connect, configure, and test your device using NI Measurement & Automation Explorer (MAX) software. It also describes the setup process with the NI myDAQ measurement and control tool, but the same process applies to other USB multifunction DAQ devices such as the NI Educational Laboratory Virtual Instrumentation Suite (NI ELVIS) II or NI USB-6009.
Prior to starting this module, review the Learn LabVIEW modules to understand the fundamentals of graphical programming.

Detailed Explanation

Installing Hardware Drivers

Before connecting or installing your multifunction DAQ device, you need to install the proper hardware driver. Most NI multifunction DAQ devices communicate to your computer via the NI-DAQmx driver. You can access NI educational devices such as NI ELVIS II and NI myDAQ using the NI ELVISmx driver, which is built on and uses the NI-DAQmx driver to communicate to your computer. Plus the NI ELVISmx driver has additional functionality such as the NI ELVISmx Instrument Launcher, as seen in Figure 1.Click here for more information on using NI ELVISmx.

NI Measurement & Automation Explorer (MAX)

Similar to the Windows Device Manager, which manages all peripherals connected to a Windows PC, MAX manages all NI hardware and software. This application is installed with most NI software packages. Take a look at the most used features of MAX: Software and Devices and Interfaces.

Note: You can access two systems in MAX: the locally installed hardware and software, which is listed under My System, and Remote Systems, which contains all the remote targets you have detected on your network such as NI CompactRIO hardware or a real-time PXI system.

Software

Knowledge of the software and drivers on your system is beneficial for setting up and troubleshooting your measurement system. The Software section of MAX contains all of the installed NI software on your local machine, as seen in Figure 3.

Figure 3. Locally Installed NI Software
in the MAX User Interface

When you select an installed software package such as LabVIEW 2010 Service Pack 1 (SP1), more detailed information is displayed in the pane to the right of the software list. For a development system such as LabVIEW, all installed toolkits and modules, the version, a description, and the path to the executable are displayed in the right window pane, as shown in Figure 4.

Hardware

By being able to view and manage all of the hardware connected to your local machine, you can easily manage and configure your hardware all in one place. All of the NI hardware, as well as the peripherals that can be accessed by NI hardware and software, are listed in the Devices and Interfaces section of MAX, as shown in Figure 5.

Figure 5. Locally Installed NI Hardware

On the system shown in Figure 5, an NI myDAQ and an NI ELVIS II are installed. Because the NI myDAQ device was installed and detected first, it was enumerated in the system as Dev1 (Device 1); the NI ELVIS II device was installed and detected second, so it is Dev2 (Device 2). You can rename the device by right-clicking it to display the shortcut menu and selecting Rename, as shown in Figure 6.

Figure 6. Shortcut Menu of NI myDAQ Device in MAX

In this example, the devices were renamed to match their product names, NI myDAQ and NI ELVIS II (see Figure 7). This can make the device selection more intuitive when you are programming.

Figure 7. Devices Renamed to Their Product Names

The shortcut menu also features the Create Task… option, which you can use to create a data acquisition task in LabVIEW for analog input, analog output, and so on. With a MAX task to program your data acquisition or data generation, you can generate a step-by-step graphical interface rather than using the low-level NI-DAQmx API in LabVIEW.

The option for Device Pinouts, as shown for the NI myDAQ device in Figure 8, provides a visual reference for the I/O terminals on each device, which helps you identify the proper terminal for signal or device connection. Note that this is not available for every device.

Figure 8. Device Pinouts for NI myDAQ

Two other useful resources in the shortcut menu are Reset Device and Self-Test. Resetting the device clears all of the references to the device as well as any routes and tasks associated with the device. A dialog box appears with the result of the reset (see Figure 9).

Figure 9. Dialog Box After Successfully Resetting a NI-DAQmx Device

Self-test checks to see if the NI-DAQmx driver is able to successfully communicate with the device. A dialog box appears with the result of the self-test; a successful self-test dialog box is shown in Figure 10.

Test Panels

It is beneficial to be able to quickly test if the voltages or signals you are receiving or outputting are correct. The NI-DAQmx test panels, which you can access in the shortcut menu of your device, provide this option. You are able to test analog input, analog output, digital I/O, and counter I/O for a multifunction DAQ device such as an NI myDAQ or NI ELVIS II (see Figure 11). You can also set the input range, sample mode, and configuration as well as the channel to test.

Figure 11. Analog Input Test Panels for the NI myDAQ Device

Figure 12 is a graphical representation of the analog input voltage data acquired from the ai0 pin. Notice that there is also an instantaneous value displayed in the lower right-hand corner.

Step-by-Step Procedure

Use this section with the video to test and validate that your NI data acquisition device, such as an NI myDAQ or NI ELVIS II, is working properly. Before proceeding, you must open the test panels for the device.

You can now use test panels to ensure that the analog input, analog output, digital I/O, and counter I/O are all functioning correctly. In this example, test the NI myDAQ.

Analog Input

By default, the test panels open to analog input. You can choose the channel you want to test (Note that you can access the audio input channels as well as the digital multimeter here.), the input range of the channel, the sample mode, and the input terminal configuration. For this test, leave them as default values and just press Start.

Note: If you do not have any signals connected to an input line, the signal floats and does not hold steady. This is expected behavior.

To verify that the analog input is reading correctly, input a known voltage. You can use any known signal such as a AA battery, but, in this case, use the + rail on the device:

Connect the +5 V rail to the ai0+ terminal with a wire.

Connect the DGND terminal to the ai0- terminal with a wire.

In the MAX test panel, navigate to the Analog Input tab.

Select DevX/ai0 for the input channel, where X is the device number for your device.

Select On Demand for the Mode.

Select Differential for the Input Configuration.

Enter 10 for Max Input Limit and -10 for Min Input Limit.

Press the Start button and observe the voltage.

The graph should display between 4.7 and 5.0 VDC.

Note: This voltage is dependent on the power of the USB hub, so it may not read exactly 5 V, but it holds steady.

Analog Output

Testing the analog output requires looping the analog output back to the analog input to verify the voltage. Start by configuring the physical device.NOTE: If you have not verified the analog input, do that now and then return to this section.

Connect ao0 to the ai0+ terminal with a wire.

Connect AGND to the ai0- terminal with a wire.

Navigate to the Analog Output tab in the MAX test panels.

Select DevX/ao0 for the input channel, where X is the device number for your device.

Select Sinewave Generation for the Mode.

Select <Default> for the Transfer Mechanism.

Enter 10 for Max Output Limit and -10 for Min Output Limit.

Enter 1k or 1000 for rate (Hz).

Enter 5 for Sinewave Amplitude.

Press the Start button to begin outputting the sine wave.

Now use the analog input to verify the analog output. Configure the analog input according to the analog input section. After pressing Run, you can see a sine wave on the graph indicator with a 5 V amplitude, 10 Vpk-pk.

Digital I/O

To test the digital I/O, connect DIO0 to DIO4, DIO1 to DIO5, DIO2 to DIO6, and DIO3 to DIO7, with a wire for each pair, which equals four wires total (see Figure 15). After connecting the wires, navigate back to the test panels in MAX.

Navigate to the Digital I/O tab in the MAX test panels.

Select DevX/ctr0 for the input channel, where X is the device number for your device.

Select Port0 for the Port Name.

Select Port0/line0:7 for the Port/Line Direction.

Toggle lines 0-3 to be input and lines 4-7 to be output.

Press the Start button.

Toggle the software switches for lines 0-3 to observe the software LEDs change for lines 4-7.

Counter I/O

A counter can both input and output a digital signal deterministically. First, test the input by applying a 5 V to 0 V pulse train; the counter can detect a transition from high to low or low to high.NOTE: If you do not have a single-pole double-throw (SPDT) switch, you can simply connect a wire into PFI3 and then connect and disconnect the other end of the wire to the +5 V terminal.

Connect a 330 Ω resistor, SPDT switch in series to terminal DIO 3 as seen in Figure 16.

Connect one pole of the SPDT switch to the DGND terminal and the other pole to the +5 V terminal.

Navigate to the Counter I/O tab in the MAX test panels.

Select DevX/ctr0 for the input channel, where X is the device number for your device.

Select Edge Counting for the Mode.

Select /DevX/PFI3 for the Edge Source.

Press the Start button and toggle the SPDT switch to begin counting edges.

NOTE: If there is any noise on the signal, multiple edges may be counted for each transition of the SPDT switch.

Figure 16. Counter Input Wiring

Now test the output of the counter pulse train, which is a series of digital high and low pulses often used to trigger an event such as a sample clock for data acquisition. To output a pulse train, you must

Connect a 330 Ω resistor and an LED in series between terminal DIO 3 and the +5 V terminal as seen in Figure 17.

Navigate to the Counter I/O tab in the MAX test panels.

Select DevX/ctr0 for the input channel, where X is the device number for your device.

Cumulative Exam: LabVIEW and DAQ

Evaluate your understanding of LabVIEW and the basics of DAQ. This exam is recommended after you complete all of the modules in the Learn LabVIEW and Learn DAQ sections. There are 26 multiple choice questions on the exam.

Cumulative Exercise: LabVIEW and DAQ

Assess your working knowledge of building a complete system by acquiring, processing, and displaying data with LabVIEW and a DAQ device. This exercise is recommended after you complete all of the modules in the Learn LabVIEW and Learn DAQ sections.