Download Digital Data - Data Acquisition and FFTs - Lab 5 | M E 345 and more Lab Reports Mechanical Engineering in PDF only on Docsity!
Name: ______________________________________________
Date of lab: ______________________ Section number: M E 345._______
Lab 5
Precalculations – Individual Portion
Digital Data: Data Acquisition and FFTs
Precalculations Score (for instructor or TA use only): (^) _____ / 20
- The digital data acquisition system in this lab utilizes an A/D converter that is 16-bit, and has an input range of −10 to 10 V. How many bins or levels of A/D output are available?
- What is the resolution of this system (give your answer both as an overall resolution and as a +/- resolution, i.e., quantization error in millivolts to 3 significant digits).
- For the system used in this lab, suppose the voltage to be measured in a certain experiment is always positive, and never exceeds 2.5 V. How many of the 16 bits of the A/D converter are effectively utilized?
- Consider a pure sine wave signal at 50 Hz. 256 discrete data points are taken at f (^) s = 200 Hz, and an FFT is calculated. Calculate the total sampling time, the frequency resolution, and the maximum useful frequency of the resulting frequency spectrum.
- Suppose a signal from a vibrating motor is to be sampled discretely with a digital data acquisition system to determine the RPM of the motor. It is known that the maximum possible RPM is 1800. What is the minimum sampling frequency (in Hz) with which the signal can be sampled in order to measure the RPM of the motor? For full credit, show all your work and explain.
- For the same conditions as above, suppose also that the RPM needs to be known to within a precision of ± 1 RPM. Calculate the minimum number of discretely sampled data points necessary to achieve this resolution.
Cover Page for Lab 5
Lab Report – Group Portion
Digital Data: Data Acquisition and FFTs
Name 1: ___________________________________________________ Section M E 345._______
Name 2: ___________________________________________________ Section M E 345._______
Name 3: ___________________________________________________ Section M E 345._______
[Name 4: ___________________________________________________ Section M E 345._______ ]
Date when the lab was performed: ______________________
Group Lab Report Score (For instructor or TA use only) :
Lab experiment and results, plots, tables, etc. (^) _____ / 50
Discussion (^) _____ / 20
Neatness & grammar _____ / 10
TOTAL ______ / 80
Comments (For instructor or TA use only) :
NOTE: The instructor or TA reserves the right to deduct points for any of the following:
- Arriving late to lab or leaving before your lab group is finished.
- Not participating in the work of your lab group (freeloading).
- Causing distractions, arguing, or not paying attention during lab.
- Other (at the discretion of the instructor or TA).
Digital PC-based data acquisition will not totally replace oscilloscopes, at least not in the near future. The reason is sampling frequency. The maximum sampling frequency of modern PC A/D systems is typically only a few hundred kHz. Depending on the application, it may not always be possible to sample at five times the Nyquist frequency. By comparison, a good digital oscilloscope may sample as high as several GHz (gigahertz)!
The fast Fourier transform (FFT) The fast Fourier transform ( FFT ) is a computationally efficient form of the more general discrete Fourier transform ( DFT ), which is itself a discretized version of the even more general Fourier transform ( FT ). Like Fourier series analysis, FFT analysis enables us to calculate the frequency content of a signal. Fourier series analysis is useful for continuous, periodic, analog signals of known fundamental frequency. FFT analysis, on the other hand, is useful for discretely sampled ( digital ) data, and can be applied even if the signal is not periodic. With FFT analysis, the fundamental frequency of a periodic signal does not have to be known a priori.
For N sampled data points at sampling frequency f (^) s , the most useful output of an FFT calculation is the frequency spectrum or amplitude spectrum , which is a plot of modified FFT amplitude versus frequency. The frequency spectrum shows the relative importance or contribution of discrete frequencies, which range from zero to f (^) s /2. (The factor of two is a direct result of the Nyquist criterion.) The number of discrete frequencies on the frequency spectrum plot is N /2 – half of the number of discretely sampled data points in the original signal. Other details about FFTs, along with equations and examples, can be obtained from the lecture notes. Here, a brief summary is provided of the parameters that are important when using FFTs in a laboratory experiment:
- N is the number of discrete data points taken. N is an input parameter, chosen by the user.
- f (^) s is the sampling frequency , in Hz. f (^) s is an input parameter, chosen by the user. All other properties of the FFT, including sampling time, maximum frequency, frequency resolution, etc., are determined solely from these two inputs, N and fs.
- T is the total sampling time , and is calculated as T = N / f (^) s. To increase the sampling time, we must either increase the number of data points, or decrease the sampling frequency (or both).
- f folding is the folding frequency , also called f max , the maximum frequency. f folding = f (^) s /2. f folding is the maximum frequency plotted on the frequency spectrum plot, since f folding is the maximum frequency at which reliable information about the signal can be calculated, due to the Nyquist criterion. The only way to increase f folding is to increase the sampling frequency.
- Δ f is the frequency resolution or frequency increment of the frequency spectrum. Δ f = 1/ T = f (^) s / N. On the frequency spectrum plot, amplitudes of the FFT are plotted at N /2 discrete frequencies, each separated by Δ f. In other words, the discrete values of f are 0, Δ f , 2Δ f , 3Δ f , ... , [( N /2 – 1)]Δ f. [In practice, the amplitude at exactly f folding , i.e., at ( N /2)Δ f , is also plotted; this results in a total of ( N /2) + 1 discrete frequencies, counting both f = 0 and f = f folding .] The only way to increase the frequency resolution is to increase sampling time.
Here is a summary of some useful techniques and rules to remember when calculating FFTs:
- To get better frequency resolution for a fixed sampling frequency, increase the number of data points.
- To get better frequency resolution for a fixed number of data points, decrease the sampling frequency. (But be careful here not to let fs fall below the Nyquist criterion limit.)
- To get frequency component information at higher frequencies, increase the sampling frequency.
- To reduce leakage in the frequency spectrum (see lecture notes for a discussion about leakage), do one or more of the following: o Increase the number of sampled data points N (at the cost of more computer time). o Decrease the sampling frequency f (^) s (but do not sample at such a low frequency that the Nyquist criterion is violated). o Multiply the time signal by a windowing function prior to taking the FFT (at the cost of throwing away a significant portion of the signal, in particular data points near the start and finish of the time trace).
There are specialized instruments called spectrum analyzers that calculate the frequency spectrum of an input voltage signal. The present lab does not use spectrum analyzers. Instead, a virtual spectrum analyzer is built using LabVIEW, and the voltage signal from a function generator is sampled and analyzed with the computerized digital data acquisition system. LabVIEW has a built-in FFT feature, which is utilized in this lab.
Objectives
- Become familiar with the basics of programming in the LabVIEW environment.
- Create a virtual instrument that samples a single channel of data, and displays the time trace.
- Experience and record clipping, aliasing, and other pitfalls of digital data acquisition.
- Further develop programming skills in the LabVIEW environment by adding a frequency spectrum to the virtual instrument.
- Experiment with FFT analysis of signals, and become familiar with the parameters.
Equipment
- personal computer with digital data acquisition, LabVIEW virtual instrumentation software, and Microsoft Office
- function generator, along with appropriate cables
- digital oscilloscope
Procedure Build the data acquisition virtual instrument
- Connect the output of the function generator to the oscilloscope and also to the first channel of the A/D board ( Note : use AI0 (Analog Input 0), not AO0 (Analog Output 0), using BNC cables and a BNC tee connector.
- Turn on the function generator, oscilloscope, and data acquisition box (power button on the back – dim green LED indicator on the front to show that it is on).
- Adjust the function generator so that a sine wave of approximately 50 Hz is being produced. Hit the Autoset button on the scope to monitor the signal.
- Using the oscilloscope as a monitoring tool, adjust the amplitude to around 2 V peak to peak so that the signal will not cause clipping in the A/D board when the virtual instrument starts to sample data. (Failure to do so may lead to an error in LabVIEW.)
- Turn the DC offset knob to its middle position, so that there is approximately zero DC offset (for some function generators, the DC offset knob must be either pushed in or pulled out in order to have any effect).
- Generate your own virtual instrument, following the procedure provided on the pdf file, LabVIEW_USB_DAQ_SIGNAL_instructions.pdf.
Test the digital data acquisition system, and observe clipping
- Set the function generator to produce a 50 Hz sine wave, with nearly zero DC offset, and with a peak-to-peak amplitude of around 5 or 6 V.
- Set the sampling rate of your virtual instrument to 2000 Hz, and the total number of data points per scan (called “Samples to read” on the virtual instrument) to 200, so that 0.1 seconds of data will be displayed ( full cycles of the 50 Hz waveform).
- Run. The digitally acquired signal (the perceived signal) should accurately reproduce the input sine wave since approximately 40 discrete points per sine wave period are available (200 data points / 5 periods).
- Adjust the DC offset and/or amplitude knobs of the function generator to see how the digital signal is clipped when the input signal is out of range. Note : Let each person in the group have a chance to manipulate the knobs on the function generator, so that each individual can personally experience the thrill of digitally clipping a signal.
- When you have a display that clearly illustrates clipping, Stop.
- Open a Microsoft Word document into which images and information will be copied and pasted: Start-All Programs-Microsoft Office-Microsoft Word
- Copy the graph from LabVIEW (highlight the graph by clicking on it, and then Edit-Copy). Paste (Edit- Paste) it into the Microsoft Word document. Later on, you will copy the graphs generated in this lab directly into your lab report.
- In the Word document, type in the frequency setting of the function generator. Also copy an image of the settings of the virtual instrument for proper documentation. Specifically, drag the mouse cursor over the entire Timing Parameters portion of the Front Panel window, and then copy and paste it into Word.
Add FFT capability to your virtual instrument
- Modify your virtual instrument so that it becomes a virtual spectrum analyzer , following the procedure provided on the pdf file, LabVIEW_USB_DAQ_FFT_instructions.pdf.
- Copy the diagram of your FFT virtual instrument (from the Diagram window) into your Word document (this is required for your lab report), as follows:
- Return to a sine wave. Keep decreasing the sampling frequency. At what sampling frequency do you start to see aliasing in the frequency spectrum? Sampling frequency where aliasing begins = ___________ Hz
- When you have a display that clearly illustrates aliasing, copy and paste both the time trace graph and the frequency spectrum graph into your lab report document using the procedure discussed above. See attached Figures ____________.
- Play with the signal frequency and/or the sampling frequency to experience other examples of aliasing, as discussed in class. For example, generate a 50 Hz sine wave, but sample at 55 Hz. You should see a normal 50 Hz sine wave on the oscilloscope, but an aliased sine wave at around 5 Hz on the virtual instrument. The frequency spectrum should show a peak at around 5 Hz as well. Copy and paste the time trace and frequency spectrum into your Word document for the lab report, along with the settings of your virtual instrument. See attached Figures ____________.
- With the function generator set to produce a 50 Hz sine wave, experiment with the input parameters: number of points per scan (we call this N ) and sampling frequency fs. Notice their effect on the frequency spectrum. Note : If a large number of data points is specified, it may take a while for the computer to sample the data and calculate the FFT − be patient. Record your observations below:
- With the function generator set to produce a 50 Hz sine wave, record (copy the plot into a Microsoft Word file) the time trace and frequency spectrum for the following cases: o Case 1 - sampling frequency, fs about 1.2 times larger than that required by the Nyquist criterion, and 256 data points. ( Note : The number of data points, N , is called “pts/scan” in the LabVIEW module. When LabVIEW runs one scan, it samples N data points and stops. When LabVIEW runs continuously, it samples N data points, and then N more, etc. until the Stop button is pushed.) Save the time trace data for this case only to a Microsoft Excel spreadsheet. Calculate an FFT within Excel, as shown in class, and generate the corresponding frequency spectrum. Attach a copy of the first page of the Excel spreadsheet (along with the plot itself) to the report. Note : To save paper, use Excel’s File-Page Setup feature to reduce the margins and to shrink the printout to one page wide. Also use Excel’s File-Print Preview feature to see what the printout will look like before sending it to the printer. o Case 2 - same number of data points ( N = 256), but at twice the sampling frequency. o Case 3 - same number of data points ( N = 256), but with f (^) s decreased to 70 Hz. o Case 4 - same sampling frequency as Case 1, but with four times better frequency resolution. (You will need to think carefully about how to set this up.) o Case 5 - Change the sine wave to a triangular wave. Adjust the sampling frequency and number of data points such that a reasonable frequency spectrum is generated; copy the time trace and frequency spectrum plot into Word, and record the input parameters (pts/scan and sampling frequency).
- In your Microsoft Word document (which will become part of your lab report), add text identifying each of the plots copied from LabVIEW, along with an explanation of each. Be sure to explain how each case was produced, indicating the parameters involved, such as the function generator frequency and type (sine wave vs. triangular wave), sampling frequency, number of data points, etc. Each figure must be numbered and labeled appropriately, and referred to by number in the text of the report.
Exit LabVIEW and save your files
- Exit LabVIEW. Note : Select No to All if prompted about saving other things − you do not want to change your default settings.
- Restore all equipment to its original location. Before you leave, be sure to take an electronic copy of your virtual instrument (vi file), your Excel spreadsheet, and your Word document.
Discussion Questions
- Discuss when and how clipping was observed in your measurements.
- Discuss when and how aliasing was observed in your measurements.
- For one of your cases with aliasing, use the equations given in class (and, if necessary the folding diagram) to predict the aliasing frequency. Compare with your actual observation and discuss.
- Compare the frequency spectra for Cases 1 through 4. These are all spectra of the same sine wave signal, yet the results are not all the same. Explain why there are differences in these cases. Do any of them show signs of aliasing? Which one is the best? Why? Which one is the worst? Why?
- Explain why there are many harmonics on the frequency spectrum of the triangular wave (Case 5).
- Is the frequency spectrum generated by Excel the same as that generated by LabVIEW? Discuss.