mux and switch array: bleed between switches?

howdy. i have interfaced arduino with a 4051 and 8 pressure sensors being used as tact switches. the sensors act as resistors until pressed, and the switch opens. each sensor is connected to a ~390k pullup resistor.

my problem is this: 2 of the 4051's pins "bleed" and read each others' signals. the remaining 6 inputs function fine. however, when you press hard enough on either of the 2 troublesome sensors, both input pins are triggered. note that when i press lightly on the sensors, the correct pin is read - however, with greater pressure, both pins are read.

i have checked my circuit for a short again or an incorrect correction and again, but have found nothing.

what could be causing the problem here?

thank you for your time. nym

each sensor is connected to a ~390k pullup resistor.

That's a bit high.

Yes you do get some cross talk and it can be as bad as you say in my experience. Different manufacturers version of that chip have different on resistances and different cross talk values. What does your exact chip say.

I would try and reduce that pull up resistor to 390R, that is several orders of magnitude different from what you have.

Can you include a schematic of what you have along with more information about the sensors.

Which two pins on the 4051 are exhibiting crosstalk?

pins 13 and 14. i'll mention again that this happens (and happens reliably) only when i push down hard on these 2 sensors.

ugly schematic: all empty mux inputs are populated by the sensors as demonstrated

and for quick reference:

It sounds to me that you have a resistance of order 300K between those two pins. You may be able to detect this using a multimeter. I suggest you check the wiring to those pins very carefully, looking for contaminants, using a magnifying glass.

Are the bodies of the 390K pullup resistors connected to those pins touching each other? What material is the board made of, that the switches are mounted on?

And one possibility is that the chip is damaged. Static electricity can damage CMOS chips very easily if you don't take precautions for instance, as will applying signal voltage out of the supply range.

That is an odd diagram. The bit that says to arduino input pins I assume is supposed to say to arduino output pins.

However what is the resistor coming from the middle of the multiplexer through a resistor and then saying 5V? It has to muxed pin written above it. That series resistor looks wrong.

^ crap, sorry - that is the digital input pin that is being multiplexed. the resistor is a pullup resistor to 5v.

It sounds to me that you have a resistance of order 300K between those two pins. You may be able to detect this using a multimeter. I suggest you check the wiring to those pins very carefully, looking for contaminants, using a magnifying glass.

i actually used a narrow cutting disc in between the pins to make sure that there was no contaminant. this suddenly has me worried about about what MarkT said about static damage....heh. good thing i have tons of these.

multimeter readings show resistance values in the upper 700ks between mux inputs (the 2 pullups in series with one another) with no discernible difference between the problem pins and the rest of the mux inputs.

it's worth noting that if i change the order of the pins from which Arduino is writing high/low values to the 3 mux select pins, the problem changes. one of the switches is still problematic, but the other one changes to a different sensor. it is no longer pins 13 and 14, it is now 13 and 15. what does this tell us?

thank you sincerely for your help

nym: it's worth noting that if i change the order of the pins from which Arduino is writing high/low values to the 3 mux select pins, the problem changes. one of the switches is still problematic, but the other one changes to a different sensor. it is no longer pins 13 and 14, it is now 13 and 15. what does this tell us?

Aha, it's classic crosstalk caused by the ADC sample capacitor. Try introducing a short delay between changing the mux select pins and calling analogRead. The delay should be about 10us per 100K source resistance, so if you are still using 390K pullups then use about 40us of delay. Alternatively, a capacitor (in the region of 1nF to 10nF) connected between each of the mux input pins and ground should fix it.

thanks, dc42. it’s worth noting that i’m muxing a digital pin, not an analog one. though, maybe i should, simply so i can use the pressure sensors as pressure sensors instead of mere switches. in the meanwhile, though i’m using a digital pin, is the delay still appropriate?

i am using borrowed code to read/write to/from my mux. i am aware that this is not the most elegant/concise way to read/write the mux. sorry for my inadequacies, hopefully the awesomeness of my concepts compensate.

(ignore the difference in value printing between the two ifs)

is this a proper use of a delay in this context? .04 being 40us, as delay uses ms…tested this and had the same crosstalk issue. will try increasing the delay. tried increasing delay to 1ms, with the same result. perhaps the issue is where i’m placing the delay.

  for (int j=0;j<8;j++) {       
    if (j==0) {            
      delay(.04);
      digitalWrite(MULTIPLEX_A, LOW); // connect A05 to 4051 mu channeltiplexerl 0
      digitalWrite(MULTIPLEX_B, LOW);
      digitalWrite(MULTIPLEX_C, LOW); 
      static int lastswi0;
      int swi0 = digitalRead(9);
      if(swi0 != lastswi0){
        Serial.println(swi0);
        lastswi0 = swi0;
      }
      }
    else if (j==1) {          
      delay(.04);
      digitalWrite(MULTIPLEX_A, HIGH); // channel 1
      digitalWrite(MULTIPLEX_B, LOW);
      digitalWrite(MULTIPLEX_C, LOW);
      int swi1 = digitalRead(9);
      if(swi1 == 0){
        buttonState = 1;
        Serial.println("1 on");
      }
    }

I forgot you were multiplexing a digital pin, not an analog one. The problem might still be caused by a combination of high value pullup resistors and input capacitance. Try this:

for (int j=0;j<8;j++) {       
    if (j==0) {            
      digitalWrite(MULTIPLEX_A, LOW); // connect A05 to 4051 mu channeltiplexerl 0
      digitalWrite(MULTIPLEX_B, LOW);
      digitalWrite(MULTIPLEX_C, LOW);
      delayMicroseconds(100);              // **** ADDED LINE 
      static int lastswi0;
      int swi0 = digitalRead(9);
      if(swi0 != lastswi0){
        Serial.println(swi0);
        lastswi0 = swi0;
      }
      }
    else if (j==1) {          
      digitalWrite(MULTIPLEX_A, HIGH); // channel 1
      digitalWrite(MULTIPLEX_B, LOW);
      digitalWrite(MULTIPLEX_C, LOW);
      delayMicroseconds(100);              // **** ADDED LINE 
      int swi1 = digitalRead(9);
      if(swi1 == 0){
        buttonState = 1;
        Serial.println("1 on");
      }
    }

Alternatively, reduce the values of the pullup resistors, e.g. to 10K (if the pressure sensors can cope with that).

btw “delay(.04)” is equivalent to “delay(0)” so it does nothing useful.

thanks for staying with me on this. ok. i added the delays to no effect, so i tried a 10nf capacitor on pin 13. this solved the problem on the other mux input - but did not solve the issue for pin 13. i'm off to add another cap on the now corrected pin, to see if that will in turn correct pin 13.

btw i totally should replace these pullups with lesser value ones, but i'm out of pcb and extracting these resistors would be a real pain right now.

edit: it worked. THANK YOU, guys. i don't have room on this little scrap of a board to put caps on all the mux inputs, but one on each of the problematic pins did the trick. while i'm here, admittedly in the wrong forum, i'd like to debounce these switches without using delay (due to concern about it pausing other functions - this is a musical apparatus so timing is on the important side). any tips? millis?