ME 368Analog and Digital Filters Laboratory 7

Laboratory 7

Filter applications and Fourier Transforms

Equipment needed

  • Resistance substitution box
  • Capacitance substitution box
  • Commercial filter: Frequency Devices model 950 tunable filter
  • NI myDAQ / LabVIEW

Goals and Objectives

  • Understand the performance of low-pass filters in noise reduction applications, and be able to predict the amount of noise reduction that can be achieved with a given low-pass filter
  • Understand the Nyquist frequency and how it relates to the maximum frequency displayed on a Fourier transform of sampled data and the sample rate used to acquire the data
  • Understand aliasing
  • Understand the frequency resolution of a Fourier transform and how it relates to the record length of acquired data
  • Understand the pros and cons of digital filtering versus analog filtering

1.0Understanding the built-in high-pass filter on the myDAQ

There is a high-pass filter built in to the audio in channels on the myDAQ. This means that low frequencies introduced to “audio in” will be attenuated. frequencies

completion a: According to the myDAQ specification sheet pg. 35, what is the high-pass filter cutoff frequency for the audio input channel? (hint: it is not 400 kHz)

Setup an experiment to experimentally determine the cutoff frequency (frequency at which the voltage transmission is 70.7%) for your myDAQ. One way to do this is to use the function generator at your station to provide sine waves of different frequencies to the audio input channel while recording data on the audio input channel. Avoid collecting more than 200 kS of data so as not to bog down your laptop. There are cables available to adapt one of the (stereo) audio input channels to wire-pair or BNC cabling.

completion b: What is the cutoff frequency you found experimentally for your myDAQ?

You will be writing a full report for this lab. The report is only to cover sections 2.0-4.0 below. It is due Friday 3/23/2012. The items indicated below as “REPORT:” are items you may wish to include in your report.

Your report must have each of the following 5 sections: abstract, introduction, background (this is where key pieces of theory / equations go), experimental description, results and discussion. You are encouraged to:

  • use lab time to prepare all the information you need (e.g. equipment information for your experimental description section, making sure you have all your plots the way you want them for your report)
  • review the previous assignments relative to writing each of these sections
  • write the abstract last.

For this report, you must keep the total word count below 1,500. Everything but figures, their captions, and any appendices are to be counted in this word count. Use 12 point Times New Roman font, single-spaced, with 1” margins on all 4 sides. On the cover page, you must also handwrite your total word count, and handwrite the honor code “I have not given, received, or tolerated others’ use of unauthorized aid on this report”, and sign and date it.

You will probably find it challenging to keep the word count below the limit, so start with an outline, then write concisely following the outline, tracking your word count as you write to make sure you are on pace.

2.0Fast Fourier transform limits: The Nyquist frequency, frequency resolution

Digital Fourier transforms are typically computed using “fast Fourier transform” (a.k.a. FFT) algorithms, and they have 2 key limitations that analytical Fourier transforms do not have:

1) They end at some maximum frequency. This frequency is known as the Nyquist frequency.

2) They have a finite frequency resolution.

We will begin this lab by exploring these two limits.

  1. From the course website, download Lab7_starter.vi
  2. Physically connect the ao0 port on the myDAQ to the ai0+ and ai1+ ports. Connect the AGND port between the ao and the ai ports to ai0- andai1-. Do not include a hardware filter.
  3. Note that this VI collects data from each of 2 Input DAQ Assistants ~ simultaneously:
  4. It records 1kSamples from ai0 at 100 kSamples/s.
  5. It records 1kSamples from ai1 at 10kSamples/s.
  6. For each of the 2 datastreams collected, the time trace is plotted along with the frequency spectrum, resulting in 4 plots total. When setting up the frequency spectrum, we recommend you select Magnitude (Peak), Linear result, Hanning window, and uncheck Averaging, although you can change these settings if you wish. Ultimately, you may wish to have 4 separate plots or merge them so there are fewer than 4, but start for now with the 4 separate plots.

Set your signal generator to generate two sine waves (set the third sine wave amplitude to zero): one with a frequency of 200 Hz and the other with a frequency of 202 Hz, each with an amplitude of 1. Set the noise input to 0 amplitude. Run the VI.

completionc: What is the maximum frequency that you can measure with each of the 2 channels? Note: this maximum frequency is called the Nyquist frequency. How does each Nyquist frequency relate to that channel’s sample frequency?

  1. Consider the frequency resolution for each of the 2 spectral plots. Frequency resolution has to do with your ability to distinguish nearby frequencies, like the 200 Hz and 202 Hz sine waves you are studying now.

completiond: What is the frequency resolution for each of the 2 channels? Find it using each of the following 2 methods for each of the 2 channels: a) measuring the spacing between adjacent data points on the FFT plot, using a cursor or zooming in and looking at points b) varying the 202 Hz frequency to find the frequency at which the 2 peaks just merge into 1 on the FFT. How do the frequency resolutions [Hz] measured using method (a) relate to the total signal acquisition time[s] for each of the 2 channels?

3.0 Aliasing and Analog vs. Digital Filters

Now that you have a better understanding of FFTs, we will further study low-pass filters, following on from last week’s lab. One of the key uses of analog low-pass filters is to eliminate aliasing, which we will now investigate. Relevant sections in Dunn include 10.2, 10.3.

  1. Vary the frequency of the higher frequency sine wave slowly and smoothly from ~ 202 Hz to 50,000 Hz and try to make sense of what is happening on the graphs, particularly on your frequency spectrum graph(s).
  2. REPORT: Capture the output (e.g., screenshot) at combinations that demonstrate the effect of aliasing and how this appears in your output signal.

completione: Describe aliasing in your own words, using data recorded in lab to support your description. Mention the Nyquist frequency and its relation to the sine wave frequency in this description.

  1. Now, design and implement an RC low-pass filter with a cut-off of approximately 2000 Hz using the resistance and capacitance substitution boxes (keep the resistance above 100 Ω). Put the filter in between ao0/AGNDand your2ai channels. In this manner, you will low-pass filter the signal going to each of the input channels.
  2. Repeat steps 1and 2above.

completionf: Does your filter have an anti-aliasing effect? Show data that supports your findings

  1. Now, implement the commercial filter rather than your RC filter as an anti-aliasing filter. Repeat steps 1and 2above. Does this filter eliminate aliasing better than the RC low-pass filter? Try to find the setting that gives the best possible anti-aliasing performance.

completiong: What commercial filter setting did you choose? Why did you make this choice?

REPORT: Produce one or more plots that compares an FFT for the substitution-box-filtered signal to an FFT of the commercially filtered signal and show that the commercial filter has a better anti-aliasing performance.

4.0 Cleaning up a signal using your understanding of aliasing / filtering

Save the code you were using. For the remainder of the lab, you will use only 1 input consisting of connections to the ai0+ and ai0- ports.. To work the next part, we suggest starting by deleting all the blocks labeled ai1 and all the downstream graphs.

Prepare your signal generator to generate the sum of 3 sine waves and noise. Operating your ao0 channel at the 100kS/s rate with a record length of 150kS, generate a signal with 3 sine waves of amplitude 1.0, and with noise of standard deviation = 1.0. The frequencies of the 3 sine waves should be 500Hz, 1000 Hz, and 20550Hz. Sample this signal directly (without filters) using the ai0 channel at a sample rate of 20kS/s with a record length of 2kS. How does it look? What role does aliasing play? Now, imagine that the only signal we want is the 500 Hz one (imagine the noise and the 2 other sine waves are all unwanted garbage that is going to mess up our system). Try to implement a digital low-pass filter to transmit as much as possible of the desired signal while rejecting the undesired signals as much as possible. Try orders up to 8, and various topologies and cutoff frequencies.

REPORT: Archive the FFT of the best result you can achieve with the digital filter, and record the associated digital filter settings. Explain why the digital filtering struggles to remove the aliased signal.

Next, eliminate the digital filter and instead use the physical commercial filter with the same goal.

REPORT: Archive the FFT of the best result you can achieve with only the commercial filter, and provide your filter setting. Explain why the commercial filtering struggles to eliminate the 2 unwanted frequencies while retaining the desired frequency.

Finally, use a digital filter and a commercial filter together. Find the best combination of settings on the filters.

REPORT: Archive the FFT of the best result you can achieve with both the commercial filter and the digital filter, and record the associated your filter settings.

1 of 412/28/201811:07:35 PM