Object for a 16 analog-in demultiplexer 74HC4067

Hello,

I’ve searched both forums thoroughly but can’t find the answer I’m looking for.

I’d like to use a multiplexer with 16 analog inputs—like the 74HC4067 connected to 4 digital inputs and 1 analog input of a Ksoloti.
It operates at 3.3V.

I noticed the TIAR/HW/Ctrl2_4051 object exists, but I don’t understand how to use two 4051s with only 3 digital pins.
Also, it seems to me that those GPIOs are for the Axoloti, not the Ksoloti.

I don’t know how to code, and the code for that object looks complicated.

Has anyone used a multiplexer with the Ksoloti before?
Which object did you use to do it?

Thanks in advance for your replies.

a_cap/MAX11300 maybe? That’d be a 20-channel I/O expander where you can set any of the 16 pins to digital/analog, input/output.

Though it seems premade boards for this chip are not cheap.

The 4051 is cheap, tried and tested. It is an “8-channel analog multiplexer/demultiplexer”, which is just engineer talk for “1-to-8 switch”.

Pins A,B,C (TIAR: S0,S1,S2) are inputs to the 4051 and control the current address the switch points to. Connect those to any GPIO on Ksoloti and select the pin in the dropdown. The object will handle these pins and make the two 4051’s step through their 8 (each) analog input pins.

Pin COM (TIAR: Z0, Z1) is the common pin, i.e. the pin that makes a connection to each of the 8 channel pins, one at a time. When the address pins make a connection to a certain channel, the analog voltage can be read at the com pin. Again, the object handles the switching internally, but the Z0 and Z1 pins must be connected to an analog in-capable pin on the Ksoloti. See drop down.

That being said, you’re right that the object is for Axoloti. This means that the drop-down list contains only Axoloti pins. Ksoloti has more available pins, both digital and analog - a simple rewrite of the object would make them accessible if you need them.

Two of these would work with minimal wiring effort:

Now, what is the CD4067? It really is two 4051 in one package, the difference is that it has one additional digital address pin (so you can step through 16 values, not 8), and only one common pin (where you read the current analog voltage).

Do you already have a 4067 board, or are you just planning and trying to get a suitable board that works with Ksoloti?

1 Like

Hello,

I admit I don’t quite understand how the object distinguishes between the two 4051s when they are connected to the same digital GPIOs.
But I’ll give it a try; I’ve ordered two 4051 modules.

I don’t have a 74HC4067 module, though I’ve seen some inexpensive ones.
Connecting 4 digital GPIOs and 1 analog GPIO seemed like a better fit to me.

But in the end, I’d be using the same number of pins.

And if I need to modify the code to change the GPIOs in the drop down menus, I think it’s simple enough for me to give it a go.

Thanks a lot for your feedback!

That’s a trick to save on pins - there is nothing that prevents us from setting the same address on both chips simultaneously. We then use 2 analog in pins, so each chip is read separately.

So for example the object sets the S0,S1,S2 address to 3 - both chips will point to their respective channel 3 - then each chip’s multiplexed value is read via the dedicated ADC pin. The axo object knows what’s going where and forwards the values to the blue outlets.

If you have a second analog in pin to spare, reading two 4051’s is twice as “fast”/efficient than stepping through a 16-step address and reading one ADC value each time. Or if you need 24 or 32 pots, add another 4051 module(s), hook it/them up to the same address pins, and use another 1/2 ADC pin(s) to read their 8 values (and using the respective ctrl3_4051 or ctrl4_4051 objects)

OK, I think I’m starting to get it.
Pins S0 through S3 are outputs; the object/ksoloti decides which value/potentiometer it wants to read.
Indeed, in this case, there’s no point in having a 16-input demultiplexer.
Just need to update the list of Ksoloti Core GPIOs.

Thank you

1 Like