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.

Implement low pass filter.

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 3.9k Views
  • 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.
  • S Offline
    S Offline
    Siddhartha
    wrote on 16 Jan 2019, 02:39 last edited by
    #1

    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.

    https://github.com/CieNTi/serial_port_plotter

    J 1 Reply Last reply 16 Jan 2019, 04:28
    0
    • S Siddhartha
      16 Jan 2019, 02:39

      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.

      https://github.com/CieNTi/serial_port_plotter

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 16 Jan 2019, 04:28 last edited by
      #2

      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

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

      S 1 Reply Last reply 16 Jan 2019, 14:22
      6
      • J JKSH
        16 Jan 2019, 04:28

        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

        S Offline
        S Offline
        Siddhartha
        wrote on 16 Jan 2019, 14:22 last edited by
        #3

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

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcarney
          wrote on 16 Jan 2019, 14:50 last edited by
          #4

          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.

          C++ is a perfectly valid school of magic.

          S 1 Reply Last reply 16 Jan 2019, 15:21
          2
          • F fcarney
            16 Jan 2019, 14:50

            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 16 Jan 2019, 15:21 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
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 16 Jan 2019, 15:41 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 16 Jan 2019, 16:01
              2
              • M mrjj
                16 Jan 2019, 15:41

                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 16 Jan 2019, 16:01 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

                M 1 Reply Last reply 16 Jan 2019, 16:16
                0
                • S Siddhartha
                  16 Jan 2019, 16:01

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

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 16 Jan 2019, 16:16 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 16 Jan 2019, 17:18
                  1
                  • M mrjj
                    16 Jan 2019, 16:16

                    @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 16 Jan 2019, 17:18 last edited by
                    #9

                    @mrjj And what would it be like?

                    M 1 Reply Last reply 16 Jan 2019, 17:30
                    0
                    • S Siddhartha
                      16 Jan 2019, 17:18

                      @mrjj And what would it be like?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 16 Jan 2019, 17:30 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 16 Jan 2019, 17:48
                      2
                      • M mrjj
                        16 Jan 2019, 17:30

                        @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 16 Jan 2019, 17:48 last edited by
                        #11

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

                        M 1 Reply Last reply 16 Jan 2019, 18:10
                        0
                        • S Siddhartha
                          16 Jan 2019, 17:48

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

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 16 Jan 2019, 18:10 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 16 Jan 2019, 21:30 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
                            • J Offline
                              J Offline
                              JKSH
                              Moderators
                              wrote on 16 Jan 2019, 23:02 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 16 Jan 2019, 23:35
                              4
                              • J JKSH
                                16 Jan 2019, 23:02

                                @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 16 Jan 2019, 23:35 last edited by
                                #15

                                @JKSH Unfortunately, I'm new to both.

                                J 1 Reply Last reply 17 Jan 2019, 01:56
                                0
                                • S Siddhartha
                                  16 Jan 2019, 23:35

                                  @JKSH Unfortunately, I'm new to both.

                                  J Offline
                                  J Offline
                                  JKSH
                                  Moderators
                                  wrote on 17 Jan 2019, 01:56 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

                                  1/16

                                  16 Jan 2019, 02:39

                                  • Login

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