# Sampling Theorem for ADC/DAC Analog-to_Digital and Digital-to-Analog Converters [Wikipedia](https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem) Shannon Sampling theory refers to the Fourier Analysis of the signal processing operation called ideal sampling: 1. Input an analog signal $x(t)$, streamed over all time$t$ 2. Uniformly sample the signal at a rate $F_s$, with infinite precision (no of bits per sample) and no timing jitter 3. Reconstruct the analog signal from the (perfect samples) over all time $t$. Under what conditions is this possible? The Nyquist Criterion for sampling says that if $x(t)$ is strictly bandlimited to $B$ Hz, and $F_s=1/T > 2B$, the analog signal can be reconstructed from the samples using using the series $$ x(t) = \sum_{n} x(nT) \ \mbox{sinc}\frac{(t-nT)}{T} $$ Other reconstruction methods are often used. Shannon used this to show why all communications is inherently digital, since a bandlimited signal can be represented by its samples. Therefore, we have the association $$ x(t) \ \leftrightarrow \ x_n=x(nT)$$ The left hand signal is said to be reconstructed from the samples over all time $t$. Sampling allows DSP-Digital Signal Processing. Notes 1. The signal must be band-limited, otherwise aliasing occurs and the reconstructed signal is distorted. This is the main source of error due to undersampling. 2. The sampling must be fast enough, and the reconstruction filter should be matched to the sampling rate. 3. The quantization precision must be infinite,otherwise we suffer quantization error for having too few bits representing the signal. Practical ADC must address this along with the numerical representation - fixed point, floating point, etc 4. Normally an anti-aliasing pre-filter is used to condition the analog signal for sampling. 5. All engineering implementations have error, so the idea is to have the power of the error small enough for the application. 6. Modern systems often use sigma-delta sampling which trades off precision for sampling rate (more samples are taken at a higher rate, but at lower precision). --- Here is the the **Fourier Analysis** The key point is how to represent the sampling process. This is done using multiplication by the comb sampler $$ \boxed{y(t) = x(t) z(t) \ \ \mbox{where} \ z(t) = \mbox{comb}_T (t) }$$ and $$ \mbox{comb}_T (t) := \sum_{n} \delta (t-nT)$$ Here $x(t)$ is a generic finite energy signal, with transform $X(f)$. Recall: Knowing $X(f)$ is equivalent to knowing $x(t)$. Our goal is to observe $y(t)$, the sampled $x(t)$, and then reconstruct $x$ from the samples $y$. By the modulation theorem of Fourier, and using $$ X(f) = {\cal F} x(t) = \int e^{-2\pi j f t} x(t) dt$$ modulation gives $$ {\cal F} y(t)=Y(f) = {\cal F} \ x(t) \cdot z(t) = X(f) * Z(f) $$ where $*$ denotes convolution. We will take $x(t)$ as a generic message signal, but explore the comb sampler $z(t)$ in detail. Now $z(t) = z(t+T)$ is $T$-periodic, and so has a Fourier Series, $$ z(t) = \sum_k \frac{1}{T} \exp ( 2 \pi j kt/T) $$with Fourier coefficients $$ Z_k = \frac{1}{T} \int_0^T z(t) e^{-2\pi kt/T}dt =\frac{1}{T}$$. We show this by substituting for $z(t)$ and since only a single $\delta(t)$ contributes (we can integrate over any T-interval), the result is $Z_k = 1/T$ for all $k$ by the sifting property. Using this we can find $$ Z(f) = {\cal F} \mbox{comb}_T (t) $$ since this is $$ Z(f) = {\cal F} \sum_k \frac{1}{T} \exp ( 2 \pi j t/T) $$ But this is now easy because $$ {\cal F} \ \exp ( 2 \pi j t/T) = \delta (f-k/T) $$ Therefore, the FS-Fourier Series representation gives $$ Z(f) = \frac{1}{T}\sum_k \delta ( f - k/T) $$ Now let's return to the main issue: the spectrum of the sampled signal $y(t)$. Carrying out the convolution gives $$ {\cal F} x(t) \cdot z(t) = X(f) * Z(f) $$ $$ = \frac{1}{T}\sum_k \delta ( f - k/T)*X(f)$$ $$ = \frac{1}{T}\sum_k X( f - k/T) =: \frac{1}{T}\mbox{rep}_{T} [ X(f) ] $$ which we use to define the repetition operator. To summarize: $$ \boxed{ \phantom{123} \ \ Y(f) \ = \ \frac{1}{T}\mbox{rep}_{T} [ X(f) ] \ \ \phantom{123} } $$ Can we recover $X(f)$ from $Y(f)$? To understand this result, we need to sketch (magnitude) spectrum. We can identify the baseband component $X(f)$ and the so-called aliases $X(f \pm 1/T)$,$X(f \pm 2/T)$, etc. If the aliases overlap with the baseband component, then all components overlap with their neighbors and aliasing error results. The sampling theorem requires the situation in which the spectral aliases do not overlap and can be separated by the reconstruction filter. **The Nyquist Criterion** for the minimal sampling rate. If the minimum sampling rate is used, twice the highest frequency, $F_s =2B=1/T$, then the reconstruction filter $H(f)$ is $$ |H(f)| = \frac{1}{2B} \mbox{rect} \left ( \frac{f}{2B} \right ) $$ whose FT is the sinc-pulse, $h(t)$, $$ {\cal F} \ \mbox{sinc}(2Bt) = \frac{1}{2B} \mbox{rect}\left ( \frac{f}{2B} \right ) $$ This is best illustrated by sketching the magnitude spectrum at each point in the signal processing chain. The General signal flow is: 1. Pre-processing MyCT signal --> Bandlimited filter --> CT Signal 2. Sampling CT --> DT CT signal --> Ideal sampler --> DT samples 3. DT samples --> Interpolator --> reconstructed CT sig The use of the DT samples depends on the application - processing vs communications or storage. ![image](https://hackmd.io/_uploads/H1jZ8EYJeg.png)