0
votes

I have implemented a pulse oximeter on FPGA and I am collecting the data at sampling rate = 115200. So when I plot the data in Matlab I get the following waveform:

enter image description here

I would like to set up a simple low pass filter to filter out the noise.So the filtered data looks something like this:

enter image description here

How do I design this filter? How do I determine the cutoff frequency for butterworth filter ([b,a] = butter(n,Wn))?

W1=0.5/60;  % lower cutoff 
W2=4/60;    %higher cutoff
[b,a]=butter(2,[W1,W2]); % Bandpass digital filter design 
h = fvtool(b,a); % Visualize filter
low_pass_data1 = filtfilt(b,a,data); % applying filter to our data 

The above mentioned algorithm works and I got it from the internet but I don't know how it works? There is no mention of the sampling rate in the above algorithm and yet it works! I don't even know if it's right.

1

1 Answers

0
votes

Since you are designing a digital filter, the sampling rate is irrelevant. A digital filter takes a stream of values and outputs a stream of values, it has no chance of knowing at what rate they were taken, nor would it matter.

Therefore, frequencies in digital filters are always relative. Actually, the help of butter explains it:

The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

Therefore, if your natural sampling rate is 115200 Hz and you want to cut off at, I don't know, 10 kHz, then the frequency to pass to butter is 10000/(115200/2) = 0.1736.

In case you wonder why it is half the sampling rate: with a sampling rate of Fs, we can see the frequency content in [-Fs/2,Fs/2] (due to Shannon-Nyquist), therefore half the sampling rate is the highest frequency that makes sense.