2 Interfacing A Microprocessor To The Analog World
2 Interfacing A Microprocessor To The Analog World
? ?
A/D CPU D/A
Two questions:
physical analog
voltage digital
quantity
sensor A/D
* tachometer
* potentiometer
- sensors that directly generate a digital value
physical
digital
quantity
sensor
* digital camera
* position encoders
• Issue:
- an analog voltage can take a continuum of values
- a binary number can take only finitely many values
• Resolution [2, 3]
- Idea: two analog numbers whose values differ by < 1/2n
may yield the same digital representation
- an n-bit A/D converter has a resolution equal to 2−n times
the input voltage range, v ∈ [0, Vmax]
- least significant bit (LSB) represents Vmax/2n
11
10
01
00
0 Vmax Vmax 3Vmax Vmax
4 2 4
input voltage
11
10
01
00
0 Vmax Vmax 3Vmax Vmax
4 2 4
input voltage
• Design issues
- precision
- accuracy
- speed
- cost
- relative amount of analog and digital circuitry
MSB
D/A
converter
LSB
start at MSB
set bit = 1
no all bits
checked?
yes
conversion done
end
• Issues
- timing (bits set one at a time)
- signal to noise ratio (lower bits based on small signals)
- cannot correct for wrong decisions on a given bit
• sampler [3]
switch
analog -
input output
+
time
0.5
−0.5
−1
−1.5
−2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time, sec
1.5
0.5
−0.5
−1
−1.5
−2
0 1 2 3 4 5 6 7 8 9 10
time, sec
1.5
0.5
−0.5
−1
−1.5
−2
0 1 2 3 4 5 6 7 8 9 10
time, sec
1.5
0.5
−0.5
−1
−1.5
−2
0 1 2 3 4 5 6 7 8 9 10
time, sec
1.5
0.5
−0.5
−1
−1.5
−2
0 1 2 3 4 5 6 7 8 9 10
time, sec
• Other issues[6]
- irregular sampling interval
- synchronizing sampling with the signal
0.8
0.6
0.4
0.2
−0.2
−0.4
cos(t)
cos((1+ 1π) t)
−0.6 cos(2k)
cos((1+ 1π)2k)
−0.8
−1
0 1 2 3 4 5 6
time, seconds
R rev/sec
actual
3T
2T
T perceived
actual
2T
perceived
3T
actual
T, 3T,...
2T, 4T,...
θ
x
x(t) = cos(2πRt)
y(t) = sin(2πRt)
T
θ 0
• More terminology
- Fourier coefficients: ai, bi
- DC term: a0
- fundamental: n = 1, sinusoids of frequency ω0
- harmonics: n > 1, sinusoids of frequency > ω0
4
- Fundamental: n = 1, π sin(ω0t)
4
- 1st harmonic: n = 3, 3π sin(3ω0t)
4
- 2nd harmonic: n = 5, 5π sin(5ω0t)
0.5
−0.5
−1
−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time, seconds
1.5 square
fundamental
fund+...+5th
0.5
−0.5
−1
−1.5
0 0.5 1 1.5 2 2.5 3 3.5 4
time, seconds
4/π
4/3π
4/5π
R∞
• Recall: delta function: δ(ω) = 0, ω 6= 0; −∞ δ(ω)dω = 1
• The Fourier transform of a sinusoid of frequency f Hz consists
of two delta functions located at frequencies ±f Hz.
• The frequency response of a square wave consists of delta
functions corresponding to all frequency components of the
Fourier series expansion of the square wave.
• Example5: Square wave of period T = 2 seconds, f = 0.5
Hz has frequency components at ±f, ±3f, ±5f, . . .. The
Fourier transform of a square wave may be approximated using
algorithms from [7]
4.5
3.5
2.5
1.5
0.5
0
−5 −4 −3 −2 −1 0 1 2 3 4 5
frequency, Hz
0
-ωΝ ωΝ ω
x(t) = cos(2πRt)
y(t) = sin(2πRt)
π 1
ω0 < ωN = rad/sec ⇒ T < sec
T 2R
π 2π
ωN = > ω0 ⇔ ωs = > 2ω0
T T
(usually, we set sampling frequency ωs > (5 − 10)ω0, twice
as fast is only the theoretical limit)
vi(t) + C vo(t)
-
1
H(jω) =
1 + jωRC
- magnitude, or gain
1
|H(jω)| = √
1 + ω 2 R2 C 2
- phase
−1
∠H(jω) = − tan (ωRC)
• After transients die out, the steady state response of the filter
to a sinusoid is determined by it frequency response function:
−10
−20
Magnitude (dB)
−30
−40
−50
−60
0
RC = 0.01
RC = 0.1
RC = 1
RC = 10
Phase (deg)
−45
−90
−3 −2 −1 0 1 2 3 4
10 10 10 10 10 10 10 10
Frequency (rad/sec)
• Lowpass filter
- passes low frequencies
- attenuates high frequencies
- introduces phase lag
• Bandwidth of RC filter proportional to 1/RC