Acquire Data
Acquire Data
Approximate Time
You can complete this exercise in approximately 15 minutes.
Background
NI-DAQmx is a programming interface you can use to communicate with data acquisition devices. Measurement & Automation Explorer (MAX) is a tool automatically installed with NIDAQmx and used to configure National Instruments hardware and software. This exercise introduces you to the Express VIs used to acquire data using NI-DAQmx. With NIDAQmx you can create simulated devices in MAX, so no data acquisition hardware is required to complete this exercise. An NI-DAQmx simulated device is a software replica of data acquisition hardware.
Overview
In the following exercise, you will create an NI-DAQmx task that continuously takes a voltage reading and plots the data on a waveform graph. You will use the DAQ Assistant Express VI to create the voltage task. The voltage task will acquire data from an NI-DAQmx simulated device that you configure in MAX.
Completed Exercise
Step-by-Step Instructions
1. Creating a Simulated DAQ Device
Complete the following steps to configure a simulated data acquisition device in MAX. a. Launch Measurement & Automation Explorer (MAX) by double-clicking the desktop icon or navigation to Programs National Instruments Measurement and Automation in the Windows Start menu.
b. Click My System and right-click Devices and Interfaces. c. Select Create New... in the dropdown menu.
d. Select NI-DAQmx Device NIDAQmx Simulated Device and click Finish. The Choose Device window will prompt you to select a device.
With this list, you can browse hundreds of devices supported by NI-DAQmx. You can create an NI-DAQmx simulated device of nearly any NI-DAQmx-supported device.
e. Select M Series DAQ NI PCI-6221 and click OK. The NI-DAQmx simulated device will appear in the Configuration pane within MAX.
The icon color of the NI-DAQmx simulated devices differs from real devices. Real devices are green and chassis are grey ; simulated devices and chassis are yellow.
d. Click Analog Input under Acquire Signals. e. Select Voltage to create a new voltage analog input task. The dialog box displays a list of channels for our simulated PCI-6221. The channels listed depends on the number of channels on the selected device.
4
f. In the Supported Physical Channels list, select ai0 and click the Finish button. The DAQ Assistant opens a dialog displaying options for configuring the selected channel to complete a task.
g. In the Input Range section of the Settings page, enter 10 for the Max value and enter -10 for the Min value.
h. Select N Samples from the Acquistion Mode menu in the Timing Settings section. i. Enter a value of 1000 in the Samples To Read box.
b. Display the front panel and run the VI three or four times. Observe the waveform graph. Voltage appears in the plot legend at the top of the waveform graph. c. On the block diagram, right-click the DAQ Assistant Express VI and select Properties from the shortcut menu to open the DAQ Assistant. d. Right-click Voltage in the list of channels and select Rename from the shortcut menu to display the Rename a channel or channels dialog box. You also can select the name of the channel and press the <F2> key to display the Rename a channel or channels dialog box.
e. In the New Name text box, enter First Voltage Reading, and click the OK button. f. In the DAQ Assistant dialog box, click the OK button to save the current configuration and close the DAQ Assistant.
g. Display the front panel and run the VI. First Voltage Reading appears in the waveform graph plot legend. h. Save the VI.
c. Select the Voltage channel from the Add Channel menu to display the Add Channels To Task dialog box. d. Select any unused physical channel in the Supported Physical Channels list, and click the OK button to return to the DAQ Assistant.
e. Click the Add Channels button Rename the channel Second Voltage Reading. f. Select Continuous from the Acquistion Mode menu in the Timing Settings section.
When you set timing and triggering options in the DAQ Assistant, these options apply to all the channels in the list of channels. g. Click the OK button to save the current configuration and close the DAQ Assistant. The Confirm Auto Loop Creation dialog box appears.
h. Click the Yes button. LabVIEW places a While Loop around the DAQ Assistant Express VI and the graph indicator. A stop button appears on the block diagram wired to the stop input of the DAQ Assistant Express VI. The stopped output of the Express VI is wired to the conditional terminal of the While Loop. If an error occurs or you click the stop button while the VI is running, the DAQ Assistant Express VI stops reading data and the stopped output returns a TRUE value and stops the While Loop.