APPLICATIONS IN SIGNAL PROCESSING
Section 9 Digitizing a Signal
This document digitizes continuous or sampled signals. Your input:
F(t), the calculated or sampled continuous-time signal
, the sampling interval
, the bandwidth limit of the signal
The output is a vector of integers representing the quantized level assigned to each digitized sample. The
document plots the original samples, the quantized output, and the quantizing noise.
References
William McC. Siebert, Circuits, Signals, and Systems, The MIT Press (Cambridge, 1986).
Background
It is often desirable to convert a continuous-time signal into a set of digital samples. The signal can now be
processed by digital circuitry, and will be easier to store and recall. This type of sampling is used in compact
disk recording technology and other analog-to-digital conversion applications.
Nyquist Sampling Theorem and Aliasing
There are two issues in digitization. The first is the sampling rate. A signal is completely characterized by
sampling it at twice its bandwidth. This is known as the Nyquist sampling theorem. The signal can be
oversampled, which may be done to generate a smoother reconstruction of the signal.
If fewer samples are used, then signal components of higher frequencies will resemble additional components
at lower frequencies. This is a phenomenon called aliasing, which can distort the information carried by a
signal.
Quantization Levels
The second criterion for effective digitization is the size of the smallest quantized step in amplitude, known as
the sampling interval. In theory, the greater the number of levels, the more accurately the amplitude of the
signal can be represented. However, limitations on storage size and calculation dictate that levels be chosen at
some reasonable size: one tenth of the amplitude or smaller. Sufficiently small intervals ensure that the error
in quantization will be independent of the trends in the signal. For a sufficiently large number of levels, the
maximum error will be restricted to approximately one interval.
Mathcad Implementation
Mathcad's histogram function hist is used to digitize a continuous signal. The signal is sampled at a given
rate, and each sample is assigned a quantized amplitude level. To use the example, define an input function F
(t) (the signal to be digitized) with a specified bandwidth, w. Define the length of time, L, for the sampled
output, and a value for N, the number of levels in the quantized amplitude.
Enter signal and sampling information.
bandwidth, shown as highest frequency component (10 kHz as an example):
4
ω ≔ 10
input signal:
⎛ω ⎞ ⎛ω ⎞
F (t) ≔ .3 ⋅ cos (ω ⋅ t) + .4 ⋅ cos ⎜―⋅ t⎟ + cos ⎜―⋅ t⎟
⎝4 ⎠ ⎝6 ⎠
The length of the sample is given by 20 times the smallest frequency component. This is entered as a multiple
of the bandwidth:
length of sample:
⎛x⎞
x≔6 L ≔ 20 ⋅ ⎜―⎟
⎝ω⎠
number of quantizing levels:
N ≔ 10
Calculate the Digitizing Parameters and the Vector of Samples
sampling frequency (4X oversampling):
⎛ω⎞
f ≔ 4 ⋅ ⎜―⎟
⎝π⎠
sampling rate:
1 −5
T≔― = 7.854 ⋅ 10
f
vector of samples:
n≔0‥f⋅L s ≔ F (n ⋅ T)
n
maximum and minimum values of the function (used to calculate the sample interval):
A ≔ max (s) = 1.7
B ≔ min (s) = −1.449
The application now constructs a vector a which stores the N possible quantized levels for amplitude. The
vector codes contains the numbers 0 through N - 1, which identify the levels.
sampling interval:
A−B
Δ ≔ ――= 0.315
N
vector of levels:
k≔0‥N a ≔B+k⋅Δ a ≔A+1
k N
vector of codes:
i≔0‥N−1 code ≔ i
i
A straightforward application of the hist function returns a vector q giving the level (number of sampling
intervals) for each sample value.
coded sample:
⟩
⎛ n⎞
q ≔ hist ⎝a , s ⎠ ⋅ code
⟨
You can use q to reconstruct the digitized approximation to the original signal. The first plot shows this
approximation o together with the original signal F. The second plot shows the quantizing noise, that is, the
difference between the original sample values and the quantized amplitude values in o.
step-function output:
Δ
o ≔ B + ―+ q ⋅ Δ
2
graphing parameters:
L
step ≔ ―― t ≔ 0 , step ‥ L
200
1.75
1.4
1.05
⎛ T⎞ 0.7
F ⎜t − ―
⎝ 2 ⎟⎠ 0.35
o
n -0.35
-0.7
0 -1.05
-1.4
-1.75
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01 0.011 0.012
t n⋅T t
Fig. 9.1 Plot of output and original signal
The quantization noise is given by:
e≔s−o
0.325
0.26
0.195
0.157
0.13
0.065
e 0
-15 0 15 30 45 60 75 90 105 120 135 150 165
n
-0.065
-0.13 −0.157
-0.195
-0.26
-0.325
Fig. 9.2 Plot of quantization noise
The space between the dotted lines is one sampling interval, D.
To quantize any set of sample data, read the data into the vector s by using one of the functions in
the File Access category, such as READCSV, READEXCEL, READFILE, READPRN, or
READTEXT. Alternately, you could use the READEXCEL button or the Excel Component
button. These are located on the Mathcad Ribbon: Input/Output tab.
Once your data is stored in the vector s, let n run from 0 to length(s) – 1. You can now delete the original
definition of s, and the associated definitions for sampling time and sample length.