Multiplexer Cascading/Mux over Mux

Hey guys,

How would one wire and program a working arduino with one 4067 main multiplexer and many other multiplexers on that multiplexer.

Been searching for this for weeks.

Would like to see a full working setup as I already have been getting pieces of the puzzle, which I'm not interested in. Would like to get something practical as I don't know much code.

Regards,
Hein

Here's a thought. This may be an "XY problem". :astonished:

How about you explain what it is you are trying to do?

Example:

PLEASE SEE ATTACHED.

  1. I have an arduino with one analog input (A0)

  2. I want to make that one analog input (A0) 16 using a 4067 multiplexer. Sharing the data lines.

3)Then I want to add another 16 multiplexers on each pin of the first multiplexer that's connected to A0

Number 1 and number 2 I know how to do. Number 3 I don't know how to do...

All the mux's will have potentiometers connected to them.

What I want to know is how to code this using the MidiController library or Control Surface by Pieter. If you have MIDI.h library code for this that's also fine.

You need to connect the A, B, C, D pins of all 16 mux together and to 4 more Arduino pins. If you don't have enough Arduino pins, use a 74hc595/74hc164/pcf8574 to control the A, B, C, D pins of the 16 mux and the A, B, C, D pins of the 17th mux.

You should also connect a 0.1uF bypass cap to each chip. The INH pins of all 17 mux should be connected to ground.

Moving to a Mega could be wise.
Then you have 16 analogue inputs, one for each 74HC4067.
Leo..

I don't think 256 potentiometers on an Arduino Uno (or Mega for that matter) is feasible. The default ADC rate in free running mode is around 9600 Sps. This means that in a perfect world, reading all potentiometers can happen at around 37.5 Hz. You'll probably want to discard the first reading after switching mux channels to prevent cross-talk, so you're down to less than 19 Hz. Add some software to handle all readings, take into account the time you need for setting all mux address lines, and the result will barely even be usable.

Since your goal is to use the Control Surface library, you also have to take into account memory usage. Control Surface aims to be flexible and easy to use, but this comes at a cost: it uses more memory than a hand-coded solution (mostly pointers to keep track of all objects and due to virtual function calls). You're not going to be able to fit 256 CCPotentiometer objects in the 2048 byte RAM of an Arduino Uno.
I don't know the actual memory footprint by heart, but let's say a CCPotentiometer object requires 2 bytes for the analog pin number, 2 bytes for the previous analog value, 2 bytes for the MIDI address and 4 bytes for extra pointers, then you're looking at 2560 bytes just for the potentiometers.

Control Surface also automatically discards the first analogRead value when using multiplexers. It does this at each level, so if you have two levels, it'll measure the actual input four times instead of just two. I should probably fix this, but having many levels of multiplexers wasn't the main goal back when I designed that part of the library.
You can easily disable the first measurement:

The digital filters and oversampling used by Control Surface for smoothing the potentiometer values will also cause increased latency at such low sampling rates.

Personally, I don't see any value in having this many potentiometers on a MIDI controller. I'd implement between one and eight channel strips, and then use some buttons to switch between different banks. This is the approach used by commercial MIDI contollers and modern digital mixing consoles.
You don't need a physical EQ, FX, AUX or Pan knob for each channel. Add a single strip of EQ controls (just 6 knobs or so) and then use some buttons to select the channel you want to change the EQ for. If you're going to be doing this, rotary encoders are much more user friendly than potentiometers.

Pieter

Like I said, clearly an "XY problem". :astonished:

The whole thing is a very bad idea and completely out of kilter with current practice.

Probably better executed on a Raspberry Pi with a 22 inch touch screen monitor. Then you can have a rotary encoder (yes, just one) and it may be useful to use a Pro Micro if you need a "bridge" from the Pi to the USB port of another system. If a traditional opto-coupled MIDI interface will suffice, then the Pi can no doubt do that by itself. :grinning:

Thanks for your input guys.

The issue with having banks is that then I would have to use my PC keyboard to change between mixer channels. That won't work because how will it know that I'm changing the banks.

Then I would have to press a button again. That defeats the purpose. Mixing when pressing two buttons every time and then you still have to keep track of where you are.

I don't know if this will work but it's late for that guys, I've already setup all the parts. I'm seeing this through with 256 controls no matter how I get there

What if I used EEPROM?

FYI, your control surface library doesn't work with hairless. I use the midi controller library. That works. Not sure why

Another option could be mcp3208. You could use 2 of them to replace the 17th mux, or perhaps even 32 of them, using a couple of your mux chips for the chip-enable pins.

heinrich_1:
The issue with having banks is that then I would have to use my PC keyboard to change between mixer channels. That won't work because how will it know that I'm changing the banks.

Then I would have to press a button again. That defeats the purpose. Mixing when pressing two buttons every time and then you still have to keep track of where you are.

Why would you have to press a key on the keyboard? That doesn't make any sense, you just need to press a button connect to the Arduino. Have a look at how the Behringer X32 does it, for example.

heinrich_1:
What if I used EEPROM?

Use EEPROM for what?

heinrich_1:
FYI, your control surface library doesn't work with hairless. I use the midi controller library. That works. Not sure why

Control Surface does work with Hairless. Are you using the HairlessMIDI_Interface in your sketch? Did you select the right baud rate (115200) in Hairless?