C12 · Lesson 17 · The ADC's input
Sampling capacitors, source resistance, dividers and references
The code that reads an ADC is two lines; the circuit in front of it decides whether the reading is right. Inside a microcontroller's converter, a switch connects the pin to a small capacitor for a short acquisition time, then opens and converts whatever voltage the capacitor reached. If the source can't charge that capacitor in time, the reading comes out low, and no amount of code fixes it. This lesson sizes the parts around the pin: how much resistance a sensor may have, when a capacitor at the pin helps, how to scale a voltage that's too big, and where the reference fits in.
- The curve is how far the sampling capacitor is from its final voltage, in 12-bit codes, as the acquisition goes on. The dashed line is half a code, the usual target.
- Raise the source resistance: the time constant grows and the curve crosses half a code later. A 100 kΩ divider needs about 9 µs, which is most of a conversion.
- The readout is the acquisition time needed: .
Predict
A thermistor divider has a Thévenin resistance of 50 kΩ. The ADC samples onto 10 pF for 1 µs. Roughly how far off is a reading of a full-scale step?
The time constant is 51 kΩ × 10 pF = 0.51 µs, so 1 µs is only about two time constants: the capacitor gets to of the step, about 580 codes short of 4096 (only when the voltage has just changed a lot, as when switching channels). Either lengthen the acquisition, lower the source resistance, or put a capacitor at the pin.
Name it
Settling
The sampling capacitor charges through the switch resistance and the source's Thévenin resistance . To settle within half a code of an N-bit converter from a full-scale step:
For 12 bits, time constants.
A capacitor at the pin
A capacitor much bigger than supplies the charge directly. When the switch closes, the two share charge, and the pin dips by , where is the difference between the capacitor's old voltage and the pin's. Keeping that under half a code needs , about 82 nF for 10 pF at 12 bits. The source then has a whole sample period, not just the acquisition time, to recharge it, which also makes a low-pass filter: good against aliasing and noise, slow for fast signals.
Dividers
A divider scales a large voltage into range: . Its Thévenin resistance is the source resistance the ADC sees, and is a current it draws all the time, which matters for battery devices.
References
The ADC reads . A reference that's 1% high makes every reading 1% low. A ratiometric sensor (a thermistor or potentiometer powered from the same rail as the reference) cancels the reference: both scale together.
Worked example
A 10 kΩ source drives an ADC that samples onto 10 pF through 1 kΩ. What acquisition time does 12 bits need?
Show the solution
- Time constant. The source and the 1 kΩ switch add in series:
- Settle to 12 bits. That takes 9.01 time constants: about 1 µs.
- A weaker source. A 100 kΩ source would need 9.1 µs.
Answer about 1 µs (991 ns).
Worked example
A 12 V battery is measured through 100 kΩ over 33 kΩ. What does the pin see, how much current flows, and what is one code worth at the battery?
Show the solution
- Divider ratio.
- Pin voltage. safely under 3.3 V.
- Current. all the time, more than the whole sleeping board in the power lesson.
- One code at the battery. One code is 0.806 mV at the pin, so at the battery it's
- Acquisition. The Thévenin resistance is 24.8 kΩ, so the ADC needs about 2.3 µs of acquisition, or a capacitor at the pin.
Answer the pin sees 2.98 V, the divider draws 90 µA all the time, and one code is worth 3.25 mV at the battery.
Worked example
What capacitor at the pin makes the charge-sharing error under half a code, for a 10 pF sampling capacitor and 12 bits?
Show the solution
- Size the capacitor. so a 100 nF part works.
- The filter it makes. With the 24.8 kΩ divider above, the corner is
- What it's good for. That's fine for a battery voltage, and far too slow for audio.
Answer at least 82 nF, so a 100 nF part; with the 24.8 kΩ divider its corner is 64 Hz.
Check
A source of 10 kΩ drives a 12-bit ADC that samples onto 5 pF through 1 kΩ.
(a)
What is the time constant?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
What acquisition time settles a full-scale step to half a code?
Check
A 10 kΩ source (plus 1 kΩ switch) charges 10 pF for 2 µs after a full-scale step on a 12-bit ADC.
(a)
How many codes short is the reading?
(b)
What fraction of the step did it reach?
Check
A 12 V supply is measured through 100 kΩ over 33 kΩ.
(a)
What does the pin see?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
(b)
What current does the divider draw?
(c)
What source resistance does the ADC see?
Check
A 10-bit ADC samples onto 10 pF.
(a)
What pin capacitor keeps the charge-sharing error under half a code?
Write units the way you normally would: 1.5 nF, 1500 pF and 0.0015 µF are the same answer.
(b)
With exactly that capacitor, how many codes does a full-scale charge share dip the pin?
Check
A source of 10 kΩ feeds a 10 nF capacitor at the pin.
(a)
What corner frequency does it make?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
How long does a full-scale change take to settle to half a 12-bit code?
Check
The 3.3 V reference is actually 1% high, and the input is 1 V.
(a)
What code does the ADC give?
(b)
What error results if the program assumes 3.3 V?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A thermistor divider is powered from the same 3.3 V rail the ADC uses as its reference. The rail is 2% low. How much does the temperature reading change?
Check
Write acq_time(rs, rsw, cs, bits): the acquisition time in seconds that settles a full-scale step to half a code, and divider(v, r1, r2): a tuple (pin voltage, current in amperes, Thévenin resistance).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can a capacitor at the ADC pin let a high-resistance sensor be read accurately, and what does it cost?
The sampling capacitor needs a burst of charge in a short acquisition time, and a high-resistance source can't deliver it fast enough, so the reading comes out short. A much larger capacitor at the pin holds that charge ready: when the switch closes, it shares charge with the sampling capacitor and its voltage barely dips. The source then has the whole time between samples to top it back up. The cost is speed: the source resistance and the pin capacitor form a low-pass filter, so the reading follows changes only as fast as that time constant allows, and sampling too often can drain it faster than the source refills it.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.