Skip to content

MCP3008

Microchip MCP3008 8-channel 10-bit SAR ADC with SPI interface (single-ended and differential).

Live catalog

Prefer labwired_describe with the catalog id over guessing pins or addresses.

Status at a glance

Aspect Status
Catalog id mcp3008
Bus SPI (mode 0,0 or 1,1)
Address — (CS via cs_pin)
Datasheet Microchip MCP3004/3008 DS21295D: §5.0, Table 5-2, Equation 4-2, §6.1 Figure 6-1
Source configs/devices/mcp3008.yaml (declarative, no Rust model)
Tier smoke-proven (register-level tests: crates/core/tests/parts_batch5.rs)

Pins / attachment

Pin / net Role
SCK / DIN / DOUT SPI
CS/SHDN cs_pin
CH0..CH7 Analog inputs (stimulus ch0_mv..ch7_mv)
VREF Stimulus vref_mv

Support matrix

Behavior Status Notes
Figure 6-1 three-byte read (0x01, SGL·D2D1D0, x) ✅ Null bit + B9:B8 in byte 1, B7..B0 in byte 2
Single-ended CH0..CH7, differential pairs (Table 5-2) ✅ Negative difference reads 0
code = 1024·VIN/VREF, clamp 0..1023 ✅
LSB-first repeat after B0, then zeros ✅
Other start-bit alignments, sample/conversion timing ❌

Stimulus

Host inputs: ch0_mv … ch7_mv, vref_mv (millivolts).

How to run

  1. Place the part and an MCU in Playground, or add it to a system YAML:
    external_devices:
      - id: "mcp3008"
        type: "mcp3008"
        connection: "spi1"
        config:
          cs_pin: "PA4"
    
  2. Agent: labwired_list → labwired_describe id=mcp3008 → wire → labwired_validate → labwired_run / labwired_verify.
  3. Register-level smoke: cargo test -p labwired-core --test parts_batch5 — CH0 → 512, CH5 → 310, CH0−CH1 differential → 256, and the clamp; mcp3008_tracks_stimulus_vref_and_lsb_first_repeat covers VREF, full scale and the LSB-first repeat. The same file's negative control proves the check fails against a stand-in that answers only 0x00 or only 0xFF.

Limitations

  • The start bit must be bit 0 of the first byte (Figure 6-1); the 0x18 | ch five-bit form returns zeros.
  • Inputs are integer millivolts; the result is the ideal transfer function.

See the YAML header for the full datasheet trace and every named approximation.