Processing (Filtering) Bio- Signals using Arduino Uno

Greetings ,
I am able to get (See) the analog signal (waves) and Values on the Serial (Monitor and Plotter) of the Arduino IDE. but am not able to apply FFT filters or other type of filters for the obtained bio Signal. How do I apply a filter to a continuous wave which I can see on the Plotter in Live.

ie.,: I am able to get the Raw Data , But I want to get the processed and Filtered Data and be able to See it Live(On the serial Plotter itself).

Looking Forward for Help.

Thank You .

if you do a web search for arduino fft you will get plenty of links

don't know if you could do an FFT on a UNO - you may need to move to a more powerful microcontroller such as an Arduino Due or an ESP32

what sampling rate/frequencies are you looking at?

Am looking for 250 to 1250 samples/sec and I am moving on to ESP32.
Assuming the frequency range is from 1HZ to 100Hz.
Can the ESP 32 Fetch the Signal from the body and Filter it at the same time (Real Time) ?
The main aim of the project is to plot the filtered bio signal on the serial Monitor of my Arduino Serial Plotter. (in real time)

Thank you for the reply horace !

Shannons theorem tells you should sample at least at 2 times the frequency.
Also you should guarantee that higher frequencies are not present.
I recommend an analog rc filter (maybe second order) and sampling at 3000 Hz.
Processing should be possible in real time.

Thank you so much for the suggestion in Change.
I will definitely alter the changes and check the output. Right now I am using 250 samples/sec and the frequency is in the range of 650 to 750hz.
Or maybe I am going to alter the samples/sec.

Thank you

Basically you can't with an Arduino. An FFT takes time to gather samples, process them, like windowing, and then display the results. While this is happening the continuous signal goes on happening. So basically this is a stop / start process.

To do this you would have to have something like a continuous FFT going and you sample phase involves just adding one sample to the FFT buffer and processing that. This in done by using a hardware, or rather a FPGA FFT implementation.

However, you can do other sorts of filtering on a continuous signal by using DSP (Digital Signal Processing) algorithms.
The whole subject is a bit maths heavy, But here are some links to get you started:-
Basic forms of filters
Basic Digital filters
Introduction to DSP

Basically what you do is to take the last n samples and apply a coefficient to each one. Sample n is the latest sample you take, sample n-1 is the sample before that and so on.
The filter's output is the sum of all the samples multiplied by the samples' coefficient Cn.

So you might have
output = Sn * Cn + Sn-1 * Cn-1 + S-2 * Cn-2

For a recursive filter some of these values in the polynomial can also include previous output values, like Out n-2 * CnOut n-2. If the output coefficients are not chosen correctly the filter can become unstable and the output will oscillate instead of passing the signal through the filter. But a recursive filter often gives better results with fewer calculations.

As you can see there are a lot of floating point multiplications and additions, so you need a powerful Arduino to to this. However, on a Uno you can implement simple filters with a few coefficients, and still use a reasonable sample speed.

This is a tool that takes in what sort of filter you would like to implement and gives you the signal weighting for each successive sample.
Filter Design tool

This is a plot from my book Arduino Music Where Chapter 16 is all about simple signal processing. It shows a signal in the plotter window. The first half of the plot shows the input signal which is a simple square wave. The last half of the plot shows the output of the filter which is a simple notch filter taking out the fundamental frequency of the input square wave and leaving all the other harmonics in the square wave.

Notice that the filter, like all digital filters, needs a little time to settle down before producing a continuous output, because at the start the older samples have not been gathered yet. Or are full of old values.

Thank You very much for the Detailed explanation Mike. I will do the necessary changes and I shall Update here on the changes made.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.