C1217 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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: (Rs+Rsw)Csln⁡213.

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?

Name it

Settling

The sampling capacitor Cs charges through the switch resistance Rsw and the source's Thévenin resistance Rs. To settle within half a code of an N-bit converter from a full-scale step:

tacq≥(Rs+Rsw)Csln⁡2N+1

For 12 bits, ln⁡8192=9.01 time constants.

A capacitor at the pin

A capacitor Cext much bigger than Cs supplies the charge directly. When the switch closes, the two share charge, and the pin dips by ΔVCs/(Cext+Cs), where ΔV is the difference between the capacitor's old voltage and the pin's. Keeping that under half a code needs Cext≥(2N+1−1)Cs, 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 RsCext a low-pass filter: good against aliasing and noise, slow for fast signals.

Dividers

A divider scales a large voltage into range: Vpin=VR2/(R1+R2). Its Thévenin resistance R1∥R2 is the source resistance the ADC sees, and V/(R1+R2) is a current it draws all the time, which matters for battery devices.

References

The ADC reads V/Vref. 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
  1. Time constant. The source and the 1 kΩ switch add in series: τ=11kΩ×10pF=110ns
  2. Settle to 12 bits. That takes 9.01 time constants: 9.01τ=991ns about 1 µs.
  3. 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
  1. Divider ratio. 33133=0.248
  2. Pin voltage. 12V×0.248=2.98V safely under 3.3 V.
  3. Current. 12V133kΩ=90μA all the time, more than the whole sleeping board in the power lesson.
  4. One code at the battery. One code is 0.806 mV at the pin, so at the battery it's 0.806mV0.248=3.25mV
  5. 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
  1. Size the capacitor. Cext≥8191×10pF=82nF so a 100 nF part works.
  2. The filter it makes. With the 24.8 kΩ divider above, the corner is fc=12πRC=12π(24800)(10−7)Hz=64Hz
  3. 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?

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.