SP1: Multichannel data acquisition using LabVIEW

advertisement
PC based multi-channel data acquisition of sensor signals.
Objective
Understand the principles of operation and limitations of the data acquisition system.
• Single channel data acquisition.
• Multi channel data acquisition.
• Data acquisition at different sampling rates.
• Effect of quantization.
Overview
Traditionally, measurements are done on stand-alone instruments of various typesoscilloscopes, multi meters, counters etc. However, the need to record the measurements
and process the collected data for visualization has become increasingly important. It has
become essential to design systems where the computer acquires the signal directly from
the transducer.
There are several ways in which the data can be exchanged between the instruments and
a computer. Many instruments have a serial port, which can exchange data with a
computer or other instruments. Use of GPIB (General purpose Instrumentation Bus)
interface board allows instruments to transfer data in a parallel format.
Another way to measure signals and transfer the data to a computer is by using a Data
Acquisition (DAQ) board. A typical commercial DAQ card contains ADC and DAC that
allows input and output of analog and digital signals in addition to digital input/output
channels.
Sampling
The data is acquired by an ADC using a process called sampling. Sampling an analog
signal involves taking a sample of the signal at discrete times. The rate at which the
signal is sampled is known as sampling frequency. The process of sampling generates
values of the signal at equal time intervals as shown in the following figure.
The sampling frequency determines the quality of the conversion from analog to digital.
A higher sampling frequency achieves better conversion of the analog signals. The
minimum sampling frequency required to represent the signal should at least be twice
the maximum frequency of the analog signal under test (this is called the Nyquist rate).
If the sampling frequency is equal to or less than twice the frequency of the input
signal, a signal of lower frequency is generated from such a process (this is called
aliasing). Once the signal has been sampled, one needs to convert the analog samples
into a digital code. This process is called analog to digital conversion.
Commercially available boards have different sampling frequencies. The DAQ board in
the underwater lab has a 12 bit ADC.
Most boards also have a multiplexer that acts like a switch between different channels
and the ADC. Therefore with 1 ADC, it is possible to have a multichannel input DAQ
board. The board available in the underwater lab has 8 channel analog input. This makes
it possible to acquire up to 8 analog signals in parallel (however, the sampling frequency
will be divided by the number of parallel channels).
Precision of the analog input signal converted into digital format is dependent upon the
number of bits the ADC uses. The resolution of the converted signal is a function of the
number of bits the ADC uses to represent the digital data. The higher the resolution, the
higher the number of divisions the voltage range is broken into, and therefore, the smaller
the detectable voltage change. An 8 bit ADC gives 256 levels (2^8) compared to a 12 bit
ADC that has 4096 levels (2^12). Hence, a 12 bit ADC will be able to detect smaller
increments of the input signals than an 8 bit ADC. LSB or least significant bit is defined
as the minimum increment of the voltage that an ADC can convert. If the full scale of the
input signal is 10V than the LSB for a 3-bit ADC corresponds to 10/2^3=1.25V.
However, for a 12 bit ADC the least significant bit will be 10/2^12=10/4096=2.44mV. If
one needs to detect smaller changes, one has to use a higher resolution ADC. Clearly, the
resolution is an important characteristic of the DAQ board.
Digital to Analog Converter
The multifunction boards also have on-board digital to analog converters (DAC). A DAC
can generate an analog output from a digital input. This allows the board to generate
analog signals, both dc and ac voltages. Like the ADC, the DAC's performance is limited
by the number of samples it can process and the number of bits that are used in
converting the digital code into an analog signal.
LabVIEW
LabVIEW programs are called virtual instruments, or VIs, because their appearance and
operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW
delivers a powerful graphical development environment for signal acquisition,
measurement and analysis. It can acquire data at a specified sampling rate. It acquires
data in the background while processing in the foreground. It integrates different DAQ
boards in a computer and uses various functions of a DAQ board from a single user
interface. Refer to the LabVIEW manual for more details. The driver software is a lower
level driver that interfaces the LabVIEW software with the DAQ boards. As a user of
LabVIEW one does not have to worry about configuration and control of components
within DAQ boards. LabVIEW identifies each board by a device number and therefore
one can have as many devices (as many as the computer can accept on its expansion
slots). LabVIEW can also combine and display inputs from various sources like inputs
from serial and parallel port, data acquisition board(s), and GPIB boards on a single
interface. The user interface which is called a vi consists of two parts- a front panel and a
block diagram. This is similar to that of an instrument where a front panel is used for
input and output controls, and to display the data whereas the circuit resides on the circuit
board. Similarly you can bring the buttons, indicators and graphing and display functions
on the front panel. When data acquisition is performed, the software needs to know the
following information:
• Device number
• Channel that is being used
• Sampling Rate
Lab Objectives
Experiment 1 Familiarization with hardware and required software.
 NI ---- card will be used to acquire the signal onto a PC. Functional
generator and power amplifier should be used to generate and
amplify the signal. Get familiar with the card and the Terminal
Box (BNC-2110).
 LabView software will be used to acquire and process the signal.
Get familiar with the Software. Use the Getting started manual to
try out some examples.
 ---- sensor will be used to acquire underwater signal.
Get familiar with all the hardware and software to be used.
Experiment 2 Generation of sine wave from functional generator and acquiring with
DAQ using different sampling rates( 500Hz, 750Hz, 1kHz, 2kHz, 4kHz).
Functional
Generator
DAQ
PC
Steps :
1. Generate sine wave of 1kHz using functional generator.
• Choose the sine wave from the panel,
• Fix the frequency of 1kHz.
• Fix the amplitude of 10V.
2. Program the labview to acquire and store the signal in a note pad at a specified
sampling frequency. The signal spectrum is also plotted. The steps to be followed are
given below.
1. Verify that there is a BNC cable is connected to the analog input channels on BNC
2110.
2. Verify that the switch below the channel BNC is all the way to the right in GS
position.
Writing the LabVIEW Programs
First make sure that you can access the various palettes needed in the front panel
and block diagram as well as the areas to find the tools, controls, and functions. It should
be noted that the Controls pallet is only accessible in the Front Panel window and the
Functions Palette is only accessible in the Block Diagram window while the Tools
Palette an be used in both. The palettes can be selected while in the Front Panel or Block
Diagram window at anytime from the Window menu item. To start a new program:
1.
Open the labview software.
2
Press the New << Blank VI button with the left mouse button. Two windows
appear one with the name Untitled 1 at the top, which is the Front Panel window, and
one with Untitled 1 Diagram at the top, which is the Block Diagram window. The
Tools palette also appears when the program is started. To begin writing the LabVIEW
program the tasks in the Front Panel window should first be completed followed by the
tasks in the Block Diagram window.
3.
If it is not already displayed, the Controls palette can be brought up by
selecting it from the Window menu item at the top of the Front Panel with the
left mouse button.
Writing a Waveform Acquisition Program.
Programming the Front Panel
There are two items, which will be placed on the Front Panel for this program: the two
Waveform Graphs. After placing these items on the Front Panel their appearance,
position, titles and other attributes will be modified.
.
1. Create a waveform graph by selecting Graph Inds>>Waveform Graph on the
Controls palette with the left mouse button. Make sure you select the Waveform
Graph and not the Waveform Chart.
2. Position the Waveform Graph (titled Waveform Graph) in the Front Panel.
3. Create a second waveform graph by selecting Graph Inds>>Waveform Graph on
the Controls palette with the left mouse button.
4. Position the second waveform graph (titled Waveform Graph 2) in the Front Panel
and press the left mouse button.
Modifying the X-scale on both of the Waveform Graphs
1. Move the cursor over the upper Waveform Graph and press the right mouse button
to bring up the graph properties menu. Select Scales<<Time (X-Axis) and
uncheck the Auto scaling feature for the X axis.
2. Select Format and Precision>>Time(X-Axis) and verify that the Floating Point is
selected. Change the Digits of Precision to 3 and press the OK button at the
bottom of the screen.
3. Select the Editing tool from the Tools Palette and using it select the largest number
on the x-scale of the Upper Waveform graph (which should now read 100.000)
and press the left mouse button. Type in the number (0.008) and press the Enter
key on the keyboard.
4. Again select the Editing tool from the Tool Box and using it select the largest
number on the x-scale of the Lower Waveform graph (which should now read
100) and press the left mouse button. Type in the number (4000) and press the
Enter key on the keyboard.
Changing some of the titles and values of some of the items on the Front Panel
1. Select the Edit Text tool from the Tools palette.
2. All of the following changes can be made in the same way as that used for changing
the maximum value of the x-scale with the waveform graphs above.
- Select the value or text to be changed
-Type in the new value or text and press the enter key on the keyboard, or
press the left mouse key on a blank region of the panel.
3. Change the text and values as indicated in Table 1.
Table 1. Changes to the values or text of various items
Item
Old Text or Value
x-scale title of top Waveform Graph
Time
x-scale title of bottom Waveform Graph
2
Title of bottom Waveform Graph 2
New Text or Value
Time (Seconds)
Time
Frequency (Hz)
Waveform Graph
2
Fast Fourier
Transform
4. The Front Panel Diagram window should appear as in Fig. Items can be moved by
placing the cursor over the item holding down the left mouse button and dragging the
item to the new location. In order to make the current values the default values for
this laboratory select Operate>>Make Current Values Default and press the left
mouse button.
5. The work at this point should be saved.
Final arrangement of front panel controls and displays.
Programming the Block Diagram
Items in the Block Diagram window allow the program to control and access
channels on the multi-channel DAQ board, to conduct calculations on the data, and to
save the data to a text file.
1. Access the Block Diagram window .
2. Bring up the Functions palette by selecting “Show Functions Palette” from the
Window menu item at the top of the Block Diagram window.
3. Create a While Loop by selecting Exec Ctrl>>While Loop from the Functions
palette using the left mouse button. Place the mouse cursor at the position on the block
diagram where you want to anchor the top-left corner of the While Loop and press and
hold down the left mouse button. When the button is released it will define the lower
right corner of the While Loop. Everything inside the While Loop will be executed
continuously until stopped by pressing the Stop button. Notice that a Stop button now
appears both on the Block diagram and the Front panel.
4. Use the Up navigation button on the Functions palette to navigate back to the
main Functions palette using the left mouse button.
5. Select Input<<DAQ Assist vi and drag it inside the While Loop. The DAQ
assistant menu will automatically appear to configure the DAQ Assist vi:
a. Select Measurement << Analog Input.
b. Select Measurement<< Voltage.
c. Select Physical Channel<<(the one you have chosen). Then select Finish.
d. A window will then appear with information about the measurement task.
In the Task Timing menu select Acquire N Samples and set the Samples
to Read to 1,000. Also set the (sample) Rate at 10,000 Hz. The click OK
to end the DAQ configuration.
6. Use the Up navigation button on the Functions palette to navigate back to the main
Functions palette with the left mouse button.
7. Create an FFT analyzer by selecting Analysis>>Spectral from the Functions
palette and drag inside the While Loop. The Spectral Measurements menu will
automatically appear to configure the FFT vi:
a. Select Spectral Measurement<< Measurement (RMS), and Result
<<Linear.
b. Select Window<<None. Then click OK to end the FFT analyzer
configuration.
8. Use the Up navigation button on the Functions palette to navigate back to the main
Functions palette with the left mouse button.
9. Create a vi to save the data in a text file by selecting Output<<Write LVM (Write
LabVIEW Measurements) from the Functions palette and drag it onto a position
outside and to the right of the While Loop on the block diagram. The Write LVM
menu will automatically appear to configure the Measurements File (if it does not
right click on the Write LVM icon and select Properties):
a. Note and (modify) the path of the File Name.
b. Check Action<<Ask user to choose file<< Ask only once.
c. Check one of the options as desired in If a file already exists.
d. Ckeck Segment Headers<<One header per segment or as desired.
e. Check X Value Columns<< One column per channel
f. Check Delimiter<<Tab and then OK to end Configuration
g. Look at Figure to see what the block diagram should look like at this point.
10. Close the Functions palette by selecting the X in the upper right corner of the
palette with the left mouse button.
11. Select the Connect Wire tool (spool of wire) on the Tools palette (if the Tools
palette is not visible select Window>>Show Tools Palette.
12. Now the components can be wired.
Final arrangement of the block diagram
Running the Waveform Acquisition Program
The program can now be run using as inputs sine or triangle waves at different
frequencies and saving the data. (A disk should be in the A drive). The program allows
viewing the waveform and when the Stop Button is pressed the last waveform(s)
displayed can be saved. The fast Fourier transform will display peaks at the frequencies
needed to create the waveform from a series of sine waves. If the waveform is a sine
wave there is only one peak, which is associated with the frequency of that sine wave.
1. Start the LabVIEW Program by selecting the run arrow at the top left of the Front
Panel window of your program.
2. A waveform should be displayed and will be continuously updated in both graphs on
the Front Panel.
3. Adjust the Amplitude Adjust knob on the FUNCTION GENERATOR until a sine
wave of amplitude of approximately ± 1 is displayed in the Waveform Graph.
You will notice that the Amplitude on the graph is automatically updated.
4. Adjust the Frequency Adjust knob on the FUNCTION GENERATOR until the
peak in the Fast Fourier Transform graph is at 500 Hz indicating the frequency of
the sine wave that is being used.
5. The data should now be saved, so select the Stop Button in your program and press the
left mouse button. A file dialog box will open asking for a file name file
destination. Save the data appending the suffix .txt to the file name.
6. Repeat Steps 1, 4 and 5 but for different wave frequencies (do not adjust the
amplitude). Notice as the frequency increases the sine wave distorts.
7. The sampling rate can be changed by right clicking on the DAQ Assistant icon and
selecting Properties. Note the change in FFT frequency with sampling rate.
•
•
Repeat the above steps again by using the input amplitude of 5V, 2.5V
and 1V.
Comment on the results.
Experiment 3 Loop back test: Generation of signal on PC and acquiring the signal from
sensor at PC again with different sampling rate.
PC
DAQ
PC
Steps : 1.
• Program the Labview to generate a sine wave of 1kHz at 10V.
• Plot the spectrum of the generated signal.
• Program the labview to output this sine wave using out port of DAQ
• Also program to receive it back using in port of DAQ.
• Use the previous programs to acquire it at different sampling rates.
• Plot the spectrum of the acquired signal.
• Comment on the results.
• Recommendation: if possible repeat the above steps at different input
voltages.
2.
• Generate two sine waves of 1kHz and 15kHz.
• Repeat the above loop back test using two channels with specified
sampling frequencies.
• Plot the spectrum.
• Comment on the results.
3.
•
•
•
•
Generate square waves of 30% duty cycle.
Repeat the above loop-back test with specified sampling frequencies.
Plot the spectrum.
Comment on the results.
Experiment 4 Generation of sine wave from functional generator and acquiring the
signal from the sensor with a DAQ onto a PC using different sampling rates.
Functional
Generator
Power
amplifier

Preamplifier
DAQ
sensor
Steps :
• Generate sine wave of 150 kHz at 10V using functional generator.
• Propagate this signal to the sensor and amplify the received signal
appropriately using power amplifier.
• Acquire the signal in the PC using DAQ with sampling rate of
100kHz, 150kHz, 300kHz, 1500kHz.
• Plot the spectrum of the output.
• Comment on the results.
Experiment 5: Measure and plot the frequency spectrum of the transducer, using above
approach.
PC
Related documents
Download