SME
Embedded Systems
Microcontrollers
Use this for “A 10-bit ADC with a 3.3 V reference reads 1.2 V. What code does it give?”
Chart
10
bits:
1024
codes,
0
to
1023;
1
LSB
=
3.3
V
1024
=
3.223
mV
1.2
V
3.223
mV
=
372.4,
rounded
down:
D
=
372;
back,
D
×
LSB
=
1.199
V
Zoomed to codes 365 to 380 of 0 to 1023
This is an example. Type your own values to start a new problem.
LSB (mV)
=
Vref (V)
÷
2
D
=
⌊
Vᵢₙ (V)
÷
LSB (mV)
⌋
Vback
Voltage back
worked out (not typed)
Formulas
LSB
=
Vref
2
n
0.003223
=
3.3
2
10
D
=
⌊Vᵢₙ
×
2
n
Vref
⌋
372
=
⌊1.2
×
2
10
3.3
⌋
Vback
=
D
×
LSB
1.1988 = 372 × 0.003223
Formulas are worked in V. The step-by-step shows the conversions.
Assumptions
•
An n-bit converter splits Vref into 2ⁿ equal steps of 1 LSB = Vref ÷ 2ⁿ.
•
This converter truncates, D = ⌊Vᵢₙ ÷ LSB⌋; some converters round to the nearest code instead.
•
D runs from 0 to 2ⁿ − 1, so the input must be from 0 up to (not at) Vref.
•
The voltage back, D × LSB, sits less than 1 LSB below Vᵢₙ: the quantization error.
Step-by-step
WE KNOW
n = 10, Vref = 3.3 V, Vᵢₙ = 1.2 V
FIND
step size (LSB), code (D), voltage back (Vback)
Step 1 · Find step size (LSB)
Use LSB = Vref ÷ 2ⁿ
n
bits
make
2ⁿ
codes,
so
the
reference
is
cut
into
2ⁿ
equal
steps.
LSB
=
3.3
2
10
LSB
=
3.3
1,024
LSB = 0.003223 V
Step 2 · Find code (D)
Use D = ⌊Vᵢₙ × 2ⁿ ÷ Vref⌋
Count
the
whole
steps
of
Vref
2ⁿ
below
the
input;
the
converter
drops
the
part
of
a
step
left
over.
D
=
⌊1.2
×
2
10
3.3
⌋
D
=
372
Step 3 · Find voltage back (Vback)
Use Vback = D × LSB
The code counts steps, so the voltage it stands for is that many LSBs.
Vback = 372 × 0.0032227
Vback = 1.1988 V
Step 4 · Convert the answers
Change each answer back to the unit you chose.
LSB = 0.003223 V = 3.22266 mV (1 V = 1000 mV)
Check
Put the numbers back in. Both sides should match.
0.0032227
=
3.3
2
10
✓
372
=
⌊1.2
×
2
10
3.3
⌋
✓
1.1988 = 372 × 0.0032227 ✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
More problem types
A DAC’s output voltage
Use this for “An 8-bit DAC with a 5 V reference gets the code 200. What voltage comes out?”
An LED’s resistor on a pin
Use this for “A 3.3 V pin drives an LED with a 2 V drop at 10 mA. What resistor goes in series?”
A divider down to 3.3 V
Use this for “A 5 V signal reaches a 3.3 V pin through 2.2 kΩ over 3.3 kΩ. What voltage does the pin see?”
Setting and clearing a register bit
Use this for “An 8-bit register holds 0x41. Set bit 3, then clear bit 6. What does it hold?”