L3 - WordPress.com

advertisement
APLICAȚIA NR. 4
INSTRUMENT VIRTUAL PENTRU ACHIZIȚIA, ANALIZA ȘI
PREZENTAREA SEMNALELOR
I. PARTEA TEORETICĂ
Most LabVIEW VIs have three main tasks: acquiring some sort of data, analyzing the
acquired data, and presenting the result. When each of these parts are simple, you can
complete the entire VI using very few objects on the block diagram. Express VIs are
designed specifically for completing common, frequently used operations. In this
section, you learn about some Express VIs in each of these categories: acquire,
analyze, and present. Then you learn to build a simple VI using these three parts, as
shown in Figure 1.
Figure 1. Acquire, Analyze, and Present Example
Front Panel Window and Block Diagram Window
On the Functions palette, the Express VIs are grouped together in the Express
category. Express VIs use the dynamic data type to pass data between Express VIs.
1
I.1. Acquire
Express VIs used for the Acquire task include the following: DAQ Assistant, Instrument
I/O Assistant, Simulate Signal, and Read from Measurement File.
DAQ Assistant
The DAQ Assistant acquires data through a data acquisition device.You must use this
Express VI frequently throughout this course. Until you learn more about data
acquisition, you only use one channel of the data acquisition device, CH0. This channel
is connected to a temperature sensor on the DAQ Signal Accessory. You can touch the
temperature sensor to change the temperature the sensor reads.
Instrument I/O Assistant
The Instrument I/O Assistant acquires instrument control data, usually from a GPIB or
serial interface.
Simulate Signal
The Simulate Signal Express VI generates simulated data such as a sine wave.
Read From Measurement File
The Read From Measurement File Express VI reads a file that was created using the
Write To Measurement File Express VI. It specifically reads LVM or TDM file formats.
This Express VI does not read ASCII files.
I.2. Analyze
Express VIs used for the Analyze task include the following: amplitude and level
measurements, statistics, tone measurements, and so on.
Amplitude and Level Measurements
The Amplitude and Level Measurements Express VI performs voltage measurements
on a signal. These include DC, rms, maximum peak, minimum peak, peak to peak,
cycle average, and cycle rms measurements.
Statistics
The Statistics Express VI calculates statistical data from a waveform. This includes
mean, sum, standard deviation, and extreme values.
Spectral Measurements
The Spectral Measurements Express VI performs spectral measurement on a
waveform, such as magnitude and power spectral density.
Tone Measurements
The Tone Measurements Express VI searches for a single tone with the highest
frequency or highest amplitude. It also finds the frequency and amplitude of a single
tone.
Filter
The Filter Express VI processes a signal through filters and windows. Filters used
include the following: Highpass, Lowpass, Bandpass, Bandstop, and Smoothing.
Windows used include Butterworth, Chebyshev, Inverse Chebyshev, Elliptical, and
Bessel.
I.3. Present
Accomplish present results by using Express VIs that perform a function, such as the
Write to Measurement File Express VI, or indicators that present data on the front panel
window. The most commonly used indicators for this task include the Waveform Chart,
the Waveform Graph, and the XY Graph.
Common Express VIs include the Write to Measurement File Express VI, the Build Text
Express VI, DAQ Assistant, and the Instrument I/O Assistant. In this case, the DAQ
2
Assistant and the Instrument I/O Assistant provide output data from the computer to the
DAQ device or an external instrument.
Write to Measurement File
The Write to Measurement File Express VI writes a file in LVM or TDM file format.
Build Text
The Build Text Express VI creates text, usually for displaying on the front panel window
or exporting to a file or instrument.
I.4. Running a VI
After you configure the Express VIs and wire them together, you can run the VI. When
you finish building your VI, click the Run button on the toolbar to execute the VI.
While the VI is running, the Run button icon changes to the one shown at left. After the
execution completes, the Run button icon changes back to its original state, and the
front panel indicators contain data.
I.5. Run Button Errors
If a VI does not run, it is a broken, or nonexecutable, VI. The Run button appears
broken, shown as follows, when the VI you are creating or editing contains errors.
II. PARTEA PRACTICĂ
In this example, Create a simple VI that accomplishes the acquire, analyze, and present
tasks.
You need to acquire a sine wave for 0.1 seconds, determine and display the average
value, log the data, and display the sine wave on a graph.
The input for this problem is an analog channel of sine wave data. The outputs include a
graph of the sine data and a file logging the data.
II.1. Program Architecture—Quiz
1. Acquire: Circle the Express VI that is best suited to acquiring a sine wave from a
data acquisition device.
2. Analyze: Circle the Express VI that is best suited to determining the average value of
the acquired data.
3
3. Present: Circle the Express VIs and/or indicators that are best suited to displaying
the data on a graph and logging the data to file.
II.2. Implementation
1. Open LabVIEW.
2. Open a blank VI.
3. Save the VI as Simple AAP.vi.
❑ Select File»Save.
❑ Name the VI Simple AAP.vi.
❑ Click OK.
In the following steps, you will build a front panel window similar to the one in Figure 2.
4
Figure 2. Acquire, Analyze and Present Front Panel Window
4. Add a waveform graph to the front panel window to display the acquired
data.
❑ If the Controls palette is not already open, select View»Controls Palette from the
LabVIEW menu.
❑ On the Controls palette, select the Express category.
❑ Select the Graph Indicators category from within the Express category.
❑ Select the waveform graph.
❑ Add the graph to the front panel window.
5. Add a numeric indicator to the front panel to display the average value.
❑ Collapse the Graph Indicators category by selecting Express on the Controls
palette.
❑ Select the Numeric Indicators category from within the Express category.
❑ Select the numeric indicator.
❑ Place the indicator on the front panel.
❑ Enter Average Value in the label of the numeric indicator.
In the following steps, you build a block diagram similar to the one in Figure 3.
Figure 3. Acquire, Analyze, and Present Block Diagram
6. Open the block diagram of the VI.
❑ Select Window»Show Block Diagram.
5
Note The terminals corresponding to the new front panel window objects appear on the
block diagram.
8. Acquire a sine wave for 0.1 seconds. If you have hardware installed, follow the
instructions in the Hardware Installed column to acquire the data using the DAQ
Assistant. If you do not have hardware installed, follow the instructions in the No
Hardware Installed column to simulate the acquisition using the Simulate Signal
Express VI.
8. Determine the average value of the data acquired by using the Statistics
Express VI.
❑ Collapse the Input palette by selecting Input on the Functions
palette.
❑ Select the Signal Analysis palette.
❑ Select the Statistics Express VI and add the Statistics Express VI to
the block diagram to the right of the DAQ Assistant.
❑ Wait for the Statistics Express VI dialog box to open.
❑ Place a checkmark in the Arithmetic mean checkbox.
❑ Click OK.
9. Log the generated sine data to a LabVIEW Measurement File.
❑ Select Express on the Functions palette.
❑ Select the Output category.
❑ Select Write to Measurement File.
❑ Add the Write to Measurement File Express VI to the block diagram
6
below the Statistics Express VI.
❑ Wait for the Write to Measurement File Express VI dialog box to open.
❑ Leave all settings as default.
❑ Click OK.
10. Wire the data from the DAQ Assistant (or Simulate Signal Express VI) to the
Statistics Express VI.
❑ Place the mouse cursor over the data output of the DAQ Assistant (or Simulate
Signal Express VI) at the location where the cursor changes to the Wiring tool.
❑ Click the mouse button to start the wire.
❑ Place the mouse cursor over the Signals input of the Statistics Express VI and click
the mouse button to end the wire.
11. Wire the data to the graph indicator.
❑ Place the mouse cursor over the data output wire of the DAQ Assistant (or Simulate
Signal Express VI) at the location where the cursor changes to the Wiring tool.
❑ Click the mouse button to start the wire.
❑ Place the mouse cursor over the graph indicator and click the mouse button to end
the wire.
12. Wire the Arithmetic Mean output of the Statistics Express VI to the Average Value
numeric indicator.
❑ Place the mouse cursor over the Arithmetic Mean output of the Statistics Express VI
at the location where the cursor changes to the Wiring tool.
❑ Click the mouse button to start the wire.
❑ Place the mouse cursor over the Average Value numeric indicator and click the
mouse button to end the wire.
13. Wire the data output to the Signals input of the Write Measurement File Express VI.
❑ Place the mouse cursor over the data output wire of the DAQ Assistant (or Simulate
Signal Express VI) at the location where the cursor changes to the Wiring tool.
❑ Click the mouse button to start the wire.
❑ Place the mouse cursor over the Signals input of the Write Measurement File
Express VI and click the mouse button to end the wire.
14. Save the VI.
II.3. Testing
1. Switch to the front panel window of the VI.
2. Set the graph properties to be able to view the sine wave.
❑ Right-click the waveform graph and select X Scale»Autoscale X to deselect
autoscaling.
❑ Right-click the waveform graph and select Visible Items»X Scrollbar.
❑ Use the labeling tool to change the last number on the X Scale of the waveform graph
to .1.
3. Save the VI.
4. Run the VI.
❑ Click the Run button on the front panel toolbar.
The graph indicator should display a sine wave and the Average Value indicator should
display a number around zero. If the VI does not run as expected, review the
implementation steps.
5. Close the VI.
II.4. Measuring a Signal
Using LabVIEW and NI data acquisition devices, you can acquire data and present it on
the user interface in minutes to analyze and explore the measured signal. Using NI
7
myDAQ, you can configure the device on the PC and acquire an analog signal as
follows:
1. Connect the NI myDAQ or a data acquisition DAQ device to your PC
2. Connect the signal of interest to Analog Input 0 (ai0)
3. Create a new VI in LabVIEW
a. Open LabVIEW and select File»New VI
4. Place a DAQ Assistant on the block diagram
a. Right-click on the block diagram and select Express»Input»DAQ
Assistant
b. Place the DAQ Assistant on the block diagram by left-clicking on it
5. Configure the DAQ Assistant type
a. Select Acquire Signals
b. Select Analog Input
c. Select Voltage
d. Select Dev1 (or the name of your device if not Dev1)
e. Select ai0 for Analog Input 0
6. Configure acquisition settings
a. Enter 10k for Number of Samples
b. Enter 10k for Sample Rate
c. Click Run to test your settings
d. Click OK to finish the DAQ Assistant
7. Create a graph indicator to view data
a. Right-click on the Data output terminal of the DAQ Assistant
b. Select Create»Graph Indicator
c. Run the VI by pressing the Run button and visualize the results
d. Adjust the Graph Indicator appearance as desired
8. Change Acquisition Mode to Continuous
a. Double-click the DAQ Assistant
b. Change Acquisition Mode from N Samples (Finite) to Continuous
c. Select OK to finish the DAQ Assistant
d. Select Yes to auto place the While Loop around the DAQ Assistant
9. Run the VI to visualize the data on the front panel
8
Figure 2. Configure the DAQ Assistant
Convert to the Frequency Domain
To find the noise on the measured signal, you need to see the signal in the frequency
domain. Using the Spectral Measurements Express VI, convert the time-domain signal
into the frequency domain. To measure the peak, the VI analyzes all of the frequencies
of your signal and displays them on your graph.
1. Place a spectral measurements function on the block diagram
a. Create a spectral measurements function by navigating to Express»Signal
Analysis»Spectral in
the Functions palette; place the function on the block diagram
b. In the Configure Spectral Measurements window, change the Selected
Measurement to Magnitude
(Peak)
2. Connect the functions and test the VI
a. Wire the data terminal of the DAQ Assistant to the Signals input of the
spectral measurements
b. Wire the FFT – (Peak) output of the spectral measurements to the input
terminal of the waveform graph
c. Return to the front panel and click the Run button (the white arrow in the
upper left corner)
9
Figure 3. Configure the Spectral Measurement
Filter the Unwanted Signal
Once you have identified the unwanted components of the signal, you can remove the
noise and keep the signal of interest. A filter removes an unwanted component or
feature but does not alter the original frequencies. Using a Lowpass Filter Express VI,
you can pass all frequencies below a specified value while removing higher frequency
values. While running LabVIEW, you can interact with the user interface and interact
with and modify the variable of the cutoff frequency as you acquire the signal.
1. Place a filter on the block diagram
a. Return to the block diagram and add a filter from Express»Signal
Analysis»Filter
b. Leave the Filtering Type as the default Lowpass, but change Cutoff
Frequency (Hz) to 400
10
Figure 4. Configure the Filter Express VI
Figure 5. LabVIEW VI for the Frequency Domain
11
Download