Physics 121 - Lab #3: Frequency Analysis, Resolution, Noise, Aliasing, Filtering
In the previous exercises we learned methods for recording and generating voltage signals. Here we will investigate methods of signal processing and analysis and issues that influence the quality of recorded signals.
Concepts
Resolution in analog-to-digital conversion
Fourier-transform based frequency analysis and aliasing
Noise characterization, wiring considerations to minimize noise, common mode rejection
Digital and analog filtering
Background Reading
"NI USB-6212 Device Specifications.pdf", "NI DAQ Specifications Glossary.pdf", "DAQ M Series User Manual.pdf" (note useful glossary at end of manual)
"Wiring and Noise Considerations.pdf" and "Labview Analysis Concepts Guide.pdf"
►► Exercise 1: Measurement Resolution in Analog-to-Digital Conversion Write a Labview program using DAQ assistant to do continuous buffered
acquisition at 250 kHz (or the fastest possible) and plot the data on a graph once per second for 10 seconds (for loop).
Show the instructor or TA that your program works
Generate a ~1 Hz sine wave with amplitude ~1 V from the bench function generator and record it with the DAQ input range set to -10 to 10 volts.
Configure the plot so that it shows the individual data points by right clicking the graph label "voltage" in the upper right corner of the plot and choose a plot type with points.
Zoom in on the graph to look at the individual points by right clicking the graph and select "Visible Items > Graph Palette". This shows a "magnifying glass" tool next to the graph window. Click this and draw a rectangle on the graph to zoom in. You can zoom out by clicking that option in the tool palette.
Change the formatting of the numbers on the axes by right clicking on them. It is often convenient to use "scientific" formatting with four digits of precision.
Questions to Investigate
a) What is the specified resolution (smallest resolvable voltage change) of the NI USB-6212 card? What do you experimentally determine to be the resolution? Determine this by looking at a zoomed-in plot of the recorded data points to examine what is the smallest voltage change recorded. Include this plot in your report.
b) Does this resolution change if you reduce the analog input range to -5 to 5 volts. Include results and answers in your lab report.
►► Exercise 2: Frequency Analysis and Aliasing of Acquired Signals
"Hanning", Averaging On, Weighting "Linear", Number of Averages "10", produce spectrum "Every Iteration".
Set the function generator to generate a 130 Hz sine wave of amplitude ~5 volts (10 volts peak-to-peak) and record this signal.
Questions to Investigate:
a) Set the graph axis limits to show the interval from t=0 to 0.01 s and include this graph in your report. Do you see the expected number of periods of the sine signal?
b) Set the FFT graph to show the interval from 0 to 200 Hz. With the signal being recorded is there a clear peak at 130 Hz in the FFT? Include this graph in your report
Show the instructor or TA that your program works
c) Does the height of this peak equal the amplitude of the recorded sine signal? d) The function generator may not generate a perfect sine wave, so other frequency
components and noise may also be present. Change the plotted FFT range from 0 to 1000 Hz and change the amplitude axis to a logarithmic scale (right clicking the axis and select "Mapping > Log") so as to better see small and large components on the same graph. Include this graph in your report and note down any other prominent frequency components are present besides 130 Hz.
e) What happens to the height and width of the peak if you read only 80k samples per loop iteration in DAQ assistant instead of 250k samples (while keeping the
sampling rate at 250 kHz)? Why does it change?
f) How low can you reduce the sampling rate (while still calculating the FFT once per second) and still see a peak at 130 Hz in the FFT?
g) What happens if you reduce the sampling rate to 100 Hz? Why? Include results and answers in your lab report.
►► Exercise 3: Analysis of Noise in Data Acquisition
Investigate noise inherent to the DAQ card (and its cables and connector board):
Questions to Investigate
a) Add code to make your analysis program calculate the mean value and standard deviation of the signal. Display these with scientific format and three digits of precision.
b) Set the input range of the card to its most sensitive level (-0.2 to 0.2 volt range). Wire the two differential input terminals ( positive and negative) together with a short piece of wire so that nominally you should measure "zero volts" (plus
whatever noise is present) and record this to determine the FFT (averaged for 10 seconds – allow the loop which records 1 s of data to iterate ten times). Note that this is effectively a "floating signal source", so the inputs to the DAQ need to be wired up with "bias resistors" to DAQ ground as addressed in the prelab HW questions for lab #2 (submitted with the lab#1 report). What is the measured mean and standard deviation? What does the FFT look like (plotted with log scale on both axes)? Include in your lab report.
c) The DAQ card can be "self-calibrated" in the measurement and automation explorer program by right clicking on the listing for the USB-6212 card. Do the results change after doing this?
applied to both inputs. This helps reduce any noise fluctuations that are the same on both inputs, such as noise induced in the wires carrying the signals. Test how well the DAQ actually rejects a large common mode signal by applying a 10 V sine wave at 50 Hz from the function generator (grounded source) to both AI+ and AI- inputs. Use the FFT to determine what fraction of this signal leaks through.
Compare this to the common mode rejection ratio (CMRR) listed on the USB-6212 spec sheet (note: you will have to understand what is meant by "dB" units, which is explained in the "Labview Analysis Concepts" book).
e) Investigate what happens to the CMRR if you change the common mode signal to 10 kHz. Is this consistent with expected trend of CMRR vs. frequency shown in a plot in the USB-6212 spec sheet?
Include results and answers in your lab report.
►► Exercise 4: Analysis of Noise Produced by Power Supplies and Batteries
A "5V" power supply supposedly outputs "5V", but how stable is this? Investigate this with the program used in Exercise 5.
Questions to Investigate
a) Characterize the voltage output by the "5V" terminal on the DAQ card. Set the input range to -10 to 10V. Document the mean, standard deviation, and use the FFT (with log axis scale for amplitudes) to identify the most prominent noise frequencies.
b) Characterize the voltage output by the "5V" terminal on the benchtop power supply. Compare the mean and standard deviation to that of the DAQ card 5V supply and plot the FFT (with log axis scale for amplitudes) for both (with plot axis ranges set the same for both). Discuss how the FFTs compare.
c) Characterize the voltage output from an analog output channel on the DAQ card set to output 5 volts. Compare the standard deviation to that of the 5 V power supply and plot the FFT for both (with plot axis ranges set the same for both). Discuss how the FFTs compare.
d) Characterize the voltage output from a 9V battery. Compare the standard deviation to that of the 5 V power supply and plot the FFT for both (with plot axis ranges set the same for both). Discuss how the FFTs compare.
Include results and answers in your lab report.
►► Exercise 5: Analysis of Noise Arising in Wiring
As discussed in the technical note "Wiring and Noise Considerations ", noise can be picked up in wires between a measurement device and the DAQ card, and precautions should be taken to minimize this. Try the following:
Questions to Investigate
a) As in Exercise 3, attach a very short wire between the terminals of a differential analog input. Acquire data at the maximum rate input range -0.2 to 0.2 volts for 10 seconds. Determine and write down the standard deviation. Determine the FFT (averaged for 10 s, using log axis scales)
frequencies. Do you see evidence for "60 Hz" noise (or harmonics?) which typically originates from building power lines (because electricity is delivered as AC volts at 60 Hz)?
c) Noise can be picked up from nearby electronic devices. Try looping the 1 m wire around one of the computer monitors. Compare and discuss standard deviations and FFTs with the monitor on vs. turned off.
d) Configuring wires as a "twisted pair" (as illustrated on the right) supposedly reduces electrical noise pickup. Try reconfiguring
the long loop of wire to mimic a twisted pair (a loop has no end, but you can
imagine it to be two wires connected at the middle point of the wire and measuring "0 volts"). Drape the twisted wire over the computer monitor. Compare and discuss standard deviations and FFTs for the twisted pair vs. the open loop, and with the scope turned on and off.
Include results and answers in your lab report.
►► Exercise 6: Averaging, Smoothing, Digital Filtering
Noise can sometimes be filtered out by averaging, smoothing, or "digital filtering". This requires that the signal is sampled at a high enough rate that the noise is accurately sampled. The sampling frequency must be >2x, and preferably >5-10x the frequency of any significant noise, otherwise noise will be aliased to lower frequencies (meaning show up as lower frequency components in the recorded signal). Try the following:
Questions to Investigate
a) Use the "Simulate Signal" function to generate a 100 Hz sine wave, Amplitude=1 with 10,000 samples per second and 10,000 samples. Graph the signal from 0 to 0.1 sec (turn off x-axis autoscaling). Calculate the FFT and graph the result (with log axis scale for amplitudes) from 0 to 300 Hz.
b) Using a second "Simulate Signal" function and the "+" arithmetic function add a 1000 Hz sine wave, Amplitude=1 with 10,000 samples per second and 10,000 samples to the 100 Hz sine wave. Use the Express > Signal Analysis > Filter function "smooth" the signal with a "rectangular moving aperture". Plot the
original signal and and filtered signal for comparison. Plot the FFTs (with log axis scale for amplitudes) for comparison. Adjust the half width of the aperture (which is half the number of points being averaged) to try to smooth out the 1000 Hz sine wave while leaving the 100 Hz signal intact.
c) What happens to the 100 Hz signal if you smooth enough to reduce the 1000 Hz signal by 90%?
d) What is the most you can reduce the 1000 Hz signal while keeping 90% of the 100 Hz signal
e) Change the 1000 Hz signal to 200 Hz. What is the most you can reduce the 200 Hz signal while keeping 90% of the 100 Hz signal?
f) Change the filter type to a low pass IIR "Butterworth" filter with 4 poles and a "150 Hz" cutoff. How well does this separate 200 Hz from 100 Hz? What happens if you increase the number of poles?
g) Is there any disadvantage to increasing the number of poles? (Hint: look at the signal vs. time signal before vs. after filtering)
Include results and answers in your lab report.
A digital filter will NOT help you filter out undesired noise present at frequencies higher than the sampling rate used to record the signal. As seen above, noise will be aliased into the recorded signal and appear as lower frequency noise. However, you can use an electronic circuit to filter the signal before it is recorded by the DAQ card. A simple low-pass filter is the "RC filter" shown on the right. Theoretically this circuit will attenuate the peak amplitude of signals at frequency f according to Vout=V¿
1
√
1+(2πfRC)2.The frequency at which the signal is attenuated by a factor of 1/
√
2 is referred to as the"cutoff frequency".
Questions to Investigate
a) Write a Labview program that acquires a signal for 3 seconds (use DAQ assistant, N point acquisition at sufficiently high frequency) and then uses the "Tone
measurements" function (one from the <<signal analysis>> library) to
determine the amplitude and frequency of the signal. Test that this program works by inputting a signal from the function generator.
b) Build a low pass RC filter using a 47 nanofarad capacitor (in box labeled "0.05 microfarads") and 22 kΩ resistor and calculate the theoretical cutoff frequency. Note: you can set this up by inserting the resistor and capacitor leads right into the DAQ terminal board.
c) Use the benchtop function generator, set by hand, to send signals ranging from 100 Hz to 1000 Hz in steps of 100 Hz through the RC filter and determine the attenuation factor (Vout/V¿¿ for each frequency.
d) Use Matlab to plot the measured attenuation factor vs. frequency as points as a log-log plot (using the matlab command "loglog(x,y,'.');" and plot the theoretical attenuation factor on the same plot as a line "hold on; loglog(x2,y2);". Label the axes of the plot.
Include results and answers in your lab report.
►► Exercise 8: Response of an RC Analog Filter to White Noise
An alternative way to characterize the analog filter without needing to feed different frequencies thru it one-at-a-time is to feed a "white noise" signal into it, which contains a flat spectrum containing all frequencies. You can then analyze the transmitted signal by FFT to determine the whole transmitted amplitude vs. frequency response curve in one step.
Questions to Investigate
a) Write a Labview program that generates a white noise signal of amplitude 10V (use "Simulate signal" - you want noise only, no sine wave, so set amplitude of sine wave to 0) at 10,000 samples/sec and 70 seconds long (ignore warning that this is a lot of samples) and outputs this signal using the DAQ assistant, N-point analog output. Note: the DAQ assistant function has a setting (input terminal) called "Timeout", which is the maximum number of seconds it will run for. You need to set this to >70 seconds. Look at the output on the scope to make sure the program works.
FFTs set Averaging = On, Weighting = Linear, Number of Averages = 20). Plot the FFT on a graph with log scales (right click axes > mapping > log). Save the
averaged FFT using "Write Measurement File" (outside the for-loop, so that it only saves the final FFT). Write the file with No Header, one X-value column, to
facilitate later reading of the data into Matlab.
c) Pass the white noise signal thru the RC filter into the DAQ analog input. To acquire the signal start the first Labview program (that generates the 70 second long white noise) running and then quickly start the second Labview program (that records the filtered signal for 60 seconds).
Show the instructor or TA that your program works
d) Read the recorded FFT data into Matlab and compare the results with those theoretically expected and measured in Exercise 7 (plotting on a log-log plot). Note: V¿ at any particular frequency for the white noise signal is not 10V, as that amplitude is partitioned across all frequencies. You can determine the effective V¿ by looking at the FFT amplitude at low frequency (since
Vout=V¿ at low frequency).
e) Reconfigure your RC filter to be a "high-pass filter" and produce an experimentally measured plot of (Vout/V¿¿ vs. frequency for it.