I’m having an issue with the Mayhew Labs MUX shied… the old version. Not the MUX II shield.
My project is a ping pong ball arcade and I’m using the MUX shield to read Piezo sensors on 24 different targets. The targets are split between two separate guns so I am running the positive side of 12 piezo sensors into 12 ports on the same mux chip. In other words 12 piezos are in the ports on MUX chip 1, and 12 more are on MUX chip 2.
The problem I’m seeing is that the analogRead on the chip is returning a value no matter which target gets hit. Here is a basic code fragment from my sketch:
//Give convenient names to the control pins
#define CONTROL0 5
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
void setup()
{
//Set MUX control pins to output
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
}
void loop()
{
digitalWrite(CONTROL0, (0&15)>>3);
digitalWrite(CONTROL1, (0&7)>>2);
digitalWrite(CONTROL2, (0&3)>>1);
digitalWrite(CONTROL3, (0&1));
targtevalue = analogRead(2);
}
So, even though this should read port 0 (the first port) on the 3rd mux chip, it returns a value even though the input was on target 3 (port 2).
The ground side of the piezo is tied to a common ground. I don’t think that should be a problem since it seems that the mux grounds are all tied together to the arduino ground.
At first I thought vibrations might be being transferred through the target frames… however it does the same thing if I simply squeeze the piezo.
I should also mention that I am conditioning the piezo signal using a diode inline on the positive side, and a capacitor across the positive and negative terminals. This is in addition to the usual 1m resistor across the piezo terminals. The additional components work to keep the piezo signal active and readable for about 300ms instead of the normal 20-30ms the raw signal would give.
I’ll upload a schematic and photos tonight if it will help. Any input would be appreciated!