Exercise 7
Exercise 7
Exercise 7.
Keywords
analog-to-digital converter (A/D, ADC), digital-to-analog converter (D/A, DAC), sine fitting
References
[1] http://en.wikipedia.org/wiki/Analog-to-digital_converter
[2] http://en.wikipedia.org/wiki/Digital-to-analog_converter
[3] http://en.wikipedia.org/wiki/Sampling_(signal_processing)
[4] http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem
[5] http://www.maxim-ic.com/appnotes.cfm/appnote_number/1040/CMP/ELK1
Measurement Instruments
Oscilloscope Agilent 54622A
Power Supply Agilent E3630
Function Generator Agilent 33220A
Digital multimeter (6 digit) Agilent 33401A
Theoretical Background
In this part of the guide some of the necessary theory are presented.
1
Laboratory 2. Exercise 7.
Sampling
The theory of sampling was created by Nyquist and Shannon. The sampling theorem says
that an analog signal can be correctly sampled (and reproduced) if the analog signal does
only contain frequency components which are smaller than the half of the sampling
frequency (denoted with fs). This is due to the fact that the spectrum of the sampled signal is
periodic with the sampling frequency if the analog signal contains larger than fs/2
frequencies, these components overlap.
Correct sampling:
2
Laboratory 2. Exercise 7.
Quantization
The quantization process maps the continuous input value to discrete (digital) values. The
number of possible values can be determined from the resolution of the quantization: when n
bits are used, 2n quantization levels can be selected.
The following figure shows the theoretical linear quantization (left part) and the
amplitude error introduced by the quantization process (right part).
In computing, the least significant bit (lsb) is the bit position in a binary integer
giving the units value, that is, determining whether the number is even or odd. The lsb is
sometimes referred to as the right-most bit, due to the convention in positional notation of
writing less significant digits further to the right. It is analogous to the least significant digit
of a decimal integer, which is the digit in the ones (right-most) position. In the context of
D/A converters LSB denotes the potential change when the least significant bit of the input
is changed.
3
Laboratory 2. Exercise 7.
a percentage of full scale. A differential non-linearity greater than 1 LSB will lead to a non-
monotonic transfer function in a DAC.
The spectral output of the FFT is a series of M/2 points in the frequency domain (M is the
size of the FFT). The spacing between the points is fs/M, and the total frequency range
covered is dc to fs/2, where fs is the sampling rate. The width of each frequency "bin"
(sometimes called the resolution of the FFT) is fs/M. Figure 2 shows an FFT output for an
ideal 12-bit ADC. Note that the theoretical noise floor of the FFT is equal to the theoretical
SNR plus the FFT process gain, 10log(M/2). It is important to remember that the value for
noise used in the SNR calculation is the noise that extends over the entire Nyquist bandwidth
(dc to fs/2), but the FFT acts as a narrowband spectrum analyzer with a bandwidth of fs/M
that sweeps over the spectrum. This has the effect of pushing the noise down by an amount
equal to the process gainthe same effect as narrowing the bandwidth of an analog
spectrum analyzer.
The FFT data shown in Figure 2 represents the average of 5 individual FFTs. Note that
averaging a number of FFTs does not affect the average noise floor, it only acts to "smooth"
the random variations in the amplitudes contained in each frequency bin.
Figure 2 FFT Output for an Ideal 12-Bit ADC, Input = 2.111MHz, fs = 82MSPS,
Average of 5 FFTs, M = 8192
4
Laboratory 2. Exercise 7.
The FFT output can be used like an analog spectrum analyzer to measure the amplitude of
the various harmonics and noise components of a digitized signal. The harmonics of the
input signal can be distinguished from other distortion products by their location in the
frequency spectrum. Figure 3 shows a 7-MHz input signal sampled at 20 MSPS and the
location of the first 9 harmonics. Aliased harmonics of fa fall at frequencies equal to |Kfs
nfa|, where n is the order of the harmonic, and K = 0, 1, 2, 3,.... The second and third
harmonics are generally the only ones specified on a data sheet because they tend to be the
largest, although some data sheets may specify the value of the worst harmonic.
Harmonic distortion is normally specified in dBc (decibels below carrier), although in audio
applications it may be specified as a percentage. It is the ratio of the rms signal to the rms
value of the harmonic in question. Harmonic distortion is generally specified with an input
signal near full-scale (generally 0.5 to 1 dB below full-scale to prevent clipping), but it can
be specified at any level. For signals much lower than full-scale, other distortion products
due to the differential nonlinearity of the converternot direct harmonicsmay limit
performance.
Total harmonic distortion (THD) is the ratio of the rms value of the fundamental signal to
the mean value of the root-sum-square of its harmonics (generally, only the first 5 harmonics
are significant). THD of an ADC is also generally specified with the input signal close to
full-scale, although it can be specified at any level.
Total harmonic distortion plus noise (THD + N) is the ratio of the rms value of the
fundamental signal to the mean value of the root-sum-square of its harmonics plus all noise
components (excluding dc). The bandwidth over which the noise is measured must be
specified. In the case of an FFT, the bandwidth is dc to fs/2. (If the bandwidth of the
measurement is dc to fs/2 (the Nyquist bandwidth), THD + N is equal to SINADsee
below). Be warned, however, that in audio applications the measurement bandwidth may not
necessarily be the Nyquist bandwidth.
5
Laboratory 2. Exercise 7.
Spurious free dynamic range (SFDR) is the ratio of the rms value of the signal to the rms
value of the worst spurious signal regardless of where it falls in the frequency spectrum. The
worst spur may or may not be a harmonic of the original signal. SFDR is an important
specification in communications systems because it represents the smallest value of signal
that can be distinguished from a large interfering signal (blocker). SFDR can be specified
with respect to full-scale (dBFS) or with respect to the actual signal amplitude (dBc). The
definition of SFDR is shown graphically in Figure 4.
SINAD and SNR deserve careful attention, because there is still some variation between
ADC manufacturers as to their precise meaning. Signal-to-Noise-and-Distortion (SINAD, or
S/(N + D) is the ratio of the rms signal amplitude to the mean value of the root-sum-square
(rss) of all other spectral components, including harmonics, but excluding dc. SINAD is a
good indication of the overall dynamic performance of an ADC because it includes all
components which make up noise and distortion. SINAD is often plotted for various input
amplitudes and frequencies. For a given input frequency and amplitude, SINAD is equal to
THD + N, provided the bandwidth for the noise measurement is the same for both (the
Nyquist bandwidth). A typical plot for an 12-bit, 65-MSPS ADC is shown in Figure 6.
6
Laboratory 2. Exercise 7.
Figure 1 An 12-bit, 65-MSPS ADC SINAD and ENOB for Various Input Full-Scale
Spans (Range)
The SINAD plot shows that the ac performance of the ADC degrades due to high-frequency
distortion and is usually plotted for frequencies well above the Nyquist frequency so that
performance in undersampling applications can be evaluated. SINAD plots such as these are
very useful in evaluating the dynamic performance of ADCs. SINAD is often converted to
effective-number-of-bits (ENOB) using the relationship for the theoretical SNR of an ideal
N-bit ADC: SNR = 6.02N + 1.76 dB. The equation is solved for N, and the value of SINAD
is substituted for SNR:
Note that Equation 1 assumes a full-scale input signal. If the signal level is reduced, the
value of SINAD decreases, and the ENOB decreases. It is necessary to add a correction
factor for calculating ENOB at reduced signal amplitudes as shown in Equation 2:
The correction factor essentially "normalizes" the ENOB value to full-scale regardless of the
actual signal amplitude.
A few ADC data sheets somewhat loosely refer to SINAD as SNR, so you must be careful
when interpreting these specifications and understand exactly what the manufacturer means.
7
Laboratory 2. Exercise 7.
There is a mathematical relationship between SINAD, SNR, and THD (assuming all are
measured with the same input signal amplitude and frequency. In the following equations,
SNR, THD, and SINAD are expressed in dB, and are derived from the actual numerical
ratios S/N, S/D, and S/(N+D) as shown below:
Eq. 3, Eq. 4, and Eq. 5 can be solved for the numerical ratios N/S, D/S, and (N+D)/S as
follows:
Because the denominators of Eq. 6, Eq. 7, and Eq. 8 are all equal to S, the root sum square of
N/S and D/S is equal to (N+D)/S as follows:
and hence,
Similarly, if we know SINAD and THD, we can solve for SNR as follows:
Similarly, if we know SINAD and SNR, we can solve for THD as follows:
8
Laboratory 2. Exercise 7.
It is important to emphasize again that these relationships hold true only if the input
frequency and amplitude are equal for all three measurements.
Development Board
9
Laboratory 2. Exercise 7.
The schematic diagram of the resistor based D/A converter is shown on Figure 3. The IC is
configured in a way that the D/A converter output connects to the D/A pins through an
integrated output buffer. The pins are wired to BNC connectors denoted with DAC0 and
DAC1. DAC0 is connected directly to the D/A IC, while DAC1 is connected through an
amplifier with amplification ratio of 1. As the amplifier offers protection and higher
loadability, use this output during the measurements.
The signal range of the D/A is programmable the microcontroller sets the reference voltage
to 2.5V.
Application Software
During the exercie the dac_gui.m function is used. The function works in Matlab.
10
Laboratory 2. Exercise 7.
s_init() It opens the serial port and create an object com1. Before using the function
adc_measure you have to create this serial port object.
s_close() It closes the serial port object and frees its allocated resources.
y = adc_measure(channelID, Nsamples, com1) Running this function we can gather
samples by using the ADC converter. channeled determines the used channel (here, the
second channel DAC2 is used, so channelID=2 ). Nsamples is the number of the
samples (maximum 8192). com1 is the corresponding serial object (see the function
s_init). Returning this function the variable y contains the corresponding samples.
calc_sinefit() A 4 parameter sine fitting algorithm. For detailed instructions see its help
by typing help calc_sinefit in Matlabs workspace.
calc_fft() This function calculates the spectra of a coherently sample sine wave. The
function plots the spectrum, moreover calculates the SINAD, SNR s THD. For detailed
instructions see its help by typing help calc_fft in Matlabs workspace.
cleanup() This function closes all opened serial ports and closes all the running gui
applications.
Laboratory Exercises
11
Laboratory 2. Exercise 7.
digital input is set to 2n, where n is the resolution of the D/A. Obviously, the
maximum digital value which can be set on the input is 2n-1 (binary 111111),
therefore the maximal output voltage is FS-1LSB, where LSB denotes the potential
change when the least significant bit of the input is changed. The reference voltage
on the development board is set to 2.5V. Thus the nominal output range is 02.5V
(FS=2.5V). The 12-bit digital input has a range of 04095; the nominal output for
input value 0 is 0V, while input value 4095 nominally results in a FS-
1LSB=2.4994V. The amplification error is the difference of the measured values
and the nominal values at input values of 0 and 4095, represented in percentage or
LSB units.
1.2. Measure the integral linearity error.
For the absolute correct measurement of the linearity error, all possible input values
should be measured. In the case of the 12-bit D/A this would result in 4096
measurements. Due to the time constraints, only 10-20 different measurements are
done observations show that such amount of measurements are enough to get a
relatively exact characteristic.
Measure the output with minimal and maximal input values (0 and 4095). Then
select at least 10 input values evenly distributed in the input value range and
measure the output for all of these values. In every measured point, compute the
difference between the measured values and the theoretical linear characteristic.
The integral linearity error is the maximum value given in LSB units.
1.3. Measure the differential linearity error.
The gradient of the characteristic can be represented with the output voltage change
when the digital input is incremented with 1. In an ideal case, the voltage change is
exactly 1LSB. The differential linearity error is the difference of the measured
values from this theoretical value, given in LSB units.
Measure the output voltage at several points of the characteristic using consecutive
input values (e.g. 1030 and 1031). Determine the differential linearity error in LSB
units.
12
Laboratory 2. Exercise 7.
13