RPI PICO – CD4051 For More Analog Inputs

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 operate on 3.3V and is available in a 16-DIP package.

https://www.ti.com/lit/ds/symlink/cd4051b.pdf

Today I popped over to my local electronics/hobby shop (Sayal). I ended coming home with a 4051 Analog-Mux with a 1995 date code, from a semiconductor supplier I not familiar with AVG Semiconductors.

I wired up a resistor ladder long the 8 inputs just to give it a test run.

I wrote a few lines of \(\mu Python\) to cycle through the mux inputs every 1 ms:

from machine import Pin, ADC

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.