Every day, scientists and engineers are required to perform tests. The signals that they measure are real-world analog signals that vary indefinitely with time. To automate and better visualize the data, you need to transfer the analog signal to the digital world to be viewed on a computer. Data acquisition devices, such as the NI myDAQ or NI Educational Laboratory Virtual Instrumentation Suite (NI ELVIS) II, perform analog-to-digital conversion to accomplish this task. This module shows you how to acquire an analog voltage signal using a DAQ device and NI LabVIEW software.
Connect the signal of interest to the analog input channel 0 (ai0) terminal of your device
You can locate the device pinouts for your DAQ device by searching for your device online at ni.com
The user guide and specifications contain this diagram
Right-click your device in NI Measurement & Automation Explorer (MAX) and select Device Pinouts
Create a new VI in LabVIEW
Open LabVIEW and select File»New VI
Place a DAQ Assistant on the block diagram
Right-click on the block diagram and select Express»Input»DAQ Assistant
Place the DAQ Assistant on the block diagram by left-clicking
Configure DAQ Assistant type
Select Acquire Signals
Select Analog Input
Select Voltage
Select Dev1 (or the name of your device if not Dev1)
Select ai0
Configure acquisition settings
Enter 1000 for Number of Samples
Enter 10k for Sample Rate
Click Run to test your settings
Click OK to finish the DAQ Assistant
Create the graph indicator to view data
Right-click on the Data output terminal of the DAQ Assistant
Select Create»Graph Indicator
Run the VI by pressing the Run button and visualize the results
Adjust Graph Indicator appearance as desired
Change acquisition mode to Continuous
Double-click the DAQ Assistant
Change Acquisition Mode from N Samples (Finite) to Continuous
Select OK to finish the DAQ Assistant
Select Yes to auto place the While Loop around theDAQ Assistant
Create the stop condition to include when the Stop button is pressed or an error is detected
Unwire the Conditional Terminal from the Stopped output terminal of the analog input DAQ Assistant
Right-click the block diagram and select Programming»Boolean»Or
Wire the output from the Stop button control to the bottom input of the Or Boolean function
Right-click the block diagram, select Programming»Cluster, Class, & Variant»Unbundle by Name, and place this to the right of the analog input DAQ Assistant
Wire the Error Out output terminal of the analog input DAQ Assistant to the input of the Unbundle by Name function and ensure Status is selected to be unbundled
Wire the output of the Unbundle by Name function to the top input of the Or function
Wire the output of the Or function to the input of the Conditional Terminal
Run the VI to visualize the data on the front panel
You can convert your DAQ Assistant Express VIs into low-level NI-DAQmx functions by right-clicking the DAQ Assistant and selecting Generate NI-DAQmx Code. The low-level NI-DAQmx API exposes more functionality and customization options for programming.
Right-click on the above VI snippet and select Save Image As... Locate the file on your hard disk and click and drag the file icon onto your LabVIEW block diagram. LabVIEW automatically generates the code from the VI snippet. For more information, read VI Snippets.
For a low-level NI-DAQmx driver example for this concept, open the NI Example Finder and browse to Hardware Input and Output»DAQmx»Analog Measurements»Voltage»Cont Acq&Graph Voltage Wfm-Int Clk.vi. View the detailed help on using the NI Example Finder and help within LabVIEW.
Exercise Goal
Use the NI myDAQ device to continuously acquire an audio signal from a sound device such as a microphone, CD player, or MP3 player. Then display the signal to a graph in LabVIEW.
Required Hardware
1- NI myDAQ
1- 3.5 mm audio cable with MP3 or CD player
or
1- computer microphone
Things to Consider
What is the audible frequency range of the human ear? Then what should the sampling rate be according to the Nyquist Theorem to capture all of the frequencies? What is the sampling frequency of a CD player? Therefore, what should you use for the sampling rate of your NI myDAQ?
Samples to Read should be 1/5 to 1/10 of your sampling rate. For example, Fs=10 kHz, Samples to Read = 1k or 2k samples. This is a good benchmarking relationship for buffered acquisition.
Use a voltage acquisition to read data from a microphone, CD player, or MP3 player on audioInputLeft and audioInputRight for a stereo input, or just one channel for a mono input.
The input range for the audio input is ±2 V.
Turn your sound device to about 30 percent volume to input a quality signal.
Here is an example of what the final signal should look like on a graph indicator:
Evaluate your understanding of LabVIEW and the basics of DAQ. This exam is recommended after you complete all of the modules for LabVIEW Basic Concepts and LabVIEW Basic Tasks. There are 26 multiple choice questions on the exam.
Assess your working knowledge of building a complete system by acquiring, processing, and displaying data with LabVIEW and a DAQ device. This project is recommended after you complete all of the modules for LabVIEW Basic Concepts and LabVIEW Basic Tasks.