Hey Folks,
I've made a 16X16 grid force sensor pad using fabric, conductive fabric tabs, and velostat. I'm using two multiplexers: one provides 5V to the rows, the other allows for analog reading of the columns. There's 3.3k pull down resistors on each row. In theory, it should work like an array of FSRs but I am getting a lot of noise along the rows and columns where force is being applied. Thus what should be a point reads more as crosshairs. The real issue is that will multiple points of contact it is creating phantom zones. For instance, It is meant to be used as a pressure pad for standing on with two feet. It can detect both toe areas and both heel areas, but it doesn't look like feet - the heel area appears wider due to the toe width. And worse, if you shift your weight so that the toes on one foot are off the pad it still reads something being in that area. Thoughts on how I might clean that up? Here's a video showing the false readings. Maybe a way to filter this? I'm running it into Max7 to generate the visuals.
Part of the problem might be that the power columns are not grounded when they are not being powered by the multiplexer, but I'm not sure how I could wire that in without a short circuit.
Thanks for the help!
Here's the code:
#define S0R 3
#define S1R 4
#define S2R 5
#define S3R 6
#define S0W 9
#define S1W 10
#define S2W 11
#define S3W 12
int vals[256];
void setup() {
pinMode(S0R, OUTPUT);
pinMode(S1R, OUTPUT);
pinMode(S2R, OUTPUT);
pinMode(S3R, OUTPUT);
pinMode(S0W, OUTPUT);
pinMode(S1W, OUTPUT);
pinMode(S2W, OUTPUT);
pinMode(S3W, OUTPUT);
Serial.begin(28800);
for(int i = 0; i < 256; i++) {
vals[i] = 0;
}
}
void loop() {
for(int a = 0; a < 16; a++) {
writeMux(a);
delay(5);
for(int b = 0; b < 16; b++) {
vals[a*16+b] = map(readMux(b), 0, 1023, 0, 255);
}
}
for(int z = 0; z < 256; z++) {
Serial.print(vals[z]);
Serial.print(" ");
// delay(1);
}
Serial.println();
delay(10);
}
int readMux(int channel){
int controlPin[] = {S0R, S1R, S2R, S3R};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
//loop through the 4 sig
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin[i], muxChannel[channel][i]);
}
//read the value at the SIG pin
int val = analogRead(A4);
//return the value
return val;
}
int writeMux(int channel){
int controlPin[] = {S0W, S1W, S2W, S3W};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
//loop through the 4 sig
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin[i], muxChannel[channel][i]);
}
// this just connects the channel to 5V
}