I have a setup where I record several analog signals. I want to clean up these signals using a low pass filter.
Something like this:
float k = 0.5; //alpha level for lowpass function
float cleanSignal; // global veriable for lowpass function
void setup()
{
cleanSignal = 0; //initialize global value for lowpass function
}
float lowpass(float signal, float k)
{ //is k set globally? is cleansignal initialized globally and declared in setup?
float oldSignal = cleanSignal;
cleanSignal = oldSignal + (k * (signal - oldSignal));
return cleanSignal;
}
Now, the problem is, i want to be able to call the function with each of my signals i.e. dataA = lowpass (signalA, k); and dataB = lowpass (signalB, k);
Is there any way of writing one function which can filter each signal individually for me? Possibly using the static function?