4051 mux daisy chain?

Is it possible to daisy chain 4051 analog mux chips together? like how the digital MCP23017 can do by setting each chip's A0, A1, A2 pin for different address and then daisy chaining the SCL and SDA pins

Yes, there are two ways.

The first way, as you describe similar to the MCP23017, is to use the Enable (/E) pins to control which 4051 is selected.

The second way is to "cascade" them, where the outputs of one chip are connected to the inputs of a second.

Not really, have to do it more like SPI.
Connect the address lines in parallel, then give each a unique enable line.
If you have enough of them, it might be worthwhile using a shift register - have 3 bits for the addresses and 5 bits for enables, and use just 3 lines from the Arduino to select 1 of 40 inputs.

Don't cascade, the added analog series resistance can screw up your analog signals.

Thanks for you're help,

I just checked out Grumpy_Mike's MIDI Footstep project, is what he has done there the same as, as you say Paul using the /E pins to control which 4051 is selected and daisy chaining the S0, S1, S2 pins on each 4051?

reference: MIDI Footsteps

is that also "more like SPI"?
cheers

No, what Mike is doing is not like either of the techniques I described. Mike is using the two 4051 chips independently, except that they share the 3 address lines. But the outputs from the two chips are connected to two different analog inputs in the Arduino/ATMega. So they are not what I suspect what you would describe as "daisy chained". That said, I am not sure what you mean by "daisy chained". You describe "daisy chaining" the SDA and SCL pins of MCP23017 chips, which is not accurate. When multiple MCP23017 chips are used, the SDA and SCL pins are connected in parallel, not daisy chained.

An example of what I would call "daisy chaining" is when multiple 74hc595 are connected with the Q7' output of one chip connected to the Serial input of the next chip.

I see, yeah i mean those connected in parallel, rather. What I want to do is actually very similar to Mikes goal there, I just want to read like 16 or more sensors through using the 4051 chips. Basically just want to use the Arduino Uno to loop through each chip and take readings.

I do have a lot of 4051 chips here. i will look into how shift registers work also.

Pretty simple to do. Read the code and connect appropriately. This should be pretty close.

byte address; // will be used to control D10,9,8 for address lines
byte sel0 = 2;
byte sel1 = 3;
int analogArray[16];
byte x;
void setup(){
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
Serial.begin(9600);
}
void loop(){
for (x=0; x<8; x=x+1){
PORTB = x; // 000, 001, 010, 011, 100, 101, 110, 111
digitalWrite (sel0, LOW);
analogArray[x] = analogRead(A0);
analogArray[x] = analogRead(A0); // 2 reads to ensure voltage has time to settle thru analog mux
digitalWrite (sel0, HIGH);
digitalWrite (sel1, LOW);
analogArray[x+8] = analogRead(A0); // 0 to 7 are 1 chip, 8 to 15 are the other 
analogArray[x+8] = analogRead(A0); // 2 reads to ensure voltage has time to settle thru analog mux
digitalWrite (sel1, HIGH);
}
Serial.println ("values 0 to 7: ")
for (x=0; x<8; x=x+1){
Serial.println (analogArray[x]);
}
Serial.println ("values 8 to 15: ")
for (x=8; x<16; x=x+1){
Serial.println (analogArray[x]);
}
delay(2000); // dumb pause to keep from bombarding the PC too quick
}

@CrossRoads, in one of your comments you mentioned daisy-chaining analog multiplexers can screw up analog signal due to resistance. I think i might be experiencing that now. I have designed a circuit to produce 64x1 from 8x1 i am using 9 4051s, 8 of them are connected as slaves with common s0,s1,s2 and the outputs are connected as inputs to the last one. However, when i try to read beyond CH7(CH7 is the last channel of the first slave MUX in the daisy chain.) no analog signal is read at all. I dont quite understand what is going on, could this be due the summation of the Ron of slave MUX and the master MUX, and please is there a way around this, is there another way to implement 64x1 mux.

Thank you.

I think "daisy chaining" them ("cascading" is probably a better term) should work. However, as Crossroads said, passing the analog signal through 2 mux chips could give an inaccurate reading. But it should still give a reading, not zero. So it sounds to me like you have an error in your circuit or code, or a faulty component. Post your schematic and sketch so we can check them for you.

Sorry about that. I have attached the image

volatile uint32_t s0,s1,s2,s3,s4,s5;
int addressA =3; //s0
int addressB =4; //s1
int addressC =5; //s2
int addressD =6; //s3
int addressE =7; //s4
int addressF =8;  //s5
void setup() {
Serial.begin(9600);
pinMode(addressA,OUTPUT);
  pinMode(addressB,OUTPUT);
  pinMode(addressC,OUTPUT);
  pinMode(addressD,OUTPUT);
  pinMode(addressE,OUTPUT);
  pinMode(addressF,OUTPUT);
  pinMode(A0,INPUT);
}

void loop() {
 
  write_address(0,0,1,1,0,0);  // Read ch12


Serial.println(analogRead(A0));
delay(10);
}


   void write_address(int8_t s0,int8_t s1, int8_t s2,int8_t s3,int8_t s4, int8_t s5)
  {
     digitalWrite(addressA,s0);
     digitalWrite(addressB,s1);
     digitalWrite(addressC,s2);
     digitalWrite(addressD,s3);
     digitalWrite(addressE,s4);
     digitalWrite(addressF,s5);
  }

I can't immediately see a problem with your sketch or schematic.

How are you testing? When you say that channels over 7 give zero, are you feeding a non-zero signal into every other channel? Could it be that the MUX is selecting a channel you did not expect and you don't have an input voltage on the channel it has selected?

Try swapping some of the mux chips around, to check if you have any faulty chips.

Whatever is wrong, it can't be because the signal is passing through 2 MUX chips. If that were the problem, channels 1 to 7 would not work either.

I am feeding analog signal into one channel at a time. Not all channels are hooked up with inputs, i have not tested that yet. But perhaps it could be unexpectedly selecting a vacant channel due to a broken MUX in the chain. I will investigate that further and let you know.

I was wondering if you ever got the 64 inputs to work? I trying to do the same thing?

Are you using 8 chips, each one feeding into an analog input of a Mega or 1284P board or an surface mount 328P which has all 8 analog inputs available?
If not, post a schematic of what you do have.

This is the Schematic I found, but I am using a Uno

That should also work for Uno.

Add a 0.1uF cap from the Vcc pin of each device to Gnd.
Be aware that you are adding 50 to 260 ohm of series resistance to each signal you are looking at with the cascading arrangement.
Using regular analogRead() for the 64 signals will take 7mS just in conversion time for the 64 signals, plus some time to set up the 2 sets of 8 addresses (outer bank address 0, inner bank 0 to 7, outer bank address 1, inner bank 0 to 7, etc. thru outer bank address 7, inner bank 0 to 7).

I think I may have worded my question wrong. I was referring to the programming for run master, slave with the 4051 and being able to read the analog signal.

@canuseebg, What question is that?
You jumped into page 2 of this thread with the schematic showing a Promini and 8 4051s. A promini is programmed the same as an Uno, just packaged differently. You haven't asked a question yet.