You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The problem is that the state of the EMGFilters filters is stored in the global variables LPF, HPF and AHF. These being globals means that all instances of EMGFilters share their internal state.
The filter state should be stored as instance data. Otherwise all instances effectively share the same filter.
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.
Change
index<6
toindex<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
toindex=0;index<6
will be abnormal output.If changing to
index=3;index<4
orindex=2;index<3
...etc, it will be normal output:I use two MCUS, both raise the same abnormal.
How do I allow multiple filters to output normally?
The text was updated successfully, but these errors were encountered: