MCP3KADC(4)

๐Ÿ“ฆ version 11.0, in nixpkgs unstable

๐Ÿ’… MCP3KADC(4) โ€” bestie's guide to the Microchip 3x0x SAR ADC

okay so this is mcp3kadc(4), from the Kernel Interfaces Manual, section 4. it's giving "tiny chip, big voltage-reporting energy" and honestly? we're obsessed. let's get into it โœจ


๐ŸŒธ NAME ๐ŸŒธ

mcp3kadc โ€” the Microchip 3x0x SAR analog to digital converter. yes bestie, it reads voltages. it's literally the vibe translator between "analog world" and "numbers your computer understands" ๐Ÿฆ‹


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

mcp3kadc* at spi? slave ? flags N

that's the whole config line. at spi? (hangs off SPI), slave ? (its slave number), and flags N โ€” and the N is doing a LOT of work, so keep reading ๐Ÿ‘€


โœจ DESCRIPTION โœจ

the mcp3kadc driver reports the current voltage on the chip's ADC channels through the envsys(4) API. and it doesn't just blindly spit numbers โ€” it calculates these values according to the currently selected reference voltage (Vref). so like, the math is mathing ๐Ÿงฎ๐Ÿ’–

Vref is changeable through the sysctl(8) node hw.mcp3kadc0.vref. slay.

here's the part you actually need, bestie โ€” the supported chips. the type of chip gets selected with the flags argument in the config file. no cap, this table is the whole personality of the driver:

  • MCP3001 โ€” Resolution: 10 bits ยท Input Channels: 1 ยท flags: 0
  • MCP3002 โ€” Resolution: 10 bits ยท Input Channels: 2 ยท flags: 1
  • MCP3004 โ€” Resolution: 10 bits ยท Input Channels: 4 ยท flags: 2
  • MCP3008 โ€” Resolution: 10 bits ยท Input Channels: 8 ยท flags: 3
  • MCP3201 โ€” Resolution: 12 bits ยท Input Channels: 1 ยท flags: 4
  • MCP3202 โ€” Resolution: 12 bits ยท Input Channels: 2 ยท flags: 5
  • MCP3204 โ€” Resolution: 12 bits ยท Input Channels: 4 ยท flags: 6
  • MCP3208 โ€” Resolution: 12 bits ยท Input Channels: 8 ยท flags: 7
  • MCP3301 โ€” Resolution: 13 bits ยท Input Channels: 1 ยท flags: 8
  • MCP3302 โ€” Resolution: 13 bits ยท Input Channels: 4 ยท flags: 9
  • MCP3304 โ€” Resolution: 13 bits ยท Input Channels: 8 ยท flags: 10

like, pick your fighter. more channels = more to love ๐Ÿ’…


๐Ÿ‘‘ SYSCTL VARIABLES ๐Ÿ‘‘

the following sysctl(3) variables are provided:

  • hw.mcp3kadc0.vref โ€” defines the reference voltage on the chip's Vref pin in millivolts (mV). it defaults to the ADC's maximum output value + 1 in millivolts (e.g., 4096 for a 12-bit ADC).

so yeah, that default is the "max value plus one" situation โ€” like 4096 when you're running a 12-bit ADC. iconic little detail, don't lose it โœจ


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

(the friend group ๐Ÿ’– go read them, iykyk)


๐ŸŒˆ HISTORY ๐ŸŒˆ

the mcp3kadc driver first appeared in NetBSD 8.0. a legend was born ๐ŸŽ€


๐Ÿ’œ AUTHORS ๐Ÿ’œ

the mcp3kadc driver was written by Frank Wille. thank you frank, we love you for this ๐Ÿซถ๐Ÿ‘‘


๐Ÿ“ reminder bestie: this page is from Debian, dated August 18, 2015 โ€” that's the source/version and date energy right there. anyway ily, go read your voltages responsibly ๐Ÿ’€โœจ
๐Ÿ“ฆ where this page comes from