You are on page 1of 16

1

Chapter 5: Digital Data Acquisition



by John Cimbala ( edited by Lou Cattafesta)

5.1 Analog to Digital Conversion (A/D conversion)
Digital data acquisition is used in digital multimeters, digital oscilloscopes, computer-
controlled data acquisition systems, and many other modern instruments.
In all these examples, the conversion of an analog signal into a digital signal is
accomplished with an electronic device called an analog-to-digital converter, which will
be abbreviated as an "A/D converter" or "A/D".
The goal of an A/D is to change an analog signal (usually a voltage) into a digital
number (usually in binary form).
A/D converters are typically 8-bit, 12-bit, 14-bit, 16-bit, or 24- bit. The number of bits N
represents how many ones and zeroes (bits) are available for the digital output of the A/D
converter. For example, an 8-bit converter has 8 bits available.
For simplicity, consider a 2-bit A/D converter (N = 2) with a range of -5 to 5 volts. The
voltage range is divided into bins as follows:

Analog voltage
(volts)
Bin number Digital output
(binary number)
Assigned voltage,
V (volts)
5 2.5 V <
0 00 -3.75
2.5 0 V <
1 01 -1.25
0 2.5 V <
2 10 1.25
2.5 5 V <
3 11 3.75

2
The assigned voltage for each bin is here defined as half-way between the limits of the bin.
The number of bins = 2
N
for an N-bit converter. For example, in the above table, for a 2-
bit converter, there are 2
2
= 4 bins.
The resolution of the A/D converter is defined as resolution = (Vmax - Vmin)/2
N
. In the
present example, the resolution is thus [5-(-5)]/2
2
= 2.5 V.
Alternately, the resolution can be expressed as half of this value on either side, i.e. +/-
1.25 V. Another name for the resolution expressed this way is quantization error (also
sometimes called quantizing error), defined as
quantization error = +/- 0.5 (Vmax - Vmin)/2
N
.
For the above example 2-bit A/D converter, the quantization error = +/- 1.25 V.
This quantization error is too large for most practical applications! Notice that one cannot
tell the difference between an input of 2.6 V and 4.9 V - both of these input voltages will
fall in bin number 3, and would be assigned the output voltage of 3.75 V. One might
express this reading as V = 3.75 V +/- 1.25 V to reflect the resolution of the A/D.


3
Obviously, the bigger N, the better the resolution. Consider, for example, a 12-bit A/D
converter (N=12). The number of bins = 2
12
= 4096, and the resolution (for a converter
with a range of -5 to 5 V) is 0.002441 V (i.e. the quantization error is +/- 0.001221 V).
Selected rows of the bin table are shown below:
Analog voltage (volts) Bin number
Digital output
(binary number)
Assigned voltage
(volts)
5 4.9976 V <
0 0000 0000 0000 -4.9988
4.9976 4.9951 V <
1 0000 0000 0001 -4.9963

0 0.00244 V <
2048 1000 0000 0000 0.00122

4.9951 V < 4.9976
4094 1111 1111 1110 4.9963
4.9976 V 5
4095 1111 1111 1111 4.9988
Comparing the two tables above, it should be obvious that the quantization error is much
less for the 12-bit A/D converter than for the 2-bit (with both converters covering the
same range of -5 to 5 V.)
Most commercially available A/D converters are 8, 10, 12, 14, 16, or 24-bit.
The dynamic range of an A/D converter is another important parameter that is a measure
of the ratio of the largest-to-smallest signals that an A/D can resolve. It is defined in dB
as 20log10
[(Vmax-Vmin) /resolution] = 20log10[2
N
] = 20Nlog10[2] = (20)(N)(0.3) = 6N. For example,
a 16-bit converter has a dynamic range of ~96 dB. Note that this is independent of the
input range of the analog data.

4
5.2 Discrete Sampling
The main difference between analog and digital data acquisition is that digital systems
sample the signal at discrete times only, not continuously.
In a digital data acquisition system, no information is recorded at times in between these
discrete sampling times.
Here is an example, where an arbitrary continuous signal is sampled discretely at
sampling frequency fs. Note that for this sampling frequency, the time period between
samples is simply the inverse of fs, i.e. 1
s
t f = .



5
5.3 Simultaneous Sampling
When multiple channels are sampled, a single A/D converter can sample each channel in
succession by switching to each channel at a specified scan rate. This is accomplished
using a multiplexer. In this case, the data sample rate is divided by the number of
channels. For example, if a scan rate of 1000 Hz is specified and 2 channels are sampled,
the sampling frequency for each channel is 500 Hz. More importantly, however, each
channel is sampled at a different time!
We must sample each channel simultaneously if we wish to perform dynamic data
analysis of the sampled signals (e.g., cross correlations). This can be accomplished by
using one A/D converter for each channel. However, this is costly and can result in
different sampling errors (e.g., offset, linearity, etc.) for each channel. A more common
inexpensive approach is to use a multi-channel analog hold circuit to "freeze" each
channel at the same instant in time and hold its value until a single high-speed A/D
converter digitizes the values from each channel's hold circuit.
Warning: If one is not careful, discrete sampling can lead to incorrect conclusions about
the original signal! Two of the potential problems are discussed in detail below:


6
5.4 Clipping
If the original signal lies outside of the range of the A/D converter, it will be clipped at
that extreme value. For example, if the A/D converter range is -5 to 5 V, any voltage
greater than 5 V will be assigned the maximum value of the assigned voltage (i.e. 4.9988
V, according to the above bin table for a 12-bit converter).
In most cases, the user does not know that the signal has been clipped, and this can lead
to incorrect results, although some data acquisition systems give a warning when the
signal gets clipped. A clipped signal is illustrated below:

Notice that all voltages above 5 V have been clipped.

7
5.5 Aliasing
If the sampling frequency fs is too low, one can actually measure an incorrect frequency!
This is called aliasing.
Aliasing is best illustrated by an example.
Suppose the original signal is a pure 10 Hz sine wave, with an amplitude of 3 volts, a DC
offset of 3 volts, and a phase shift of 90 degrees, i.e.
o The frequency of the signal is f = 10.0 Hz.
o The period of the signal is T = 1/f = 0.100 s. The amplitude of the signal is A =
3.00 volts.
o The DC offset of the signal is C = 3.00 volts.
o The phase shift of the signal is 2 = .
o The equation for a general sine wave function is:
sin( ) sin(2 ) signal C A t C A ft = + = +
where is the radian frequency (radians/s), f is the frequency (Hz) [note that
2 f = ], A is the amplitude in volts, C is the DC offset in volts, t is the time in
seconds, and is a phase shift.
For the sine wave used in these examples, the equation used to simulate the signal is:
3 3sin 2 10
2
signal t

| |
= +
|
\

Also, suppose one samples discretely at a sampling frequency fs = 15 Hz, i.e. 15 times per
second, or one sample every 1/15 = 0.06666... s.
A half second of both the signal and the discretely sampled data points is shown on the
graph below:

8

The aliasing is obvious - the perceived signal looks nothing like the original! In fact, the
apparent frequency of the inferred or perceived signal (formed by connecting the discrete
data points with straight line segments) is 5 Hz, and it is an odd-looking trapezoidal
waveform rather than a sine wave.
If the sampling frequency is greater than twice the actual frequency, there is no aliasing
frequeny.


9
For sampling frequencies less than twice the actual frequency, the aliasing frequency must
be calculated using the folding diagram. A summary of the procedure is given below:
o Calculate the folding frequency, 2
N s
f f =
o Locate
actual N
f f on the folding diagram, duplicated below:

o Note: For values of
actual N
f f greater than 4, the folding diagram can easily be
extended, following the obvious pattern.
o Read straight up from the value of
actual N
f f to obtain the value of
apparent N
f f on
the vertical axis.


10
What is the difference between aliasing and folding? Consider the following two cases:
o CASE 1: Aliasing.
Suppose we sample a continuous time signal
( )
0
( ) cos 2 x t A f t = + at a
sampling rate 2
s N
f f = . This generates the discrete-time signal
( )
0
[ ] cos 2
s
x N A f nT = + where 1
s s
T f = .
Now consider another sinusoid ( ) y t with the same amplitude and phase but
with a frequency
0 s
f kf + , where k is a positive or negative integer. Therefore,
( ) ( )
0
( ) cos 2
s
y t A f kf t = + + .
If we sample this waveform at a sampling rate
s
f , we obtain
( ) ( )

( )
0
0
1
0
[ ] cos 2
cos 2 2
cos 2 2
s s
s s s
s
y n A f kf nT
A f nT nk f T
A f nT nk



= + +
| |
= + +
|
|
\
= + +

The result is
( )
0
[ ] cos 2 [ ]
s
y n A f nT x n = + = !
As a result, [ ] y n is indistinguishable from [ ] x n , and we say that the frequencies
0 s
f kf + are aliases of
0
f .

11
o CASE 2: Folding.
This comes from the negative frequency component of the cosine wave.
Now consider another sinusoid ( ) y t with the same amplitude and opposite
phase but with a frequency
0 s
f kf + where k is a positive or negative integer.
Therefore,
( ) ( )
0
( ) cos 2
s
y t A f kf t = + .
If we sample this waveform at a sampling rate
s
f , we obtain
( ) ( )

( )
0
0
1
0
[ ] cos 2
cos 2 2
cos 2 2
s s
s s s
s
y n A f kf nT
A f nT nk f T
A f nT nk



= +
| |
= +
|
|
\
= +

The result is
( )
0
[ ] cos 2 [ ]
s
y n A f nT x n = + = since the cosine is an even
function, cos( ) cos( ) x x = .
As a result, [ ] y n is indistinguishable from [ ] x n , and we say that the
frequencies
0 s
f kf + are folded frequencies of
0
f .


12
Here is another example. For the same sine wave (10 Hz), the signal is plotted for 1
second. Data are sampled discretely at 11
s
f = Hz.

Note that the perceived signal looks like a sine wave at 1 Hz! In this case, the aliasing
frequency is, in fact, 1 Hz, i.e. 11 - 10 Hz.
One more example for the same sine wave (f = 10 Hz): Data are sampled discretely at fs =
9 Hz.

13

Note that the perceived signal also looks like a sine wave at 1 Hz! In this case, the
aliasing frequency is, in fact, 1 Hz, i.e., since
2
2
3
s
f f f < < ,
( )
9 10 1
a s
f f f Hz Hz = = =


14
5.6 Nyquist Theorem
The sampling rate theorem helps one avoid aliasing. The sampling rate theorem is stated
as follows:
To avoid aliasing, the sampling frequency must be greater than twice the highest
frequency component of the analog signal.
Some references call this the Nyquist theorem, and that the Nyquist criterion must be
met in order to avoid aliasing. The Nyquist criterion can be stated as follows:
To avoid aliasing, one must sample at a frequency at least twice the highest frequency
component of the analog signal.


15
5.7 Signal Reconstruction
If the Nyquist criterion is followed, one can theoretically reconstruct the original analog
waveform from a set of discrete samples.
This is accomplished using the cardinal series. If there are an infinite number of discrete
samples, the cardinal series will reconstruct the waveform exactly. In practice, however,
with only a finite number of samples available, the cardinal series will still do a fairly
good job of reconstructing the original signal. For N discrete samples, the cardinal series
is
( )
1
0
sin
1
( )
N
d
n
t
n
t
f t f n t
t
n
t

=
(
| |

|
(

\

=
| |


where t is time (assuming that the signal starts at t = 0), n is the sample number (the
summation is over all N discrete samples), ( ) f t is the reconstructed waveform, N is the
total number of discrete samples available, 1
s
t f = is the time period between
discrete samples, and for the n
th
discretely sampled data point,
( )
d
f n t is the discretely
sampled value.


16
Example - The function
( ) ( )
( ) sin 2 10 0.2sin 2 6
a
f t t t = + represents a superposition of
two sine waves, the primary one at 10 Hz, and the secondary one at 6 Hz. The 6 Hz wave
has an amplitude of 0.2, while the 10 Hz wave has an amplitude of 1.0. Discrete data
were acquired at 25 Hz, which exceeds the Nyquist criterion. Samples were acquired for
0.6 seconds (a total of N = 16 discrete data points). A plot of the actual (analog) signal,
( )
a
f t , the discrete samples, and the reconstructed waveform, ( ) f t appears below:

Taken alone, the discrete values (red dots) do not appear to contain enough information to
reconstruct the original signal, but as can be seen, the cardinal series reconstruction is
excellent, and deviates significantly only near the end points of the time span.
The cardinal series will not work properly if the Nyquist criterion is not satisfied.

You might also like