Implement low pass filter.
-
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 -
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@mrjj Hello, thank you very much for answering, I tried to use your solution but I threw this error.
-
@mrjj Hello, thank you very much for answering, I tried to use your solution but I threw this error.
@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
Hi
well DoLowPass is just a fictional name.
You have to create the function from JKSH link or from the book @fcarney linked.@mrjj And what would it be like?
-
@mrjj And what would it be like?
@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
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]; }
@mrjj Thank you very much and I hope not to be annoying, but where would you place that code?
-
@mrjj Thank you very much and I hope not to be annoying, but where would you place that code?
@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 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)
@JKSH Unfortunately, I'm new to both.
-
@JKSH Unfortunately, I'm new to both.
@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?