Low Pass Filter + Multiplexer

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);
}

You didn't explain the purpose of the MUX. It looks like you have built a S&H circuit.

Yes, it looks like a S&H although that was not my intent. :slight_smile: The purpose of the MUX is just to expand the number of analog ports of the blue pill. It has 10 analog ports and I need at least 16 of them. I need to read the peak of the sine wave and the time it takes (typically 2-4ms) to reach the peak. And I also need to discharge the piezo in no more than 75ms to avoid double triggering, but with the current circuit it might hold the peak for about an entire second. It was working fine until I've added the MUX to the circuit.

I don't understand your low pass filter. Didn't you mix up the + and - inputs of the MCP6004?

It is supposed to be a non inverting unit gain filter, connecting the - signal to the out signal. I can't see why it is mixed up.

Hi,
OPs Pics.




Thanks.. Tom... :slight_smile:

I've found the issue. I had connected the OpAmp to 5V incorrectly and the Mux to 3V3. Fixing the supply to the OpAmp did the trick.