ME 368Analog and Digital Filters Laboratory 6

Laboratory 6

Analog and Digital Filters

Equipment needed

Wallplug voltage divider

Resistance substitution box

Capacitance substitution box

Commercial filter: Frequency Devices model 950 tunable low- or high-pass filter with gain set to zero.

NI myDAQ/LabVIEW

Goals and Objectives

  • Understand the basic operation of filters, both digital and analog
  • Understand differences between digital filtering, analog filtering
  • Consider filter applications
  • Gain familiarity with aliasing

mini-report 1: For this lab you will be writing an abstract. You can refer to the “executive summary” of the sample lab report, however that is too long. Your abstract will be 1 paragraph, 200 words maximum. It should summarize what you did, and should provide quantitative information about your key results (keep a log of quantitative key results as you work this lab)

1.0 Introduction

1.1Introductory exercise

With the wallplug voltage divider disconnected from wall power, inspect the packaging tape to make sure there is an intact barrier that will prevent you from getting a shock. Use the myDAQ DMM to determine the two resistances inside. Then, plug it in to wall power, after which point you should remain wary of the packaging tape area. Use ai0 of themyDAQ to monitor the AC signal.

lab completion a: determine

  1. The peak-to-peak voltage of the AC power at the wall in 2153 ME
  2. The dominant frequency of the AC power at the wall in 2153 ME. One way to measure this is to record N periods of data (say N = 10), then find the time it takes for N periods, then divide by N to find the time of one period, then compute f as the reciprocal of the time of one period.
  3. whether you can observe deviations from sinusoidal behavior in the signal
  4. whether you can observe deviations from periodic behavior in the signal

1.2Introductory remarks

Filters are required for many applications in process monitoring, process control, and communications. For example, you may be aware that many signals involving AC power “pick up” interference at typically 60 Hz. It is often desirable to remove this interference; it can be removed with a so-called notch filter, that blocks a very narrow range of frequencies around 60 Hz but allows all other frequencies to pass relatively unaffected. Another important use for filtering is to remove unwanted or unneeded signal information at high frequencies so that a digital data acquisition system can sample the desired signal at a low sampling frequency without concern that the high frequency information contaminates the sampled data. In addition, filtering can reduce random noise that appears on many signals. You have already used moving average filters and sample compression fornoise reduction, so you are already familiar with this use of filters, but you will become even more familiar soon.

All measurement systems inherently filter the signal that they are measuring. In other words, even if you don’t knowingly introduce a filter into signal electronics, something in the system still filters the data. Even a simple pair of wires behaves like a filter. And, for example the mass of a temperature sensor causes it to take some time for the sensor to heat up, and this heat-up time effectively filters the temperature information.

In this lab, we will investigate various aspects of digital and analog filters with the goal of understanding the effects of applying them to acquired signals and when to choose analog over digital or vice versa.

2.0 Prerequisites and Preparation

It is assumed that you have already been exposed to filtering using resistors and capacitors in one of your introductory physics or electrical engineering courses. You should understand, or remind yourself of, the definitions of

  • low-pass filter
  • high-pass filter
  • band-pass filter
  • band-reject (or notch) filter
  • cut-off frequency

Relevant sections from Dunn on related topics are: 2.6, 3.5, and 3.7. We recommend that, in addition to reviewing Dunn, you review other material related to first order low-pass filter design and high-pass filter design from other sources, such as your electrical engineering text or the internet.

3.0 Signal Generation

For much of this lab you will simulate signals rather than record them from physical voltage signals. You will use the “Simulate Signal” Express VI for this purpose.

4.0 Power Spectral Analysis

Open Lab6_starter.vi. Figure out what it does. To start, set it up so the 3 signals summed are:

  • 1: Noise without a sine wave
  • 2: A sine wave without noise
  • 3: A sine wave at a different frequency without noise

Add a Spectral Measurements Express VI to the Block Diagram (In the Signal Analysis Menu). Feed the same signal that goes to the graph to this VI. Select the options so that you are displaying

  • Magnitude (peak), result “Linear”
  • using a Hanning Window
  • and are Averaging in RMS Mode with exponential weighting and 10 averages while producing a spectrum after each iteration. You can increase the number of averages from 10 in the future if you wish.
  • Add a graph indicator to the output of the spectral measurements express block. You should retainthe original graph, this graph should be in addition to that one. Set the y-axis of this new plot to logarithmic mapping by right-clicking on the y-axis. You may also wish to set the x-axis to logarithmic mapping. The new plot you generated is called the Fourier representation (a.k.a. Fourier transform, power spectral density, etc.) of the signal. The relevant sections of Dunn for further reading on Fourier transforms include 9.5, 9.8, 9.9, 10.4, 10.5
  • First, set the noise amplitude to zero and investigate the Fourier transform for the two sine waves summed together as you vary the amplitudes / frequencies of the sine waves.
  • Now add some noise back in and note how this impacts the spectrum

lab completion b: what does the Fourier transform tell you about the signal?

5.0 Digital Filter – Low Pass

  • Add a Filter Express VI (from the Signal Analysis menu) to the block diagram and connect to its inputanother wire from the formula output. Do this without disconnecting any other parts of your code.
  • Select Low Pass with a cut-off frequency of 1000 Hz
  • Use a Butterworth topology and change the Order to 1.
  • Add a control to the “Lower Cut-off” input
  • Also, feed the output of the filter to a copy of your previous spectral measurements express block. Merge like signals and then graph the merged result so each of your 2 graphs now contains 2 signals.
  • At the original input controls on the front panel, set the amplitude of the sine wave signals to zero and set the amplitude of the noise to 41.
  • Run the VI and observe the spectrum. Change the cutoff frequency control and observe the change in the shape of the spectrum (note that because we have some averaging active in the Fourier transformation blocks, you’ll need to wait some loops for the graph to reach an approximately final state). Finally, return the cutoff frequency to 1000 Hz. We will next prepare some plots with the cutoff frequency fixed at 1000 Hz.

We are particularly interested in documenting where the filter “edge” is located and how steep it is. At the end of this exercise we will be plotting various filter performance characteristics on a single graph.

  • The filter edge is specified by the cutoff frequency, fc, that you recently adjusted. The cutoff frequency is usually defined as the point at which the output signal has ½ the power of the input signal. Because power is proportional to voltage squared, and because 0.707 squared is ½, the cutoff frequency is the frequency at which the output voltage is 0.707 times the input voltage. It may be helpful to activate and use the cursor tool associated with the graph to help you find this point on your graphs.
  • Relative to the filter steepness, let’s begin by considering f10, the frequency at which the filter output voltage is 10% of the input voltage (corresponding to an output power of 1%). To provide an indicator of the steepness, we will define a parameter S = fc / f10.

lab completion c: how doesfcvary with order, for orders 1, 2, 4, and 8?

mini report 2: prepare a table of S vs. order for orders 1, 2, 4, and 8.

6.0 RC filters

In order to study the behavior of analog filters, we need to be able to generate a physical voltage output from the myDAQ instead of working only with the simulated signal as above.

  • Add a DAQ Assistant Express VI and select Generate signal, select voltage and then select the ao0 output of the NI myDAQmodule.
  • Set the rate to 200000 samples per second and the number of samples to 20000
  • Feed the data input terminal of this VI the same signal you fed to the graph in the previous code.

Add a DAQ Assistant to collect data from channel ai0 of the myDAQ. Set the input DAQ Assistant to 200000 samples per second and 20000 samples. Display the ai0 measurement in both the time domain and the Fourier domain (2 graphs). Physically (using real wires) connect the output ao0 channel to the ai0 channel. Run the VI. You may have to adjust the number of samples in one of the blocks governing analog output generation or analog input collection so that your data does not appear truncated.

lab completion d: Have any significant differences arisen by including physical voltages?

Now, turn the amplitude of the sine waves to zero and set the noise to a nonzero number that seems to behave well (noise amplitude = 1 may be a good choice). Next, we will add a filter; however, this time the filter will be a physical filter rather than a software (digital) filter.

  • Create a low-pass filter with the resistance and capacitance substitution boxes at your station. Whenever you do this, you may find it beneficial to avoid low resistances (say < 100 ohms) and low capacitances (say < 100 pF) to limit the effects of parasitic and stray resistances and capacitances.
  • Without running the VI, choose capacitance and resistance values to set the cut off frequency toa value near 1000 Hz.
  • Now, run the VI and record the spectral output of your RC low-pass filter and determine its actual cutoff frequency, fc as well as the steepness parameter, S.

lab completion e:Compare the S value to those gathered above for Butterworth orders 1, 2, 4, and 8. Based on S, to which order digital filter does your analog filter match best?

  • Now, create a high-pass filter with the resistance and capacitance substitutions boxes
  • Without running the VI, choose capacitance and resistance values to set the cut off frequency to 10000 Hz.
  • Now, run the VI and record the spectral output of your RC high-pass filter and determine its actual cutoff frequency.

mini report 3: How closely does the actual fc (measured in LabVIEW) compare to the circuit-design fc value? As usual, be quantitative.

7.0 Commercial filter

Replace your analog filter based on substitution boxes with the commercial filter.

lab completion f:At what approximate order does this filter perform?

8.0 Aliasing and Analog vs. Digital Filters

One of the key uses of analog filters is to eliminate aliasing, which we will now investigate. Relevant sections in Dunn include 10.2, 10.3.

  1. Open the options for the Input DAQ Assistant
  2. Change the sample rate to 20000 Hz and the number of samples to 2000. Click OK. Note that ½ the sample frequency (10 kHz in this case) is a special frequency called the “Nyquist frequency”. Pay special attention to this frequency for the remainder of this lab.
  3. Set your signal generator to generate two sine waves: one with a frequency of 1000 Hz and the other with a frequency of 9000 Hz, each with an amplitude of 1. Set the noise input to 0 amplitude.
  4. Connect ao0 directly to ai0 (no filter).
  5. Graph the ai0 measurement both as a time trace and a frequency spectrum, as before.
  6. Vary the frequency of the high frequency sine wave from 1100 Hz to 50000 Hz and note the graphs?

lab completion g: Describe aliasing in your own words, showing graphs to support your description.

  1. Now, design and implement an RC low-pass filter with a cut-off of 2000 Hz using the resistance and capacitance substitution boxes.
  2. Repeat step 6 above.

lab completion h: Does your filter have an anti-aliasing effect? Capture images or data to support your findings.

  1. Now, implement the commercial filter as an anti-aliasing filter. Repeat step 6 above. How well does the filter eliminate aliasing? Try to find the settings that give the best possible anti-aliasing performance.

lab completion i: What commercial filter setting did you choose? Why did you make this choice? At this setting, quantify the performance difference between the commercial and the substitution-box-based filters.

1 of 510/21/20189:15:51 PM