Hi,
I'm building an electronic drum module. The piezo readings are being sent to a Low Pass Filter, which then sends the filtered signals to a multiplexer (CD4051) before it is sent to the MCU's ADC.
When I read the signal directly from the low pass filter output, either with an oscilloscope or through the ADC (STM32F103 Blue Pill), I get a nice filtered wave as I was expecting. But when I am reading the signals output through the MUX it looks like the MUX is holding the signal at the wave peek for several millis (the sine wave becomes like a square wave).
Here is a simple code I'm using to test the readings from the mux, and the schematics are attached.
Why is the MUX holding the peek signal? Shouldn't I be reading through the MUX output something similar to the output of the Low Pass Filter? Does the order of the components affects the results? Piezo > Low Pass Filter > MUX > MCU VS Piezo > MUX > Low Pass Filter > MCU?
byte channel_matrix[8][3] = {
{0,0,0},
{0,0,1},
{0,1,0},
{0,1,1},
{1,0,0},
{1,0,1},
{1,1,0},
{1,1,1},
};
byte s0_enable = PB9;
byte s1_enable = PB8;
byte s2_enable = PB7;
void setup() {
pinMode(A0, INPUT);
pinMode(s0_enable, OUTPUT);
pinMode(s1_enable, OUTPUT);
pinMode(s2_enable, OUTPUT);
digitalWrite(s0_enable, channel_matrix[1][0]);
digitalWrite(s1_enable, channel_matrix[1][1]);
digitalWrite(s2_enable, channel_matrix[1][2]);
}
void loop() {
byte readSensor = analogRead(A0);
Serial.println(readSensor);
delay(100);
}