A converter can print one reading per second and still give its input only a few microseconds to settle. Use an external MCP3008 with a Pico to separate those two times. Alternate a grounded channel with a potentiometer channel, increase the source resistance, and compare the first and repeated conversions at two serial clock rates.
This exact-part design and its delivered software have host checks, but no physical build or target execution is claimed. The resistance-capacitance plot is a deliberately simplified calculation using typical internal values. Its curve is not a measured converter response or a guaranteed accuracy bound.
The small capacitor must learn the input voltage
An analog-to-digital converter (ADC) turns an input voltage into a number. The Microchip MCP3008-I/P is a 10-bit, eight-channel converter: a result has 1024 possible codes, from 0 through 1023. Its successive approximation register (SAR) architecture tries a sequence of internal comparisons after acquiring the input. During acquisition, a small sample-and-hold capacitor stores a voltage; during conversion, the chip uses that stored charge.
Source impedance describes how strongly the preceding circuit can supply changing current. A high series resistance limits how quickly the internal sampling capacitor can charge after a channel change. Waiting longer before selecting the chip does not automatically keep that sampling switch connected. The acquisition interval occurs inside the conversion sequence and is approximately 1.5 serial-clock cycles. Reducing the clock rate changes that interval; reducing how often the application prints is a different action.
This experiment does not replace the Pico’s built-in converter to gain an unspecified number of accurate digits. It makes an external converter’s reference, channel history and serial timing explicit. The extra channels share one converter and are acquired sequentially, so this is not simultaneous sampling.
Exact hardware and a restricted voltage domain
The Serial Peripheral Interface (SPI) exchanges bits with a shared serial clock. Use a Microchip MCP3008-I/P in the 16-pin plastic dual in-line package (PDIP), an original Raspberry Pi Pico with the RP2040 controller, MicroPython 1.26.0, a 10 kΩ linear potentiometer, one 1 kΩ and one 100 kΩ resistor, two 100 nF ceramic capacitors and short breadboard wiring. A potentiometer has two fixed ends and a movable wiper; its wiper provides the adjustable signal. V means volt, the unit of voltage; one millivolt (mV) is one thousandth of a volt. The ampere (A) measures current; one microampere (µA) is one millionth of an ampere. One millisecond (ms) is one thousandth of a second. Ω means ohm, kΩ means one thousand ohms, nF means nanofarad, and µs means microsecond. The farad (F) measures capacitance; one picofarad (pF) is one trillionth of a farad. Hertz (Hz) means cycles per second; kHz and MHz mean one thousand and one million hertz respectively.
Power both the converter supply and reference from the Pico’s 3.3 V output. This common rail also feeds the potentiometer top; its bottom joins ground. Use only this internally generated low-voltage signal. The MCP3008 operates from 2.7–5.5 V, but a converter powered at 5 V would not be a direct 3.3 V Pico interface. Normal single-ended input range is ground through the reference. Absolute input limits are stress boundaries, not permission to measure outside the reference or drive an unpowered chip.
| Pico signal / physical pin | MCP3008 pin | Purpose |
|---|---|---|
| 3V3 / 36 | 16 VDD and 15 VREF | Supply and conversion reference; each gets 100 nF to ground nearby |
| Ground / 23 | 9 DGND and 14 AGND | Digital and analog grounds join the same short ground network |
| GP18 / 24 | 13 CLK | Serial clock |
| GP19 / 25 | 11 DIN | Data from controller into converter |
| GP16 / 21 | 12 DOUT | Data from converter into controller |
| GP17 / 22 | 10 CS/SHDN | Chip select, active LOW; HIGH deselects |
| Pot wiper through selected series resistor | 1 CH0 | Experimental input |
| Ground | 2 CH1 and 3–8 CH2–CH7 | Grounded history channel and defined unused channels |
General-purpose input/output (GPIO) numbers, such as GP18, are different from header position numbers, such as physical pin 24. The program uses GPIO names. Verify the notch, pin-one mark and manufacturer’s top-view drawing before inserting the PDIP.
Build a common-ground source-resistance fixture

tricky-circuit-batch-007/images/mcp3008-acquisition.svg) · Open full-size diagram.Disconnect power while changing the series resistor. Begin with 1 kΩ between the potentiometer wiper and CH0. Keep the wiper near mid-travel and measure its voltage relative to ground. The 10 kΩ potentiometer has a Thevenin source resistance of at most about 2.5 kΩ at its midpoint: the two 5 kΩ halves appear in parallel when the supply is treated as a low-impedance source. The added 1 kΩ therefore gives about 3.5 kΩ external resistance at that setting. Replacing the 1 kΩ with 100 kΩ deliberately produces about 102.5 kΩ.
The 100 nF parts bypass the supply and reference, not CH0. Do not add a large input capacitor during this comparison: a local charge reservoir changes the acquisition problem and also changes the response to wiper movement. A well-designed input filter can be useful later, but it is a different circuit that needs its own settling analysis. Keep the supply reference loop and analog ground short, away from clock wiring.
Keep reference error separate from settling error
The least significant bit (LSB) is one code step. Ideally its voltage size is VREF/1024, about 3.223 mV for an actual 3.300 V reference. The program’s voltage helper returns code × VREF/1024, an ideal lower-edge estimate. Code 1023 therefore does not return exactly VREF. Quantization bins, offset, gain and linearity errors make this conversion different from a calibrated voltmeter. Enter a measured reference when estimating volts.
Because the potentiometer and reference use the same rail, its ideal fraction-of-rail code is ratiometric: if both rise together, the code stays nearly the same while the real voltage changes. Multiplying by an assumed constant 3.3 V would miss that supply change. This is why “stable raw codes” and “accurate volts” are different outcomes.
For a simplified full-scale step, residual error in LSB is 1024 × exp(−tACQ/τ), with τ = (RSOURCE + RSWITCH) × CSAMPLE and tACQ = 1.5/fCLOCK. Here τ (tau) is the time constant of this simplified resistance-capacitance settling model, not the converter’s complete conversion time. Using the datasheet’s typical 1 kΩ switch and 20 pF capacitor illustrates the time scale. For a midpoint pot plus 100 kΩ, τ ≈ 2.07 µs; a 1 MHz clock supplies only 1.5 µs, whereas 100 kHz supplies 15 µs. A half-scale transition starts with half the full-scale residual. The delivered helper calculates this model rather than assuming every previous sample began at zero.

tricky-circuit-batch-007/images/mcp3008-acquisition-acquisition.svg) · Open full-size plot.Do not choose a production source resistance from that ideal capacitor equation alone. The current electrical table permits input leakage up to ±1 µA under its conditions: 100 kΩ times 1 µA is 0.1 V of possible resistive error, which a slower serial clock cannot remove. Internal values and settling also vary. The high-resistance branch is an intentionally troublesome experiment. A proper low-impedance buffer and input filter require their own design and datasheet checks.
Compare three conversions, then change one condition
- Inspect unpowered wiring; connect the Pico by Universal Serial Bus (USB), the computer interface supplying this fixture. Measure converter VDD and VREF at the package.
- Run the complete program through the MicroPython read-evaluate-print loop (REPL), its interactive command prompt, or save it as a script. Keep the wiper fixed near midpoint with the 1 kΩ series resistor.
- For each requested clock rate, the program reads CH1 ground, CH0 once, then CH0 again. Record all three raw codes, their difference, actual SPI object description and measured wiper voltage.
- Stop the script, disconnect power, replace the series resistor with 100 kΩ, and repeat without deliberately moving the wiper. Repeat at low and high pot settings to distinguish step size from reference changes.
- Compare the first and repeated samples as evidence of history sensitivity. A repeated value closer to expectation is useful information; discarding exactly one conversion is not a general accuracy guarantee.
- Restore the low-resistance branch. If the apparent error persists, investigate wiring, supply/reference quality and ground before changing the model.
The two requested serial clock rates are 100 kHz and 1 MHz, within this conservative 3.3 V fixture’s timing choice. The main loop pauses 100 ms between triplets for readability. That pause does not enlarge the acquisition interval inside any one conversion. Actual hardware clock division may produce a rate below the request; print the peripheral object and measure clock if timing is central to your results. Record observations in the blank CSV sheet (ZIP; file: tricky-circuit-batch-007/code/mcp3008-acquisition-observations-blank.csv); comma-separated values (CSV) is a plain-text table format.
Full driver and experiment entry point
The Serial Peripheral Interface (SPI) exchanges bits synchronously with a clock. This program uses mode 0: clock idle LOW and sampling on rising edges. It sends a start bit, selects single-ended mode and channel, then decodes ten result bits. Chip select is released in a finally block even if the transport raises an exception. The application reports an entire failed triplet as unknown, then obtains a fresh triplet on the next iteration.
Download the complete MicroPython program (ZIP; file: tricky-circuit-batch-007/code/mcp3008-acquisition.py). Its pure functions and injected driver tests also execute under CPython, the standard desktop Python implementation.
"""MCP3008 single-ended SPI lab, original Pico, MicroPython 1.26.0.
The portable driver and RC helper can also be tested under CPython.
"""
import math
def positive(value, name):
if isinstance(value, bool) or not isinstance(value, (int, float)):
raise ValueError(name + " must be numeric")
if not math.isfinite(value) or value <= 0:
raise ValueError(name + " must be finite and positive")
return value
def code_voltage(code, vref):
if type(code) is not int or not 0 <= code <= 1023:
raise ValueError("code must be an integer from 0 to 1023")
positive(vref, "reference")
# Ideal lower-edge estimate, not a calibrated voltage or code-bin centre.
return code * vref / 1024
def residual_lsb(source_ohms, clock_hz, switch_ohms=1000, sample_pf=20):
"""Simplified full-scale RC-step residual; typical R/C, not a guarantee."""
if isinstance(source_ohms, bool) or not isinstance(source_ohms, (int, float)):
raise ValueError("source resistance must be numeric")
if not math.isfinite(source_ohms) or source_ohms < 0:
raise ValueError("source resistance must be finite and nonnegative")
positive(clock_hz, "clock")
positive(switch_ohms, "switch resistance")
positive(sample_pf, "sample capacitance")
acquisition = 1.5 / clock_hz
tau = (source_ohms + switch_ohms) * sample_pf * 1e-12
return 1024 * math.exp(-acquisition / tau)
class MCP3008:
def __init__(self, spi, cs):
self.spi, self.cs = spi, cs
self.cs.value(1)
def read(self, channel):
if type(channel) is not int or not 0 <= channel <= 7:
raise ValueError("channel must be an integer from 0 to 7")
tx = bytes((1, 0x80 | (channel << 4), 0))
rx = bytearray(3)
try:
self.cs.value(0)
self.spi.write_readinto(tx, rx)
finally:
self.cs.value(1)
if rx[1] & 4:
raise OSError("MCP3008 null bit is not LOW")
return ((rx[1] & 3) << 8) | rx[2]
def compare(self):
"""CH1 GND, then first and repeated CH0 conversion; sequential."""
ground = self.read(1)
first = self.read(0)
repeat = self.read(0)
return ground, first, repeat
def collect(adc, emit, count=20, pause=lambda: None):
"""Publish no stale result after any partial triplet/transport failure."""
if type(count) is not int or not 1 <= count <= 1000:
raise ValueError("count must be from 1 to 1000")
for index in range(count):
try:
ground, first, repeat = adc.compare()
except OSError as error:
emit({"index": index, "state": "TRANSPORT_FAULT", "ground": None,
"first": None, "repeat": None, "detail": str(error)})
else:
emit({"index": index, "state": "UNVERIFIED_READING", "ground": ground,
"first": first, "repeat": repeat, "delta": repeat - first})
pause()
def main():
from machine import SPI, Pin
from time import sleep_ms
cs = Pin(17, Pin.OUT, value=1)
spi = None
try:
for rate in (100000, 1000000):
if spi is not None:
spi.deinit()
cs.value(1)
sleep_ms(1)
spi = SPI(0, baudrate=rate, polarity=0, phase=0, bits=8,
firstbit=SPI.MSB, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
print("Requested SCLK:", rate, "actual object:", spi)
adc = MCP3008(spi, cs)
collect(adc, print, pause=lambda: sleep_ms(100))
finally:
cs.value(1)
if spi is not None:
spi.deinit()
if __name__ == "__main__":
main()
A plausible code is not proof of a connected sensor
The converter has no address to scan and this interface has no cyclic redundancy check (CRC), a redundant error-detection code. The program can catch an impossible HIGH null bit and operating-system transport exceptions, but disconnected data that reads all zeros can look like a real zero-volt input. Every successful row is therefore labelled UNVERIFIED_READING. Check a known ground channel and a known nonzero input; software cannot certify a physical connection from one plausible code.
If only the first conversion changes with resistance or serial rate, acquisition history is a candidate explanation. If both reads shift together as VREF changes, investigate scaling. If CH1 ground is high, check the ground network and command alignment. A fixed 1023 can mean a real top-of-range signal or a fault; inspect wiring. Do not hot-connect an external test source or power the converter separately while its Pico-side signals remain active.
Host checks execute the actual decoder, all eight channel commands, invalid-input rejection, null-bit and transfer-fault cleanup, triplet recovery, acquisition math and the actual main interrupt cleanup with injected peripheral stand-ins. They do not measure the RP2040 clock, prove an electrical conversion or compile firmware. A physical result needs a recorded board, firmware, reference and instrument setup.
Challenge: can a one-second sleep fix a 100 kΩ source?
Keep SPI at 1 MHz but increase the delay between triplets from 100 ms to one second. Does the acquisition window become 1.5 seconds?
Answer
No. The internal sampling interval remains about 1.5 serial-clock cycles, approximately 1.5 µs at 1 MHz. The long pause changes the application sampling schedule. Lowering the conversion clock affects acquisition, but leakage and other errors can remain; a suitably designed buffer changes the source impedance itself.
Primary sources
- Microchip DS20001295E, 2022, linked from the current product page: exact package, analog input model, timing and serial command sections.
- Microchip MCP3008 current documentation, checked October 20, 2026; no separate applicable errata sheet surfaced in that check. Older DS21295D search results are not used as the current revision.
- MicroPython 1.26.0 SPI interface.
- Original Raspberry Pi Pico pinout.
Continue with the electronics lessons. This fixture investigates conversion behavior; it does not establish a multimeter accuracy specification.



