user84542: Problem
If the loop runs only one simulated pin and uses a filter, it will output normally (analog 1600~2200, filter 0~500), but creating an array to store multiple filtered simulated pin values will cause problems, and the output will be abnormal (10000~80000).

If analog read six sensors, and their value is 1600~2200.
It used the code below.
#include "EMGFilters.h"
#define SERIAL_TX_BUFFER_SIZE 4096 //修改串口接收缓冲区大小为2048
const int SensorInputPin[] = {A0, A1, A2, A3, A4, A5};
EMGFilters myFilter[6];
SAMPLE_FREQUENCY sampleRate = SAMPLE_FREQ_500HZ;
NOTCH_FREQUENCY humFreq = NOTCH_FREQ_50HZ;

void setup()
{

    for (int i = 0; i < 6; i++)
    {
        myFilter[i].init(sampleRate, humFreq, true, true, true);
    }
    Serial.begin(115200);
    Serial1.begin(250000);
    analogReadResolution(12);
}
void loop()
{
    long time = millis();
    int x[6] = {0,0,0,0,0,0};
    int analog[6] = {0,0,0,0,0,0};

    for (int index = 0; index < 6; index++)
    {
        //x[index] = myFilter[index].update(analogRead(SensorInputPin[index]));
        analog[index] = analogRead(SensorInputPin[index]);
    }
    while ((millis() - time) < 2)
    {
        delayMicroseconds(100);
    }
    Serial.printf("filter:%d %d %d %d %d %d analog:%d %d %d %d %d %d\n", x[0], x[1], x[2], x[3], x[4], x[5],analog[0],analog[1],analog[2],analog[3],analog[4],analog[5]);
    Serial1.printf("<%d,%d,%d,%d,%d,%d>", x[0], x[1], x[2], x[3], x[4], x[5]);
}

Change index<6 to index<2, and uncomment \\x[index] = myFilter[index].update(analogRead(SensorInputPin[index]));
It will be a normal output using two inputs and filters.

But changing index=0;index<2 to index=0;index<6 will be abnormal output.

If changing to index=3;index<4 or index=2;index<3...etc, it will be normal output:

Sketch:





XIAO MCU schematic in the HTML: https://files.seeedstudio.com/wiki/Seeeduino-XIAO/res/Seeeduino-XIAO-v1.0-SCH-191112.pdf
I don't have a sensor schematic.
Filter code: https://github.com/oymotion/EMGFilters/blob/master/EMGFilters.cpp
I hope each simulation output to look like the first Gif(normal output), what should I do to achieve this?

user7508: This is a bug in the filter library you are using. It has already been
reported (by you, maybe?).
As Majenko and chrisl suggested in comments, the crux of the problem is
that you need one filter per input channel. Using multiple instances of
EMGFilters seems like the obvious solution. Alas, the library keeps
the filter state in global variables, which essentially means your six
filter objects all reference the same actual filter.

84542: <h2>Problem</h2>
<p>If the loop runs only one simulated pin and uses a filter, it will output normally (analog 1600~2200, filter 0~500), but creating an array to store multiple filtered simulated pin values will cause problems, and the output will be abnormal (10000~80000).</p>
<p><img src="https://aws1.discourse-cdn.com/arduino/original/4X/6/9/5/6950edfbf1acdc9eed2746e95fa0e06828356b4f.gif" alt="2022-04-15--15-00-07_fps=8_scale=720_max_colors=128|690x298" /></p>
<p>If analog read six sensors, and their value is 1600~2200.</p>
<p>It used the code below.</p>
<pre><code>#include &quot;EMGFilters.h&quot;
#define SERIAL_TX_BUFFER_SIZE 4096 //修改串口接收缓冲区大小为2048
const int SensorInputPin[] = {A0, A1, A2, A3, A4, A5};
EMGFilters myFilter[6];
SAMPLE_FREQUENCY sampleRate = SAMPLE_FREQ_500HZ;
NOTCH_FREQUENCY humFreq = NOTCH_FREQ_50HZ;

void setup()
{

    for (int i = 0; i &lt; 6; i++)
    {
        myFilter[i].init(sampleRate, humFreq, true, true, true);
    }
    Serial.begin(115200);
    Serial1.begin(250000);
    analogReadResolution(12);
}
void loop()
{
    long time = millis();
    int x[6] = {0,0,0,0,0,0};
    int analog[6] = {0,0,0,0,0,0};

    for (int index = 0; index &lt; 6; index++)
    {
        //x[index] = myFilter[index].update(analogRead(SensorInputPin[index]));
        analog[index] = analogRead(SensorInputPin[index]);
    }
    while ((millis() - time) &lt; 2)
    {
        delayMicroseconds(100);
    }
    Serial.printf(&quot;filter:%d %d %d %d %d %d analog:%d %d %d %d %d %d\n&quot;, x[0], x[1], x[2], x[3], x[4], x[5],analog[0],analog[1],analog[2],analog[3],analog[4],analog[5]);
    Serial1.printf(&quot;&lt;%d,%d,%d,%d,%d,%d&gt;&quot;, x[0], x[1], x[2], x[3], x[4], x[5]);
}
</code></pre>
<p>Change <code>index&lt;6</code> to <code>index&lt;2</code>, and uncomment <code>\\x[index] = myFilter[index].update(analogRead(SensorInputPin[index]));</code></p>
<p>It will be a normal output using two inputs and filters.</p>
<p><img src="https://aws1.discourse-cdn.com/arduino/original/4X/5/e/9/5e9e39c25020a7816c04deb0cc7cdabc3f2de437.gif" alt="2022-04-15--15-15-26_fps=8_scale=720_max_colors=128|690x341" /></p>
<p>But changing <code>index=0;index&lt;2</code> to <code>index=0;index&lt;6</code> will be abnormal output.
<img src="https://aws1.discourse-cdn.com/arduino/original/4X/e/b/c/ebc212b30692150bc1cfb0c29c4d9733a6195105.gif" alt="2022-04-15--15-29-32_fps=8_scale=720_max_colors=28|690x323" /></p>
<p>If changing to <code>index=3;index&lt;4</code> or <code>index=2;index&lt;3</code>...etc, it will be normal output:
<img src="https://aws1.discourse-cdn.com/arduino/original/4X/0/5/8/05885f12cbba1c227d4f4349a169a8979a2f8caa.gif" alt="2022-04-15--15-15-43_fps=8_scale=720_max_colors=128|690x459" /></p>
<p>Sketch:
<img src="https://aws1.discourse-cdn.com/arduino/optimized/4X/b/f/b/bfb266cf4e5eb7357b6804bb7bb3a9fbd7f75694_2_705x750.png" alt="image|470x500" />
<img src="https://aws1.discourse-cdn.com/arduino/original/4X/5/5/3/553b46bb94559258b980463677a5bdee60e6a63d.png" alt="image|667x500" />
<img src="https://aws1.discourse-cdn.com/arduino/optimized/4X/1/b/c/1bccfe458e8f9843f7c8312806ff5909fd09b390_2_517x351.jpeg" alt="" />
<img src="https://aws1.discourse-cdn.com/arduino/optimized/4X/d/1/4/d140c573d60e65c1333760ca63b1a9155da322bd_2_601x750.jpeg" alt="" />
<img src="https://aws1.discourse-cdn.com/arduino/optimized/4X/6/e/c/6ec16040627057412528f8ec8bf60ee7da128bf1_2_273x373.jpeg" alt="" /></p>
<p>XIAO MCU schematic in the HTML: <a href="https://files.seeedstudio.com/wiki/Seeeduino-XIAO/res/Seeeduino-XIAO-v1.0-SCH-191112.pdf" rel="nofollow noreferrer">https://files.seeedstudio.com/wiki/Seeeduino-XIAO/res/Seeeduino-XIAO-v1.0-SCH-191112.pdf</a></p>
<p>I don't have a sensor schematic.</p>
<p>Filter code: <a href="https://github.com/oymotion/EMGFilters/blob/master/EMGFilters.cpp" rel="nofollow noreferrer">https://github.com/oymotion/EMGFilters/blob/master/EMGFilters.cpp</a></p>
<p>I hope each simulation output to look like the first Gif(normal output), what should I do to achieve this?</p>
 7508: <p>This is a bug in the filter library you are using. <a href="https://github.com/oymotion/EMGFilters/issues/3" rel="nofollow noreferrer">It has already been
reported</a> (by you, maybe?).</p>
<p>As Majenko and chrisl suggested in comments, the crux of the problem is
that you need one filter per input channel. Using multiple instances of
<code>EMGFilters</code> seems like the obvious solution. Alas, the library keeps
the filter state in global variables, which essentially means your six
filter objects all reference the same actual filter.</p>
