# Sampling Theorem – Baseband Sampling

For Matlab demo of sampling see here.

“Nyquist-Shannon Sampling Theorem” is the fundamental base over which all the digital processing techniques are built. Processing a signal in digital domain gives several advantages (like immunity to temperature drift, accuracy, predictability, ease of design, ease of implementation etc..,) over analog domain processing.

### Analog to Digital conversion:

In analog domain, the signal that is of concern is continuous in both time and amplitude. The process of discretization of the analog signal in both time domain and amplitude levels yields the equivalent digital signal. The conversion of analog to digital domain is a three step process 1) Discretization in time – Sampling 2) Discretization of amplitude levels – Quantization 3) Converting the discrete samples to digital samples – Coding/Encoding

The sampling operation samples (“chops”) the incoming signal at regular interval called “Sampling Rate” (denoted by Ts). Sampling Rate is determined by Sampling Frequency (denoted by Fs) as $$ T_s = \frac{1}{F_s} $$ Lets consider the following logical questions: * Given a real world signal, how do we select the sampling rate in order to faithfully represent the signal in digital domain ? * Is there any criteria for selecting the sampling rate ? * Will there be any deviation if the signal is converted back to analog domain ? Answer : Consult the “Nyquist-Shannon Sampling Theorem” to select the sampling rate or sampling frequency.

### Nyquist-Shannon Sampling Theorem:

The following sampling theorem is the exact reproduction of text from Shannon’s classic paper** ^{[1]}**,

“If a function f(t) contains no frequencies higher than W cps, it is completely determined by giving its ordinates at a series of points spaced 1/2W seconds apart.” |

Sampling Theorem mainly falls into two categories : 1) Baseband Sampling – Applied for signals in the baseband (useful frequency components extending from 0Hz to some Fm Hz) 2) Bandpass Sampling – Applied for signals whose frequency components extent from some F1 Hz to F2Hz (where F2>F1) In simple terms, the Nyquist Shannon Sampling Theorem for Baseband can be explained as follows

### Baseband Sampling:

If the signal is confined to a maximum frequency of Fm Hz, in other words, the signal is a baseband signal (extending from 0 Hz to maximum Fm Hz).

$$ F_s \geq 2F_m $$In order for a faithful reproduction and reconstruction of an analog signal that is confined to a maximum frequency Fm, the signal should be sampled at a Sampling frequency (Fs) that is greater than or equal to twice the maximum frequency of the signal. |

Consider a 10Hz sine wave in analog domain. The maximum frequency present in this signal is Fm=10 Hz (obviously no doubt about it !!!). Now, to satisfy the sampling theorem that is stated above and to have a faithful representation of the signal in digital domain, the sampling frequency can be chosen as Fs >=20Hz. That is, we are free to choose any number above 20 Hz. Higher the sampling frequency higher is the accuracy of representation of the signal. Higher sampling frequency also implies more samples, which implies more storage space or more memory requirements. In time domain, the process of sampling can be viewed as multiplying the signal with a series of pulses (“pulse train) at regular interval – Ts. In frequency domain, the output of the sampling process gives the following components – Fm (original frequency content of the signal), Fs±Fm,2Fs±Fm,3Fs±Fm,4Fs±Fm and so on and on…

Now the sampled signal contains lots of unwanted frequency components (Fs±Fm,2Fs±Fm,…). If we want to convert the sampled signal back to analog domain, all we need to do is to filter out those unwanted frequency components by using a “reconstruction” filter (In this case it is a low pass filter) that is designed to select only those frequency components that are upto Fm Hz. The above process mentions only the sampling part which samples the incoming analog signal at regular intervals. Actually a quantizer will follow the sampler which will discretize (“quantize”) amplitude levels of the sampled signal. The quantized amplitude levels are sent to an encoder that converts the discrete amplitude levels to binary representation (binary data). So when converting the binary data back to analog domain, we need a Digital to Analog Converter (DAC) that converts the binary data to analog signal. Now the converted signal after the DAC contains the same unwanted frequencies as well as the wanted component. Thus a reconstruction filter with proper cut-off frequency has to placed after the DAC to filter out only the wanted components.

### Aliasing and Anti-aliasing:

Consider a signal with two frequency components f1=10Hz – which is our desired signal and f2=20Hz – which is a noise.Lets say we sample the signal at 30Hz. The first frequency component f1=10Hz will generate following frequency components at the output of the multiplier (sampler) – 10Hz,20Hz,40Hz,50Hz,70Hz and so on. The second frequency component f2=20Hz will generate the following frequency components at the output of the multiplier – 20Hz,10Hz,50Hz,40Hz,80Hz and so on…

Note the 10Hz component that is generated by f2=20Hz. This 10Hz component (which is a manifestation of noisy component f2=20Hz) will interfere with our original f1=10Hz component and are indistinguishable.This 10Hz component is called “alias” of the original component f2=20Hz (noise). Similarly the 20Hz component generated by f1=10Hz component is an “alias” of f1=10Hz component. This 20Hz alias of f1=10Hz will interfere with our original component f2=20Hz and are indistinguishable. We do not need to care about the interference that occurs at 20Hz since it is a noise and any way it has to be eliminated. But we need to do something about the aliasing component generated by the f2=20Hz. Since this is a noise component, the aliasing component generated by this noise will interfere with our original f1=10Hz component and will corrupt it. Aliasing depends on the sampling frequency and its relationship with the frequency components. If we sample a signal at Fs, all the frequency components from Fs/2 to Fs will be alias of frequency components from 0 to Fs/2 and vice versa. This frequency – Fs/2 is called “Folding frequency” since the frequency components from Fs/2 to Fs folds back itself and interferes with the components from 0Hz to Fs/2 Hz and vice versa. Actually the aliasing zones occur on the either sides of 0.5Fs, 1.5Fs, 2.5Fs,3.5Fs etc… All these frequencies are also called “Folding Frequencies” that causes frequency reversal. Similarly aliasing also occurs on either side of Fs,2Fs,3Fs,4Fs… without frequency reversals. The following figure illustrates the concept of aliasing zones.

In the above figure, zone 2 is just a mirror image of zone 1 with frequency reversal. Similarly zone 2 will create aliases in zone 3 (without frequency reversal), zone 3 creates mirror image in zone 4 with frequency reversal and so on… In the example above, the folding frequency was at Fs/2=15Hz, so all the components from 15Hz to 30Hz will be the alias of the components from 0Hz to 15Hz. Once the aliasing components enter our band of interest, it is impossible to distinguish between original components and aliased components and as a result, the original content of the signal will be lost. In order to prevent aliasing, it is necessary to remove those frequencies that are above Fs/2 before sampling the signal. This is achieved by using an “anti-aliasing” filter that precedes the analog to digital converter. An anti-aliasing filter is designed to restrict all the frequencies above the folding frequency Fs/2 and therefore avoids aliasing that may occur at the output of the multiplier otherwise.

Thus, a complete design of analog to digital conversion contains an anti-aliasing filter preceding the ADC and the complete design of digital to analog conversion contains a reconstruction filter succeeding the DAC.

Note: Remember that both the anti-aliasing and reconstruction filters are analog filters since they operate on analog signal. So it is imperative that the sampling rate has to be chosen carefully to relax the requirements for the anti-aliasing and reconstruction filters.

### Effects of Sampling Rate:

Consider a sinusoidal signal of frequency Fm=2MHz. Lets say that we sample the signal at Fs=8MHz (Fs>=2*Fm). The factor Fs/Fm is called “over-sampling factor”. In this case we are over-sampling the signal by a factor of Fm=8MHz/2MHz = 4. Now the folding frequency will be at Fs/2 = 4MHz. Our anti-aliasing filter has to be designed to strictly cut off all the frequencies above 4MHz to prevent aliasing. In practice, ideal brick wall response for filters is not possible. Any filter will have a transition band between pass-band and stop-band. Sharper/faster roll off transition band (or narrow transition band) filters are always desired. But such filters are always of high orders. Since both the anti-aliasing and reconstruction filters are analog filters, high order filters that provide faster roll-off transition bands are expensive (Cost increases proportionally with filter order). The system also gets bulkier with increase in filter order.Therefore, to build a relatively cheaper system, the filter requirement in-terms of width of the transition band has to be relaxed. This can be done by increasing the sampling rate or equivalently the over-sampling factor. When the sampling rate (Fs) is increased, the distance between the maximum frequency content Fm and Fs/2 will increase. This increase in the gap between the maximum frequency content of the signal and Fs/2 will ease requirements on the transition bands of the anti-aliasing analog filter. Following figure illustrates this concept. If we use a sampling frequency of Fs=8MHz (over-sampling factor = 4), the transition band is narrower and it calls for a higher order anti-aliasing filter (which will be very expensive and bulkier). If we increase the sampling frequency to Fs=32MHz (over-sampling factor = 32MHz/2MHz=16), the distance between the desired component and Fs/2 has greatly increased that it facilitates a relatively inexpensive anti-aliasing filter with a wider transition band. Thus, increasing the sampling rate of the ADC facilitates simpler lower order anti-aliasing filter as well as reconstruction filter. However, increase in the sampling rate calls for a faster sampler which makes ADC expensive. It is necessary to compromise and to strike balance between the sampling rate and the requirement of the anti-aliasing/reconstruction filter.

### Application : Up-conversion

In the above examples, the reconstruction filter was conceived as a low pass filter that is designed to pass only the baseband frequency components after reconstruction. Remember that any frequency component present in zone 1 will be reflected in all the zones (with frequency reversals in even zones and without frequency reversals in odd zones). So, if we design the reconstruction filter to be a bandpass filter selection the reflected frequencies in any of the zones expect zone 1, then we achieve up-conversion. In any communication system, the digital signal that comes out of a digital signal processor cannot be transmitted across as such. The processed signal (which is in the digital domain) has to be converted to analog signal and the analog signal has to be translated to appropriate frequency of operation that fits the medium of transmission. For example, in an RF system, a baseband signal is converted to higher frequency (up-conversion) using a multiplier and oscillator and then the high frequency signal is transmitted across the medium. If we have a band-pass reconstruction filter at the output of the DAC, we can directly achieve up-conversion (which saves us from using a multiplier and oscillator). The following figure illustrates this concept.

### Reference:

### See also:

[1] Oversampling, ADC – DAC Conversion,pulse shaping and Matched Filter [2] Bandpass Sampling

### Recommended Books:

### External Resources:

[1] Video Lectures on Signals and Systems, Filter Design and Transforms [2] A Guide on Frequency Analysis and Manipulation using MATLAB [3] A short presentation on Quantization [4] Useful Matlab Functions and Scripts for Audio Signals and Systems [5] Mathworks – Designing a Sigma-Delta ADC from Behavioral Model to Verilog and VHDL [6] Anti-aliasing and quantization of audio signals and digital images using Matlab

Pingback: Colored Noise Generation in Matlab | GaussianWaves

Pingback: Natural Binary Codes and Gray Codes | GaussianWaves

Pingback: Gibbs Phenomena – A demonstration | GaussianWaves

Pingback: how to convert analog to digital?

Pingback: Oversampling, ADC – DAC Conversion,pulse shaping and Matched Filter | GaussianWaves

Pingback: Sampling a Signal in Matlab | GaussianWaves

Pingback: How to plot FFT using Matlab – FFT of basic signals : Sine and Cosine waves | GaussianWaves

Pingback: Relation between Eb/N0 and SNR | GaussianWaves

Pingback: Calculating power and energy content of a signal in MATLAB | GaussianWaves

Pingback: Estimation of Impulse Response of a LTI System | GaussianWaves