Global TMW:
Login  |  Register          Free Newsletter Subscription
Subscribe
Email
Print
Reprint
Learn RSS

Proper sampling ensures good data

Sampling a signal fast enough eliminates problems with aliases, but don

Paul Moffitt, Frequency Devices, Haverhill, MA -- Test & Measurement World, 7/1/2001

Analog-to-digital converters (ADCs) sample analog signals and produce a value that corresponds to a “snapshot” of the signal at a specific time. By taking samples at regular intervals, you can obtain data about a signal that you can process, plot, and store.

This information can tell you a great deal about the original signal. But because an ADC only produces discrete samples from a continuous analog signal, you cannot use your collected data to perfectly reproduce the original signal. The more samples you take during a given time, the better you can come to reproducing the original signal, but unless you take an infinite number of samples during that period—an impossibility—you have no way to reconstruct an exact duplicate of the original signal. If you pay attention to the ADC’s sampling rate and the type of signal you want to capture, though, for all practical purposes you can get close enough.

sampling_fig1.gif (5918 bytes)
Figure 1. Thirty-two samples over one cycle clearly show the signal’s sine-wave shape.
sampling_fig2.gif (7906 bytes)
Figure 2. With eight samples in one cycle, you lose some of the signal’s details, but its fundamental shape remains intact.

The plot in Figure 1 shows 32 equally spaced samples acquired during one cycle of a sine wave. The point-plot pretty well approximates the original sine wave. The plot in Figure 2 shows the effect of taking fewer samples of the same sine wave, again over one cycle. Connecting the acquired points with straight lines produces a graph that looks a bit like a sine wave, but it could look like something else, too. In fact, the sampling might have missed peaks or noise that occurred between the points shown in Figure 2. Taking more points during the same period might reveal such signals, but on the other hand, sampling too fast may simply fill your computer or instrument’s memory or disk with unneeded data.

By choosing the sampling rate to match the information you need to extract from a signal, you can ensure you capture enough points to acquire sufficient information. But how do you know what sampling rate to choose? First, you have to know about bandwidth. Every signal has an associated bandwidth that describes the maximum range of frequencies that make up the signal.

You probably recall that you can produce just about every periodic signal using a Fourier series. The series simply adds sine waves at various frequencies, phases, and amplitudes to produce a resultant signal. The Fourier series for a sine wave is simple; it’s just the sine wave itself. Thus, if the sine wave described above had a frequency of 100 Hz, it would also have a bandwidth of 100 Hz. Sine waves are just about perfect—what you see is what you get when it comes to bandwidth.

The bandwidths of other signals aren’t as simple to deduce. They usually contain many signals at many frequencies. That means most real-world signals have fairly wide bandwidths. A 100-Hz square wave, for example, would have a wide bandwidth because that signal results from summing the odd harmonics of a sine wave at the primary frequency. Thus, the 100-Hz square wave would contain signals at 100 Hz, 300 Hz, 500 Hz, and so on. In practical terms, the bandwidth of a 100-Hz square wave could reach several thousand hertz.

The rate at which you must sample a signal to obtain useful information for later analysis relates directly to the signal’s bandwidth. At first glance, you may decide you can sample the 100-Hz square wave, mentioned earlier, with only eight points. After all, both signals have a frequency of 100 Hz. But the square wave contains high-frequency components that you must capture, too, if you want the digitized signal to accurately represent the original signal. As you’ll see, taking eight samples per cycle would not capture enough information to reproduce these high-frequency components.

In 1924, Harry Nyquist at Bell Laboratories developed a mathematical relationship between sampling rates and bandwidth. Nyquist said that to accurately reproduce a signal, you must sample it at a frequency more than twice that of the highest frequency component in the signal. This is the same as saying you must sample a signal at more than twice its bandwidth. (Some texts and articles erroneously state the Nyquist sampling frequency, FNyquist, must be at least twice the bandwidth. It must be more than twice the bandwidth.)

So, for the 100-Hz sine wave, your ADC should acquire the signal at a sample rate of more than 200 samples/s. Things aren’t so simple for the 100-Hz square wave, however, because it has a wide bandwidth. Say you decide to sample at 250 samples/s to be on the safe side. Your data will contain information about the 100-Hz sine portion of the square wave, but you’re sampling too slowly to get useful information about the original signal’s third harmonic. (For a 300-Hz bandwidth, you’d need a sampling rate of more than 600 samples/s.) In fact, at 250 samples/s, you’d be sampling too slowly—undersampling—to get information about any of the harmonics. But those harmonics still exist in the square wave as the ADC takes measurements. Undersampling these harmonics leads to trouble.

To see how undersampling affects acquired data, consider a 12-kHz signal. To accurately obtain information about this signal, you’d need to sample it at greater than 24 ksamples/s. Undersampling the 12 kHz signal, at say 20 ksamples/s, leads to unexpected results. The graph in Figure 3a shows the original 12-kHz signal and a superimposed signal reconstructed from the ADC data obtained by sampling at 20 ksamples/s. The reconstructed signal never existed, it’s simply an artifact created by the undersampling process. Due to a mathematical effect called aliasing, the sampled 12-kHz signal now appears as an alias at 2 kHz in Figure 3b, the frequency-domain plot of the actual signal and the aliased signal. The difference between the two frequencies represents half the sampling frequency of the ADC.

sampling_fig3.gif (19331 bytes)
Figure 3. (a) Sampling below a signal’s bandwidth produces aliased artifacts in the bandwidth of interest. (b) Each frequency aboveFNyquist folds back into the signal’s bandwidth at FNyquist below the original signal.

The 2-kHz artifact falls within the 12-kHz bandwidth of the original signal. So, you can’t remove the artifact without degrading the original signal. You can remove the artifact by increasing the ADC’s sample rate to greater than 24 ksamples/s. Then, the original 12-kHz signal will properly appear in the ADC’s data. Because the 12-kHz signal won’t alias, you can attenuate it with an analog low-pass filter in front of the ADC.

You might wonder if you can sample at a rate exactly twice a signal’s highest frequency. In practical terms, don’t even try. Under ideal conditions, you could sample a perfect sine wave at a rate twice its frequency, but depending on how you time the sampling, you could see phase and amplitude shifts, so this type of sampling doesn’t warrant more discussion. Always sample at a rate higher than twice a signal’s bandwidth. I recommend you sample at a rate at least 2.5 times a signal’s bandwidth.

Most signals contain unwanted elements such as noise, distortion, or unneeded harmonics. In the case of the 100-Hz square wave, you may get needed information from just the primary frequency and harmonics out to 900 Hz. Assume the harmonics above that frequency don’t add appreciable information to the signal and you don’t need them. But those harmonics above the 900-Hz bandwidth of the signal you want to digitize still exist. Before you can sample the square wave, you must attenuate the unwanted frequencies to less than one least significant bit (LSB) before they reach your ADC. Otherwise, signals outside the bandwidth of interest will produce aliased signals in your digitized data. To minimize energy at frequencies above the bandwidth, you can install an analog low-pass filter in front of your ADC.

If your signal’s bandwidth approaches FNyquist, you may need a filter with a sharp roll-off. Typically, high-bandwidth ADCs that run in the megahertz range often sample their inputs at rates close to FNyquist. Those applications require a six-pole or eight-pole low-pass filter with a corner frequency much below FNyquist to sufficiently attenuate energy at frequencies above F Nyquist. Lower bandwidth systems such as those that operate at or near DC or at audio frequencies often sample at 10, 100, or even 1000 times the signal’s bandwidth.

With such oversampling, you increase FNyquist so some unwanted energy that exceeds your signal’s bandwidth falls below FNyquist and won’t alias. Under these conditions, you can use a less complex filter. As a rule of thumb, systems that sample at 32 times the signal’s bandwidth or higher require a two-pole or four-pole filter rather than a six-pole or eight-pole filter.

Don’t think that if you oversample a signal, you can use digital filters to remove all unwanted frequencies. Digital filters reduce an ADC’s effective sample rate through decimation of data, but only after the signal passes through an ADC. You can use a digital filter to remove interfering signals at frequencies between your signal’s bandwidth and FNyquist , but you can’t guarantee that no interference will occur above F Nyquist. Signals at those frequencies will alias into your signal’s bandwidth, and no digital filter can remove them because the digital filter resides after the ADC.

Keep that filter

Systems with digital filters still need low-pass analog filters in front of their ADCs. The plots in Figure 4 illustrate how an analog filter can affect the signals you wish to measure. Assume you want to measure signals within a 3-MHz bandwidth, and your signal includes interference above 6 MHz—the Nyquist frequency in this example. To let the ADC make useful measurements, the analog filter must attenuate all signals above the Nyquist frequency to less than one LSB. Thus for a 16-bit ADC, the filter must attenuate signals above 6 MHz by more than 96 dB. The analog filter chosen for this system starts to roll off at 1.9 MHz, but it attenuates signals above the Nyquist frequency by just 30 dB (Figure 4a). As a result, some of the interference will alias into the signal’s bandwidth where a digital filter can’t remove it.

sampling_fig4.gif (21527 bytes)
Figure 4. (a) Interference signals above FNyquist will alias into a signal’s bandwidth, and digital filters can’t remove them. (b) Reducing an analog filter’s cutoff frequency increases attenuation at higher frequencies.

Figure 4b shows that you can use an analog filter to attain a 96-dB attenuation above 6 MHz. But such a filter starts to roll off at only 23 kHz, thus it greatly attenuates some of the signals in the bandwidth you want to measure. If this added filtering attenuates your wanted signals too much, you’ll have to find an analog filter that offers a sharper roll off.

Always use an analog filter to attenuate frequencies above the Nyquist frequency for the bandwidth you want to measure. Although digital filters can remove signals below the Nyquist frequency, they can’t eliminate aliasing from frequencies above it. T&MW

Paul Moffitt is director of engineering at Frequency Devices. He holds a BS, an MS, and a PhD from the University of Arkansas. His background includes analog circuit design, semiconductor materials, and physics.

Try Nyquist for yourself

To get a feel for how frequencies above FNyquist will alias, you can conduct a simple experiment. You need a digitizer, a function generator, and software that displays signals in both the time domain and in the frequency domain. A data-acquisition card with scope software will work, as will a digital oscilloscope. You can also use a PC sound card with free software that you can download from the Test & Measurement World Web site.

First, select a sample rate. If you use a sound card, you can sample at 11 ksamples/s, 22 ksamples/s, or 44 ksamples/s. Set the function generator to produce a sine wave at a frequency less than 50% of your sample rate (FNyquist ). If you sample at 22 ksamples/s, try setting the function generator to 5 kHz. View the signal in the time domain and adjust its amplitude so the waveform looks clean—no clipping.

Switch to the frequency domain. You should see a spike at 5 kHz. Gradually increase the signal frequency. When the frequency exceeds FNyquist the spike will reverse direction, even though the function generator’s frequency continues to increase.

Next, try a signal that’s rich in harmonics such as a square wave. Or, just increase the sine wave’s amplitude until it clips and looks like a square wave in the time domain. In the frequency domain, you’ll see the aliased harmonics fold back, moving from right to left while the lower-frequencies move from left to right as you increase signal frequency. —Martin Rowe

Email
Print
Reprint
Learn RSS

Talkback

We would love your feedback!

Post a comment

» VIEW ALL TALKBACK THREADS

Related Content

Related Content

 

By This Author

There are no other articles written by this author.

Sponsored Links



 
Advertisement
SPONSORED LINKS

More Content

  • Blogs
  • Podcasts

Blogs

  • Rick Nelson
    Taking the Measure

    August 28, 2008
    What’s your battery IQ?
    What features do you look for in a battery, and do you know which battery technologies to choose to ...
    More
  • Rick Nelson
    Taking the Measure

    August 27, 2008
    Jim Williams gets a shout-out in Forbes
    Forbes magazine has discovered that Silicon Valley isn’t all “slick marketing pitches, s...
    More
  • » VIEW ALL BLOGS RSS

Podcasts

Advertisements





NEWSLETTERS
Click on a title below to learn more.

Test Industry News (3 Times Per Month)
Machine-Vision & Inspection (Monthly)
Communications Test (Monthly)
Design, Test & Yield (Monthly)
Automotive, Aerospace & Defense (Monthly)
Instrumentation (Monthly)
Resource Center E-Alert (Monthly)
©2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy
Please visit these other Reed Business sites