I need a few more analog inputs on the RPI Pico for part of my upcoming Project14 build.
The venerable CD4051 seemed like a good fit, will run on 3.3V and is available in a 16-DIP package.
I wired up a resistor ladder long the 8 inputs just to give it a test run.
With a few lines of micropython:
from machine import Pin, ADC from time import sleep MUXA0 = Pin(20,Pin.OUT) MUXA1 = Pin(21,Pin.OUT) MUXA2 = Pin(22,Pin.OUT) x = 0 tmr = machine.Timer() def MuxUpdate(tim): global x MUXA0.value( x & (1<<0)) MUXA1.value( x & (1<<1)) MUXA2.value( x & (1<<2)) x += 1 x &= 0x7 tmr.init(period=1,callback=MuxUpdate) while True: pass
Just like that a new to the world microcontroller, the RP2040 says hello to a 25 year old Analog Mux (not really that old...).
Probing the common pin on the CD4051 we can see the mux cycling along nodes of the resistor ladder:
There are few glitches on the transition because I am strobing out addresses bits one at time sequentially. After the last address bit is set the output settles in a few microseconds.
A bit set takes about 10 us to complete, not that fast, but it is python after all.
Just some random ramblings.