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

Ctrl2_4051_Kso.axo (11.4 KB)

Hello,

I modified this object, which works reasonably well on the patcher V1.0.12 (Core V0.6).

I couldn’t edit the code within the XML frame, so I copied and renamed the .axo file, then opened it in Notepad.

The first issue is that the new object shares the same UUID as the original, and I don’t know how to assign a unique one to it.

The other issue is that the potentiometers affect two outputs depending on the positioning of the three digital outputs.

You have to experiment with different placements to get a distinct value for each potentiometer.

If you create / save a new object via the patcher, it will just assign a random number as UUID. Whenever I manually copy/paste an existing object, I just change the UUID randomly, for example just the last digit:

   <obj.normal id="Ctrl2_4051_Kso" uuid="240515bb-3f53-430e-a78e-d484a88f81e8">

----->

   <obj.normal id="Ctrl2_4051_Kso" uuid="240515bb-3f53-430e-a78e-d484a88f81e9">

First, check ksoloti/gpio/in/analog.axo:

      <attribs>
         <combo name="pin">
            <MenuEntries>
               <string>PA0</string>
               <string>PA1</string>
               <string>PA2</string>
               <string>PA3</string>
               <string>PA4</string>
               <string>PA5</string>
               <string>PA6</string>
               <string>PA7</string>
               <string>PB0</string>
               <string>PB1</string>
               <string>PC1</string>
               <string>PC4</string>
               <string>PC5</string>
               <string>PF6</string>
               <string>PF7</string>
               <string>PF8</string>
               <string>PF9</string>
            </MenuEntries>
            <CEntries>
               <string>0</string>
               <string>1</string>
               <string>2</string>
               <string>3</string>
               <string>4</string>
               <string>5</string>
               <string>6</string>
               <string>7</string>
               <string>8</string>
               <string>9</string>
               <string>10</string>
               <string>11</string>
               <string>12</string>
               <string>14</string>
               <string>15</string>
               <string>16</string>
               <string>17</string>
            </CEntries>
         </combo>
      </attribs>

The CEntries go from 0 to 17, and 13 is ommitted. This is simply a hardware limitation. (I believe channel 13 is hard wired to the 5V voltage monitor or something.)

Not sure if this will fix the ‘double’ assignment issue, maybe it will if you have selected PF* pins as analog inputs.

What do you mean by placements?

Ctrl2_4051_Kso.axh (5.0 KB)

Ctrl2_4051_Kso.axo (11.4 KB)

Hello,

i changed the UUID number and there is no more error in the main window when i open Ksoloti patcher.

I modified the in order not to have the 13.

And the issue was my fault, i misread the A15 pin and i plugged to the G10, it couldn’t work properly :sweat_smile:

By placements i meant different pins.

Thank you again, my KsoDFAM/edge is on its way!

1 Like