Файл: The quintessential PIC microcontroller (S. Katzen, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 5351
Скачиваний: 0
14. Take the Rough with the Smooth 393
1 Quantized scale |
in |
||||||||||||||
Fraction of full scale |
signal |
||||||||||||||
Analog |
|||||||||||||||
7/8 |
111 |
||||||||||||||
Quantized signal out |
|||||||||||||||
6/7 |
110 |
||||||||||||||
5/8 |
101 |
||||||||||||||
Quantum level L |
|||||||||||||||
4/8 |
100 |
||||||||||||||
0.4285 |
011 |
011 |
|||||||||||||
3/8 |
|||||||||||||||
Quantization error |
|||||||||||||||
2/8 |
010 |
||||||||||||||
1/8 |
001 |
||||||||||||||
000 |
|||||||||||||||
0 |
1/16 |
1/8 |
3/16 |
2/8 |
5/16 |
3/8 |
7/16 |
4/8 |
9/16 5/8 11/16 6/8 |
13/16 |
7/8 15/16 |
1 |
Analog scale |
||
Error |
||
+L/2 |
f(x ) = -(L/X)x +L/2 |
|
0 |
X |
X |
-L/2 |
Fig. 14.2 The quantizing process.
of levels. This can simply be calculated by evaluating the average of the error function squared. The square root of this is then the root mean square (rms) of the noise.
F(x) = −XL x + L2
The mean square is:
1 |
X |
1 |
X |
L2 |
L2 |
L2 |
dx |
||||
0 |
F(x)2 dx = |
0 |
x2 − |
X x + |
|||||||
X |
X |
X2 |
4 |
||||||||
394 The Quintessential PIC Microcontroller
1 |
L |
2 |
L |
2 |
2 |
X |
2 |
||||||||||||
= |
x3 − |
x2 |
+ L4 x |
= 12L |
|||||||||||||||
X |
3 |
2 |
2 |
||||||||||||||||
X |
X |
0 |
|||||||||||||||||
L |
L |
||||||||||||||||||
Thus the rms noise value of √ |
= |
2√ |
, where L is the quantum level. |
||||||||||||||||
12 |
3 |
||||||||||||||||||
A fundamental measure of a system’s merit is the signal to noise ratio. Taking the signal to be a sinusoidal wave of peak to peak amplitude 2nL
n |
||||||||||||||||||
(see Fig. 14.3), we have an rms signal of |
2 2L |
, that is |
peak |
. Thus for a |
||||||||||||||
√2 |
√2 |
|||||||||||||||||
binary system with n binary bits, we have a signal to noise ratio of: |
||||||||||||||||||
n |
2n√ |
|||||||||||||||||
2√L |
||||||||||||||||||
12 |
||||||||||||||||||
2L2 |
1.22 |
2n |
||||||||||||||||
2√2 = |
||||||||||||||||||
√ |
= |
× |
||||||||||||||||
12 |
||||||||||||||||||
In decibels we have:
S/N = 20 log 1.22 × 2n = 6.02n + 1.77 dB
The dynamic range of a quantized system is given by the ratio of its full scale (2nL) to its resolution, L. This is just 2n, or in dB, 20 log 2n = 20n log 2 = 6.02n. The percentage resolution given in Table 14.1 is of course just another way of expressing the same thing.
Table 14.1: Quantization parameters. |
||||
Binary bits |
Quantum levels |
% resolution |
Resolution |
S/N ratio (dB) |
n |
(2n) |
Dynamic range |
||
4 |
16 |
16.25 |
24.1 dB |
26.9 dB |
8 |
256 |
0.391 |
48.2 dB |
49.9 dB |
10 |
1024 |
0.097 |
60.2 dB |
61.9 dB |
12 |
4096 |
0.024 |
72.2 dB |
74.0 dB |
16 |
65,536 |
0.0015 |
96.3 dB |
98.1 dB |
20 |
1,048,576 |
0.00009 |
120.4 dB |
122.2 dB |
The exponential nature of these quality parameters with respect to the number of binary-word bits is clearly seen in Table 14.1. However, the implementation complexity and thus price also follows this relationship. For example, a 20-bit conversion of 1 V full scale would have to deal with quantum levels less than 1 µV apart. Pulse-code modulated telephonic links use eight bits, but the quantum levels are unequally spaced, being closer at the lower amplitude levels. This reduces quantization hiss where conversations are held in hushed tones! Linear 8-bit conversions are suitable for most general purposes, having a resolution of better than ±14 %. Actually video looks quite acceptable at a 4-bit resolution, and music can just be heard using a single bit – i.e. positive or negative!!
14. Take the Rough with the Smooth 395
S/N ratios presented in Table 14.1 are theoretical upper limits, as errors in the electronic circuitry converting between representations and aliasing (discussed below) will add distortion to the transformation.
The analog world treats time as a continuum, whereas digital systems sample signals at discrete intervals. Shannon’s sampling theorem1 states that provided this interval does not exceed half that of the highest signal frequency, then no information is lost. The reason for this theoretical twice highest frequency sampling limit, called the Nyquist rate, can be seen by examining the spectrum of a train of amplitude modulated pulses. Ideal impulses (pulses with zero width and unit area) are characterized in the frequency domain as a series of equal-amplitude harmonics at the repetition rate, extending to infinity. Real pulses have a similar spectrum but the harmonic amplitudes fall with increasing frequency.
If we modulate this pulse train by a baseband signal A sin ωf t, then in the frequency domain this is equivalent to multiplying the harmonic spectrum (the pulse) by A sin ωf t, giving sum and di erent components thus:
A sin ωf t × B sin ωht = AB2 (sin(ωh + ωf )t + sin(ωh − ωf )t)
More complex baseband signals can be considered to be a bandlimited (fm) collection of individual sinusoids, and on the basis of this analysis each pulse harmonic will sport an upper (sum) and lower (difference) sideband. We can see from the geometry of Fig. 14.3(b) that the harmonics (multiples of the sampling rate) must be spaced at least 2×fm apart, if the sidebands are not to overlap.
A low-pass filter can be used, as shown in Fig. 14.3(d), to recover the baseband from the pulse train. Realizable filters will pass some of the harmonic bands, albeit in an attenuated form. A close examination of the frequency domain of Fig. 14.3(d) shows a vestige of the first lower sideband appearing in the pass band. However, most of the distortion in the reconstituted analog signal is due to the quantizing error resulting from the crude 3-bit digitization. Such a system will have a S/N ratio of around 20 dB.
In order to reduce the demands of the recovery filter, a sampling frequency somewhat above the Nyquist limit is normally used. This introduces a guard band between sidebands. For example the pulse code telephone network has an analog input bandlimited to 3.4 kHz, but is sampled at 8 kHz. Similarly the audio compact disk uses a sampling rate of 44.1 kHz, for an upper music frequency of 20 kHz.
A more graphic illustration of the e ects of sampling at below the Nyquist rate is shown in Fig. 14.4. Here the sampling rate is only 0.75 of the baseband frequency. When the samples are reconstituted by filtering,
1Shannon, C.E.; Communication in the Presence of Noise, Proc. IRE, vol. 37, Jan. 1949, pp. 10–21.
14. Take the Rough with the Smooth 397
(a) Sampling below the Nyquist rate
(b) Resulting filtered signal
Fig. 14.4 Illustrating aliasing.
n
Vin Vref ki × 2−i i=1
where ki is the ith binary coe cient having a Boolean value of 0 or 1 and Vin ≤ Vref where Vref is a fixed analog reference voltage. Thus Vin is
expressed as a binary fraction of Vref and the Boolean coe cients k−1 are the required binary digits.
To see how we might implement this in practice, consider the following successive approximation mechanical analogy. Suppose we have an unknown weight W (analogous to Vin), a balance scale (compare to an analog comparator) and a set of precision known weights 1, 2, 4 and 8 gm (analogous to an Vref of 16 gm). A systemic technique based on the task list might be:
1.Place the 8 g weight on the pan. IF too heavy THEN remove (k1 = 0) ELSE leave (k1 = 1).
2.Place the 4 g weight on the pan. IF too heavy THEN remove (k2 = 0) ELSE leave (k2 = 1).
3.Place the 2 g weight on the pan. IF too heavy THEN remove (k3 = 0) ELSE leave (k3 = 1).
4.Place the 1 g weight on the pan. IF too heavy THEN remove (k4 = 0) ELSE leave (k4 = 1).
will yield the nearest lower value as the sum of the weights left on the pan. For example if W were 6.2 g then we would have a weight assemblage of 4 + 2 g or 0110b for a 4-bit system.
The electronic equivalent to this successive approximation technique uses a network of precision resistors or capacitors configured to allow