Implement low pass filter.
-
Hi, I'm a novice and I'm learning.
How would you manage to implement a 50 Hz LOW Pass Filter in this software?
Thank you very much for the help. -
Hi @Siddhartha, and welcome.
How would you manage to implement a 50 Hz LOW Pass Filter in this software?
Which software? Qt, or the serial port plotter?
Anyway, your first step is to learn the basics of Finite Impulse Response (FIR) filters. After that, you can implement it in C/C++. There is an example at https://ccrma.stanford.edu/~jos/fp/Definition_Simplest_Low_Pass.html
-
@JKSH HI, True, what I need is to implement the Low Pass filter in the serial plotter.
If I could implement it in this serial plotter that I attached it would be fabulous.This example that you give me how I could attach it to the serial plotter software that I attached?
Where in all your classes should I implement the code and in what way? -
This should help with the low pass filter:
http://www.dspguide.com/
You can download each chapter as a PDF. It covers just about every type of DSP you might need.How you implement this will be up to you.
-
@fcarney Hello, the book is fabulous, the problem is that I am just learning and I do not know how to implement that filter in the serial plotter that I attached, I understand the biomedical signals but I do not understand how to implement the filter in the program.
-
Hi
In
Mainwindow.cpp
function
void MainWindow::onNewDataArrived(QStringList newData)
line 428
it says
ui->plot->graph(channel)->addData (dataPointNumber, newData[channel].toDouble());
so that is where it adds the data.
so you need something likedouble filteredData = DoLowPass( newData[channel].toDouble() ); ui->plot->graph(channel)->addData (dataPointNumber, filteredData ); so that is where it adds the data.
where DoLowPass should do the filtering.
You can try with the simple version from the link @JKSH provided -
@Siddhartha
Hi
well DoLowPass is just a fictional name.
You have to create the function from JKSH link or from the book @fcarney linked. -
@Siddhartha
Like shown in the link ?/* C function implementing the simplest lowpass: * * y(n) = x(n) + x(n-1) * */ double simplp (double *x, double *y, int M, double xm1) { int n; y[0] = x[0] + xm1; for (n=1; n < M ; n++) { y[n] = x[n] + x[n-1]; } return x[M-1]; }
-
@Siddhartha
Hi
well it could be a global function, but i think its better to make it a function of
MainWindow just like the other functions.
However, the simplp is a c function and uses a c array for the x,y but in plotter
the data is in
MainWindow::onNewDataArrived(QStringList newData)
which is a Stringlist so you cant just copy the code and have it working.So first step is to read the text in link and understand how it works then change the code to use
the newData list instead as the c code expects other type of list and must be rewritten slightly. -
Hi,
You may also find the DSPFilters project interesting.
-
@Siddhartha Before we go too deep, we need to know your starting point. Please tell us: When you said you're a novice, do you mean a novice in programming, or a novice in digital signal processing, or both?
(Note: Programming and signal processing are two very different fields. You'll need to learn both to implement a low pass filter in the plotter software)
-
@Siddhartha said in Implement low pass filter.:
Unfortunately, I'm new to both.
No problem.
OK, here's a 5-step approach I recommend for you to reach your goal:
- Learn how to build and run an existing program
- Learn how to modify an existing program
- Read about the basics of different types of low-pass filters
- Convert a low-pass filter equation into C++ code
- Integrate the C++ low-pass filter code into the serial port plotter (just like step #2)
Let's start with step #1. I see that you already have Qt Creator; are you able to build and run the serial port plotter software on your PC?