Histograms, Quantization Error, Signal Averaging, and Correlation
ME 368Histograms, Quantization Error, Signal Averaging, and Correlation Laboratory 2
Histograms, Quantization Error, Signal Averaging, and Correlation
NI myDAQ connected to LabVIEW
Two 50-ohm resistors
Electronic diaphragm pressure gage
5 V power supply
minireport 1: Later this semester you will write an entire report for each of 2 labs. To prepare, we begin by asking you to write one section per week. This week, prepare the “background” section only. This section would belong to a full report that describes this week’s lab, but you only need to write this one section. Your background section should include brief discussions of:
- Why it can be useful to measure nothing
- Histograms and their utility in this context
- Quantization error
- Signal averaging to reduce noise
Limit your submission to a maximum of one page. Include at least 2 references. The introduction section from the sample_full_report_lab1.docx file available in the lab_handouts folder gives you an example; you can probably write a higher-quality background section than the one in this example, but nonetheless the example is offered to give you a flavor for how a background section might look.
1.0 Histograms and signal averaging
Most of the scatter you will encounter in measurements follows a Gaussian distribution. In this lab, we will analyze some signals and assess whether they follow sucha distribution. The primary tool we will use to assess this is the histogram.
1.1 Random noise of a NI myDAQ at +/- 10 V range
Setup a DAQ assistant to measure the voltage of channel AI0 on the NI myDAQ. Use N samples, 20k samples to read, at 200,000 samples per second. Graph the result.
Connect a 50-ohm resistor between AI0+ and AI0-.
The resistor takes the place of an instrument that would normally present the signal of interest. The resistor ensures that the channel is measuring essentially nothing; in this case the internal noise of the data acquisition channel should be dominant. Run your VI. On the graph, you should see a signal that has a mean of approximately zero with some random scatter. Right-click on the numbers next to the y-axis. Change the formatting of these numbers (in default editing mode) to show more digits. Now the graph should autoscale appropriately (the data should fill much of the y-range of the graph). Have LabVIEW compute the mean and the standard deviation of the raw data.
preview of mini report 6: Populate the second and third columns of this table, and continue populating the table as you do the other parts of this lab. for mini report 6 you will turn in the fully populated table. Obtain the specification values from the myDAQ datasheet available on spideroak. Use the Typical value listed.+/- 10 V range measurement / +/- 10 V range specification / +/- 2 V range meas. / +/- 2 V range spec. / +/- 2 V range meas. (w/ averaging) / pressure gage measurement (+/- 2 V range w/ averaging)
/ not specified / not specified
We are interested in the histogram of this signal. Find histogram under express, signal analysis, and place it in your block diagram. Under amplitude representation, select “Percent of total”. Wire the data output of the DAQ assistant to the signal input of the Create Histogram block. Right click on the “Histogram” output and select create, graph indicator. Run your .vi. Double-click on the “Create Histogram” block and test different numbers of bins as well as different minimum and maximum in your histogram. Run the code to test. Make sure the histogram graph x-axis spans the same range as the minimum and maximum you entered into the “Create Histogram” block. Adjust the settings until your histogram looks roughly like this:
completiona (1 point): Verify that your histogram looks OK.
We will want to keep a copy of this exact histogram plot available on the front panel for the rest of the lab, while allowing the original histogram plot to update each time you run the code. To do this:
- find the histogram plot in the block diagram.
- make 2 copies (copy a and copy b) of it in the block diagram (ctrl-C once and ctrl-V twice)
- right click on copy a and select change to constant
- wire the constant to copy b
- verify that you now have 2 histograms on the front panel and that when you re-run the code, the original histogram updates while copy b always shows the archived copy
This copy will be referred to as the “+/- 10 V histogram archive” below.
Add a report express block so you can export the histogram graph to Excel (you can remind yourself how to do this by reviewing the lab1 instructions). Record (e.g., in the excel file) the mean and standard deviation associated with the saved data.
Plot the histogram data in Excel (it should look like the histogram from your .vi). Finally, add a plot of a Gaussian curve to your histogram plot. Use the following expression for the Gaussian curve:
The Gaussian curve will integrate to a value of 1.0, according to convention for probability density functions. Thus, for quantitative comparison, you should divide your measured histogram values by 100 (so it sums to 1 rather than 100%) and divide your measured histogram values by the bin spacing (so it integrates to 1 rather than sums to 1). Note: the peak values in the histogram after performing these operations will be well above 1.0.
To overlay two charts of different types (ie: a column chart and a line graph) in Microsoft Excel, first create the column chart with both the measured data and the theoretical Gaussian distribution included as separate data sets. One of the data series can then be converted to display as a line graph by right-clicking on it and selecting "Change Series Chart Type..."
To get the correct x-axis on the graphs, right-click on a dataset, click select data, under horizontal axis labels, click edit, select the correct x axis.
To plot histograms without gaps between the columns, right-click on a dataset, select format data point, series options, adjust gap width to no gap.
Your data probably contains values only at discrete numbers whereas your model function is a continuous function. The reason for the discrete data numbers is that the data acquisition cards are analog-to-digital converters that convert all input voltage signals to quantized numbers (see Dunn section 3.6).
mini report 2: Include the graph comparing your measured histogram to the Gaussian model function. Write a sentence or 2 of conclusions drawn from this graph. If your conclusions involve comparisons that could be quantitative, make them quantitative.
1.2 Random noise of a NI myDAQ at +/- 2 V range
Now, in the DAQ assistant settings, change the voltage range digitized by the myDAQ from +/-10 V to +/- 2V. In LabVIEW, find the new mean and standard deviation (add to the table above), and plot the new histogram (you will probably want to change the histogram settings to get a nice looking result).
completion b (2 points): Discuss with your instructor how the standard deviation for the +/- 10 V range data compares to the standard deviation for the +/- 2 V range data.
On the LabVIEW front panel, arrange the +/- 10 V histogram archivedirectly above your current histogram. Adjust the x-axes of the plots so they span identical ranges.
mini report 3: Provide a screen capture showing the two histograms. Write 1-3 sentences of conclusions drawn from this screen capture. If your conclusions involve comparisons that could be quantitative, make them quantitative. For example, rather than saying the +/- 2V range data has smaller quantization error, quantify how much smaller the quantization error is. Comment on whether the most recently acquired histogram appears Gaussian.
Archive the +/- 2 V range histogram the same way you did the +/- 10 V range histogram.
1.3 Averaging to reduce noise for the +/- 2 V range case
On your block diagram, we will next insert a 100-point moving average function right after the output of the DAQ assistant. As you calculated at the end of your previous report, this averaging function should act to reduce scatter in the data by a predictable factor.
completion c (2 points): by what factor should the standard deviation be reduced due to the 100-point moving average?
Drag the DAQ assistant to the left to make room. Right-click on the wire coming out of the data port, and select insert, all palettes, express, signal analysis, filter. Select smoothing under type, enter a half-width of 50, and click OK. Drag the blocks and wires around so you can see the data flow clearly. Run the .vi, and adjust histogram settings as before. Add the relevant data to the table above.
mini report 4:Provide a screen capture comparing the histograms for the unaveraged and averaged +/- 2V range data. Write 1-3 sentences of conclusions drawn from this screen capture. If your conclusions involve comparisons that could be quantitative, make them quantitative. Comment on whether the most recently acquired histogram appears Gaussian.
Archive the histogram for the +/- 2 V range data with averaging.
1.4 Random noise of the signal from the electronic pressure gage, +/-2 V range, with averaging
Unplug the resistor from AI0. Setup the electronic pressure gage as in lab 1. Power on the pressure gage, but don’t use a hairdryer (we will just be measuring ambient air, again similar to measuring essentially nothing). Record the signal on channel AI0. Complete the table above.
mini report 5:Provide a screen capture comparing the histograms for the averaged +/- 2V range data with the resistor and with the pressure gage. Write 1-3 sentences of conclusions drawn from this screen capture. If your conclusions involve comparisons that could be quantitative, make them quantitative. Comment on whether the most recently acquired histogram appears Gaussian.
mini report 6: Include the table you built in this lab. Compare all table values from which you can draw interesting conclusions. For example: describe the factor by which the standard deviation of an unaveraged measurement should be reduced by the 100-point moving average, theoretically; compute the actual factor it was reduced by and finally compute the ratio of the actual and theoretical values.
In this section we will examine the correlation of 2 signals.
2.1. Correlation of adjacent DAQ channels measuring nothing
Save your old .vi and open a new one. Connect a 50-ohm resistor between AI0+ and AI0-, and another 50-ohm resistor between AI1+ and AI1-. Setup one DAQ assistant to record data on both AI0 and AI1. Use N samples, 100k points, 200 kS/s. Create a graph to view the results as usual. In between the DAQ Assistant and the graph, insert a sample compression express block. You can do this as follows:
- hover over the wire connecting the DAQ Assistant to the graph until the wiring tool appears
- right-click and select insert, signal manipulation palette, sample compression
- use a reduction factor of 100
- this is another way to perform 100-point averaging, unlike the above method this method reduces the amount of data retained after averaging by a factor of 100 as well
Run the vi and look at the graph. Our goal in working with correlation is to determine if these two signals are correlated in the sense that when one goes up, is the other also likely to go up, etc.
On your front panel, right click and select graph indicators, XY graph. On the block diagram, wire up the XY graph as shown:
Note that the signals are split using the “Split signals” block found in Signal Manipulation. Run the .vi and adjust the formatting of the graph axis numbers so the plot autoscales nicely. This graph is showing AI1 vs. AI0, rather than both signals vs. time as you plotted previously. Display points rather than lines for this graph.
completion d (1 points): Compare this graph to Figure 8-10 Dunn. Do your data look correlated or uncorrelated?
Calculate the sample correlation coefficient, r, from equation 8.40 Dunn (note: this is easily accomplished by right-clicking on the block diagram, searching for correlation, and using Correlation Coefficient.vi)
mini report 7: Include your graph with a sentence describing what you’ve plotted. Describe whether the data look visually correlated or uncorrelated. Provide the correlation coefficient. Does the numeric value support your visual interpretation?
completion e (2 points): Explain why, physically, the data in are correlated or uncorrelated.
2.2. Correlation of adjacent DAQ channels, both measuring the electronic pressure gage
Disconnect the resistors. Jumper AI0- to AI1- and jumper AI0+ to AI1+; this will allow you to measure the same thing on each channel. Connect the output wires of the pressure gage to AI0+ and AI0- as well. Run the .vi
mini report 8: Include your graph with a sentence describing what you’ve plotted. Describe whether the data look visually correlated or uncorrelated. Does the numeric value support your visual interpretation?
completion f (2 points): Explain why, physically, the data are correlated or uncorrelated.
1/1/2019 6:46:02 AM