<<

Sampling and

Math Technology Lesson Plan Two David Abrams

1. Why Sampling Theory is Important a. Most phenomena in the physical world are continuous (i.e., analog). Think about sound, temperature, light, heat, voltage and power. Each of these quantities can assume any value between some physical maximum and minimum and will vary over time. Digital computers, however, process discrete binary values, which means that real-world signals must be sampled to create data that computers can operate on. Analog-to- Digital converters (ADC) are used to sample analog signals for processing in digital environments, then the processed digital values are converted back to analog signals by a Digital-to-Analog converter (DAC):

b. The two important conversion parameters in the data converters in the block diagram above are: 1) the resolution or number of bits (shown as “/N” to indicate N binary signal lines) and the sampling speed. i. The number of bits determines the smallest fluctuation in the input signal that can be resolved in the digital signal. For example, if the input signal varies between zero and 10 volts and the DAC has a resolution of 10 bits, the smallest

signal that will be digitized as a unique value is . The choice of

resolution is determined by the noise level of the input analog signal and the desired resolution of the information you are interested in. In a thermometer it might be 0.1% of full scale while for a music audio application the resolution sets the dynamic range or ratio between the loudest and softest passages. ii. The sampling speed necessary to capture the input signal is dependent on how fast the input signal changes. It should be obvious that a slowly moving input signal, like outdoor temperature, can be sampled less often than a faster signal like music. It turns out there is actually a mathematical limit in choosing the sampling set by the Nyquist Sampling Rate or just the . c. Activity: Load the GeoGebra file sampling_2a.gbb. Vary the Sampling Frequency from its maximum value to its minimum. At what point does the red reconstructed waveform become unusable (i.e., at what sampling frequency can the input sine wave no longer be reconstructed from the red output signal)? i. Set the sampling frequency to its lowest value. Note that the low frequency reconstructed signal goes through the same sampled points as the original higher frequency sine wave. If both the lower frequency sine wave and the original sine wave could have been present in the input signal, there is no way to tell which sine wave is the correct output. ii. This phenomenon, where we get a reconstructed sine wave at a lower frequency than the sampled input sine wave, is called aliasing. It is the result of sampling the input at a frequency below the Nyquist rate. The result is that many signals can fit the same sampled data points. These signals are called aliases of each other. Once aliasing occurs, there is no way to recover the correct original input signal. 2. Sampling Theory a. To understand aliasing, we need to think about what is happening to our continuous input signal when we sample it. Load GeoGebra worksheet sampling_2b.gbb. The upper waveform is the signal we want to sample, ; in this case it is a 0.5 Hz cosine wave:

The middle graph is our sampling function . If the sampling frequency is :

To obtain the sampled waveform at the bottom, we multiply the input function by the sampling function:

Notice that any information in the original signal between the samples is lost after sampling. Our goal is to determine under what conditions this lost information does not preclude us from recovering the original . i. Activity: Vary the sampling frequency to see how it affects the sampled output

function. Again, note how, as the sampling frequency is reduced, there is a below which we cannot uniquely recover the input function. b. To understand how the aliasing problem arises, consider only the non-zero samples in :

These are the sample values that are stored in digital system. Since for all other values of , no additional information beyond that already lost by sampling is lost by only storing the values at the sample interval along with the sampling frequency.

Now, consider the sampled values of a cosine signal at :

since k is an integer. At , so

The sampled data for a cosine at 0.5Hz is identical to the sampled data for a cosine at

0.5Hz plus the sampling frequency (since ). This means, given a set of samples

, there is no way to know if the original input signal was a cosine at

or one at . Thus, and are aliases of

each other when sampled at .

c. Notice that the result is the same for sampled values of a cosine signal at . So it

does not matter whether we sample a cosine at plus or minus , the result is indistinguishable from a sampled cosine at frequency . In fact, the same is true of a

cosine signal at plus or minus any integer multiple of :

d. This means we can write a formula for all aliases of a sampled cosine of frequency :

Activity: Load GeoGebra worksheet sampling_2c.gbb to see the nearby aliases of the sampled output for the input in the , . The blue vertical spikes are nearby aliases predicted by the equation above, with the dashed blue spike signifying the alias nearest to the input frequency, . Vary the sampling frequency to see how it affects the location of the aliases. At what sampling frequency does the frequency of the nearest alias equal the input frequency? e. The reconstructed sampled data, , could represent any of the aliased cosine signals shown in the sampling_2c.gbb worksheet. We normally design sampling systems so that the correct output alias is the one with the lowest frequency and we select it with a low pass filter which eliminates all other aliases. Select the checkbox “Show Reconstruction Filter” to display the frequency response of the low pass filter at the output of the Digital to Analog Converter. Notice that as long as the sampling frequency is high enough, extraneous aliases are eliminated by the filter. However, if the sampling frequency is less than two times the input frequency, the nearest alias is “folded” into the pass band of the low pass filter and is not removed by the filter. Thus, we must sample at a rate at least twice the frequency of the highest frequency in the input signal to avoid folding aliases into the frequency range of the input signal. This is the Nyquist sampling rate. f. Real world signals rarely consist of a single frequency sine wave. However, since the Fourier Theorem states that any continuous signal can be expressed as a sum of a series of sines or cosines, and in linear systems superposition allows us to consider each signal separately, the aliasing analysis above holds for each sinusoid in the input signal. This allows us to apply the same analysis to a broadband input signal. However, once we have non-sinusoidal input signals, sharp transitions in the input can cause harmonics well above any reasonable sampling rate. Since we cannot recover the original signal if sampling aliases are folded into the input frequency range, we must include a low-pass filter on the input to the Analog-to-Digital converter to eliminate which could fold into the input range. This is called an anti-aliasing filter and it makes sure that no frequencies higher than one-half the sampling frequency are sampled. 3. Real-World Application a. The spectral range of a person speaking includes energy from about 80Hz to about 8Khz or so but most of the energy is between 300 and 3400 Hertz. Since only latter range is necessary to understand speech, analog telephones were designed to transmit only signals within this range:

All modern telephone systems send voice digitally; that is, they digitize speech and only send the digital samples, which are then reconstructed at the receiving end. Since the Nyquist Theorem requires that we sample at a rate at least twice the highest frequency in the input signal, we would have to sample at a much higher rate than necessary to transmit intelligible voice if we do not first filter the input signal. i. Activity: Load the GeoGebra worksheet sampling_2d.gbb. This shows the effect of aliasing on a real world band-limited signal such as voice. First look at the sampling requirement without an input filter. Notice that the nearest alias folds into the input signal at a sampling rate less than 16KHz. Any alias that appears within the hatched Reconstruction Filter region will be heard in the output signal. Since there is no way to distinguish the alias from the real input signal, this will not only make the output unintelligible, it cannot be corrected. Therefore, we would have to sample at 16Khz or higher to reconstruct the unfiltered input. (In an actual implementation, we would not be able to make a perfectly sharp Reconstruction Filter cut-off so we would have to sample a bit higher than 16Khz.) ii. Select the “Apply Anti-Aliasing …” checkbox to see what happens if we pre-filter the input signal with a 3,400Hz lowpass filter. (This filter also eliminates frequencies below 300 Hz to reduce 60Hz line noise but this is unnecessary to reduce aliasing.) Now vary the sampling frequency. How low can we reduce the sampling frequency before we have to worry about aliasing artifacts in the output signal? Since the highest frequency in the input signal is 3,400HZ, we should be able to sample at 6,800Hz or higher. Note, however, in the worksheet example the Reconstruction Filter cutoff for the band limited signal is 3,600Hz so if we actually sampled at only 6,800Hz some of the nearest alias would appear in the output signal. Therefore, we need to sample at a frequency a bit higher than the Nyquist limit to recover our input signal. Nevertheless, the input signal still allows us to build a system that requires much less storage and bandwidth than the unfiltered signal.

Worksheets Online

Sampling_2a: http://www.geogebratube.org/student/m115834 Sampling_2b: http://www.geogebratube.org/student/m115837 Sampling_2c: http://www.geogebratube.org/student/m115838 Sampling_2d: http://www.geogebratube.org/material/show/id/115839

Technology: These workbooks are constructed using javascript code attached to individual GeoGebra objects. The javascript calls GeoGebra scripting commands using the applet ggbApplet. See http://wiki.geogebra.org/en/Reference:JavaScript mru dea 2014-05-09