Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Implement low pass filter.
Forum Updated to NodeBB v4.3 + New Features

Implement low pass filter.

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 4.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fcarneyF fcarney

    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.

    S Offline
    S Offline
    Siddhartha
    wrote on last edited by
    #5

    @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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      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 like

      double 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

      S 1 Reply Last reply
      2
      • mrjjM mrjj

        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 like

        double 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

        S Offline
        S Offline
        Siddhartha
        wrote on last edited by
        #7

        @mrjj Hello, thank you very much for answering, I tried to use your solution but I threw this error.
        0_1547654496959_Captura.PNG

        mrjjM 1 Reply Last reply
        0
        • S Siddhartha

          @mrjj Hello, thank you very much for answering, I tried to use your solution but I threw this error.
          0_1547654496959_Captura.PNG

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @Siddhartha
          Hi
          well DoLowPass is just a fictional name.
          You have to create the function from JKSH link or from the book @fcarney linked.

          S 1 Reply Last reply
          1
          • mrjjM mrjj

            @Siddhartha
            Hi
            well DoLowPass is just a fictional name.
            You have to create the function from JKSH link or from the book @fcarney linked.

            S Offline
            S Offline
            Siddhartha
            wrote on last edited by
            #9

            @mrjj And what would it be like?

            mrjjM 1 Reply Last reply
            0
            • S Siddhartha

              @mrjj And what would it be like?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @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];
              }
              
              
              S 1 Reply Last reply
              2
              • mrjjM mrjj

                @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];
                }
                
                
                S Offline
                S Offline
                Siddhartha
                wrote on last edited by
                #11

                @mrjj Thank you very much and I hope not to be annoying, but where would you place that code?

                mrjjM 1 Reply Last reply
                0
                • S Siddhartha

                  @mrjj Thank you very much and I hope not to be annoying, but where would you place that code?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @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.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    Hi,

                    You may also find the DSPFilters project interesting.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by JKSH
                      #14

                      @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)

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      S 1 Reply Last reply
                      4
                      • JKSHJ JKSH

                        @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)

                        S Offline
                        S Offline
                        Siddhartha
                        wrote on last edited by
                        #15

                        @JKSH Unfortunately, I'm new to both.

                        JKSHJ 1 Reply Last reply
                        0
                        • S Siddhartha

                          @JKSH Unfortunately, I'm new to both.

                          JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on last edited by
                          #16

                          @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:

                          1. Learn how to build and run an existing program
                          2. Learn how to modify an existing program
                          3. Read about the basics of different types of low-pass filters
                          4. Convert a low-pass filter equation into C++ code
                          5. 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?

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          1 Reply Last reply
                          4

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved