I am going to build an midi controller and need a solution to read about 90 potentiometers and possible some switches.
I have an Arduino Mega 2560 and was thinking to use 2 mux shields with it.
So far so good, but i am more a programmer than an electrotechnician, so i have this question,
do i need to do something extra to power all this potentiometers, or can i just connect 2 mux shields to the arduino board and connect all potentiometers with the muxshields.
I probably need to power the arduino with an adapter, but is that all?
No chances i will damage anything anywere in the circuit with such an amount of parts?
As long as all the pots together draws less than 400 milliamp (4.4 milliamp each) you should be fine. The pots are connected from +5 to Ground so they have 5V across them. Volts / Amps = Ohms and 5 Volts / 0.0044 amps = 1136 Ohms. As long as your pots are well above 1136 (1.2K) ohms you should have no problem with power draw. I'd recommend 10K to 100K pots.
I have another question which i could have mentioned earlier, but i did't.
If i understand correctly, when i connect 2 mux shields to one arduino then they will share the same digital inputs and use different analog inputs? I cannot find any matching and complete documentation to this situation, but this is what i have read in serveral topics.
I also read that reading signals from the 2 mux shields could not happen at the same time because of the shared digital inputs.
Am i still correct?
Can someone tell me how it works when using 2 mux shield on one arduino of point me at some documentation to this, because it doesn't get clear to me.
If i understand correctly, when i connect 2 mux shields to one arduino then they will share the same digital inputs and use different analog inputs? I cannot find any matching and complete documentation to this situation, but this is what i have read in serveral topics.
• Requires digital pins 2,3,4,5 and analog pins 0,1,2 – 48 inputs/outputs for the price of 7 pins
What's not clear about that statement? Poor choice of digital pins (stealing both external interrupt pins), in my opinion.
I don't see that you are going to accomplish anything by stacking two of them.
Well, i am not going to stack 2 of them physically, i was wundering if i could use other digital pins by wiring them manually, but i cannot find documentation saying that is possible allthough it looks logical to me that it can,
i could easely define other digital pins as input in the code for the different mux shield unless the shields are hardcoded internally to make uses of predefined input pins.
If it is like you say i have to make my own mux board with 6 multiplexers on it, but i hope that would not be nesscesary.
To use multiple Mux Shields, you can use the same Control lines to all three shields, but will need to use separate input lines for them (so 4 control lines, 9 input lines total). Since you are using two for digital input, you can run the outputs of these Mux Shields to digital in's on your microcontroller, while the analog Mux Shield will need to run to analog in's. The example code will need to have the input arrays and for loops (where the inputs are gathered) tripled. No major changes - just copy-paste, and rename!
This is all 'documentation' i have, does someone have more complete info on this? It would be great!
It is straightforward to use 2 Mux Shields with a Mega2560 - I've seen implementations that use 5 Mux Shields on a Mega monitoring pressure sensors! The nice thing about is you will not need to use additional pins for the Control lines. Just like the Mux Shield controls three multiplexers via the same 4 Control lines, when you add more Mux Shields, these too can use the common Control lines.
The analog input pins are the limiting factor. Since each multiplexer needs one analog pin (assuming you are doing analog input), you'll need 3 analog inputs per Mux Shield.
Here are the details of how one way you might hook two Mux Shields and one Arduino up:
Run jumpers from the Arduino digital pins 2,3,4,5 to both Mux Shield pins digital pins 2,3,4,5 - that is S0 - S3
Run jumpers from Mux Shield #1 analog inputs 0,1,2 (M0 - M2) to Arduino analog inputs 0,1,2
Run jumpers from Mux Shield #2 analog inputs 0,1,2 to Arduino analog inputs 3,4,5
Hook up power and ground pins among both Mux Shields and the Arduino
And here are the necessary code revisions
Create three additional arrays to store the input values:
int mux3array[16];
int mux4array[16];
int mux5array[16];
Create three additional loops to read in the sensor data (repeat the following code twice more for analogRead(4) and (5):
//This for loop is used to scroll through the FOURTH multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux2array[i] = analogRead(3); //notice we are reading Analog 3 pin
}
At this point, you'll have 96 analog inputs! If you are worried about current consumption, use a wall wart or some other power source to get 5V from.
Do any of you know how do this same thing with the new Mayhew Labs MuxShield II? I am also trying to use two MuxShields with one single Arduino. Any help would be appreciated. Thanks!