O'Reilly logo

Microcontroller Programming and Interfacing Texas Instruments MSP430 by Daniel J. Pack, Steven F. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

248 8. ANALOG PERIPHERALS
We can now combine both sampling and quantization processes together to identify a quan-
tized level of a sampled value. Suppose a sampled analog signal value is 3.4V and the input signal
range is 0V to 5V. Using a converter with 8 bits, we can find the quantized level of the sampled value
using the following equation.
Quantized level =
s a mp l e d i np ut v a l ue lowest possible input value
δ
Thus, given the input sample value of 3.4V, the quantized level becomes
3.4V 0 V
19.53 mV
=
174.09.
Since we can only have integer levels, the quantized level becomes 174. So the sampling error is the
difference between the true analog value and the sampled value. It is the amount of approximation
the converter had to make. See Fig. 8.4 for a pictorial view of this concept. For the example, the
input sampled value 3.4 V is represented as the quantized level 174 and the quantized error is
0.09 × δ = 1.76 mV . Note that the maximum quantization error is the resolution of the converter.
Example: Given a sampled signal value of 7.21 V, using a 10 bit ADC converter with input
range of 0V and 10V, find the corresponding quantization level and the associated quantization error.
Answer: First, we find the quantized level.
Quantized level =
7.21 0
δ
where δ =
10
2
10
= 9.77 mV . Thus, the quantized level is 738.3059. Since we always round
down, the quantized level is 738 and the associated quantization error is 0.3059 × 9.77 mV
=
2.987 mV .
8.3.3 ENCODING
The last step of the ADC conversion process is the encoding. The encoding process converts the
quantized level of a sampled analog signal value into a binary number representation. Consider the
following simple case, first. Suppose we have a converter with four bits. The available quantization
levels for this converter are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, and 15. Using four bits, we can
represent the quantization levels as 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001,
1010, 1011, 1100, 1101, 1110, and 1111. Once we identify a quantization level, we can uniquely
represent the quantization level as a binary number. This process is called encoding. Similar to a
decimal number, the position of each bit in a binary number represents a different value. For example,
binary number 1100 is decimal number (1 × 2
3
) + (1 × 2
2
) + (0 × 2
1
) + (0 × 2
0
) = 12.
Knowing the weight of each bit, it is a straight forward process to represent a decimal number as a
binary number.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required