Real-Time Software Implementation of Analog Filters - Phil's Lab #20

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 141

  •  3 года назад +76

    As an EEE sophomore, it is fascinating to see complex topics well explained in a practical approach. Thank you for your detailed videos.

    • @thekaduu
      @thekaduu 3 года назад +2

      Afferin, adam olacan :)

    • @adityaramachandran5223
      @adityaramachandran5223 3 года назад

      Literally same haha. +1

    • @p_mouse8676
      @p_mouse8676 3 года назад +4

      The lack of any real world practical examples at schools was in fact the biggest struggle for me back in the day, and still is with interns I have to manage. These days I design most of the time just by practical intuition and skills, instead of hardcore theory.

  • @pablo_costas
    @pablo_costas 3 года назад +19

    I learnt more of DSP with your videos in 2 days that in all those years of engineering degree haha. Thanks a lot I really appreciate your effort!

  • @JasonDoege
    @JasonDoege 3 года назад +6

    This is a fantastic and easy to follow video. A really cool addition to this would be to build the physical analog circuit you are implementing in software and compare the outputs.

  • @jaytrodden9244
    @jaytrodden9244 2 года назад +1

    Really nicely done. Probably would have spent more of my career in analog design instead of digital if high quality videos on these topics had been available to supplement textbooks used when I was in school. Thanks.

    • @PhilsLab
      @PhilsLab  2 года назад

      Thank you very much, Jay!

  • @buscoparan1772
    @buscoparan1772 3 года назад +1

    as a beginner in stm32, i am very enlightened by your videos. thank you very much!

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you, Busco! Hopefully many more to come.

  • @marek_ryn
    @marek_ryn 3 года назад +5

    As always excellent content. I admire how you can explain complex subjects in such a simple way. Thank you Phil for sharing with your knowledge!

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you very much, Marek - that means a lot to me!

  • @connectme2karthik
    @connectme2karthik 2 года назад +1

    Filtering is so interesting and fascinating to explore, your videos are just amazing enough to motivate me, again and again, to play with it on embedded devices.

  • @stanleyyyyyyyyyyy
    @stanleyyyyyyyyyyy 3 года назад +2

    very well explained! greetings from a fellow DSP engineer

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you, Stanley!

  • @Bits32
    @Bits32 3 года назад +3

    High-quality content. Thank you, Philip.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you very much for watching, Irshad!

  • @williamogilvie6909
    @williamogilvie6909 5 месяцев назад

    Very interesting. I did this in 1989 for a company called Analog Design Tools. (Now part of a large EDA company) They had a contract with an automatic test company to simulate a new test machine. Most of it was easy, but they didn't know how they were going to simulate analog filters in software. There were several filters, of different orders, and all expressed as Laplacians. The method I used was to convert the Laplacian to a Z Transform. The Z Trsnsform can easily be re-written as a difference equation. A correction factor was needed because of a difference in range of Laplacians vs the Z Transform. I wrote the program in C and used the ADT software to create the frequency swept response of the analog Laplacian representation and the IIR filter. Once this conversion (analog s domain to difference equation) was perfected, I created a program that converted an s domain fraction of any order into the correct difference equation. Not sure how useful that was. ADT had just hired 20 new CS grads, so they had something to play with.

  • @MrTelraam
    @MrTelraam 2 года назад +1

    Phil, love your videos! Very calming to say....
    Have a tip/more efficient way for the equation. You could do it with one coefficient. k=T/(T+RC) and solve:
    Voutn = k*Vinn + (1-k)*Voutn-1
    Where 1-k=RC/(T+RC), solve it yourself to proof.

    • @mikefochtman7164
      @mikefochtman7164 5 месяцев назад +1

      Came here to mention this, but add an even further improvement. When we did this we sometimes had issues with the (1-k) all the time. With a little algebra you can use:
      Voutn = Voutn-1 + k *(Vinn - Voutn-1).
      So instead of two multiplications, we have just one. Back in the 70's and 80's when I started doing this sort of thing, that was a serious improvement in CPU time. And if you have low-precision rounding errors, it eliminates the chances of (k + (1-k)) not being exact 1.000000 which can cause some issues.

  • @pramitchaudhury1821
    @pramitchaudhury1821 3 года назад

    Awesome awesome awesome awesome please continue to create a series on digital signal processing in such a practical way

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you very much, Pramit! Definitely more DSP videos to come.

  • @dehCremus
    @dehCremus 3 года назад

    At the beginning of the video I wasn’t expecting the implementation to be that easy! Definitely going to try this on my PT100 circuit!

    • @PhilsLab
      @PhilsLab  3 года назад

      Thanks, Christiaan! Yeah, it's actually surprisingly easy to implement these kinds of things. Hope it works out well with your project :)

  • @dpneber
    @dpneber 3 года назад +1

    I have always averaged n samples to smooth out an jittery analog sensor reading. Thank you for this new tool.

    • @MarianKeller
      @MarianKeller 3 года назад +1

      A running average filter is actually the equivalent to an ideal 1st order RC-filter, with the -3dB cutoff at half the sampling frequency.

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thanks for watching! Actually, a movering average filter is pretty much the optimal way of smoothing a signal if you aren't worried about a particular frequency band.

  • @userou-ig1ze
    @userou-ig1ze 3 года назад +3

    wow, this is a crazy good quality video, thanks so much for this great info, it just-matches my knowledge level to understand, perfect for learning

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, very glad to hear that! :)

  • @rjrodrig
    @rjrodrig 3 года назад

    Very educational video. I liked how you simplified the differential equation to something very fundamental and easy to understand without all the math complication and setting up Standard form equations etc... in differential equations. Thank you very much for this video!

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you! Yeah, I was wondering how well the differential equation part was gonna be received - I tried to keep it simple and just to what was necessary to implement it. Thanks again :)

  • @TheNewTimeNetwork
    @TheNewTimeNetwork 3 года назад

    Great explanation once again! I hated all the EE parts - network analysis and everything analog - back in college. Now I've indirectly gotten back to that domain through PCB, FPGA and embedded design and find it fascinating.
    One minor improvement: you only need a single output buffer value (float out;) because the second value is never actually used. You can write
    float RCFilter_Update(RCFilter * filt, float inp) {
    return filt->out = filt->coeff[0] * inp + filt->coeff[1] * filt->out;
    }

  • @power-max
    @power-max 3 года назад +6

    Ha I've been dabbling with the "backward euler" method long before I knew what it was called, where I made a little planet and gravity simulation in a javascript processing thing, where integration is += and differential is just current value minus old value. 😆

    • @power-max
      @power-max 3 года назад +3

      And if you don't mind burning lots of CPU cycles, just record the impulse response of your filter and convolve it with your input stream, FIR filtering easy as!

    • @PhilsLab
      @PhilsLab  3 года назад

      Yeah, that's one of the most popular places to use it - numerical integration! If you haven't already, I'd encourage you to look up 'Runge-Kutta' integration which is a more accurate method of numerical integration. Actually what I used for my flight simulator.

    • @power-max
      @power-max 3 года назад

      @@PhilsLab let me guess, is it like assuming linear interpolation (trapezoidal integration) over the += which is like the classic riemann sum / nearest neighbor type approximation?

  • @merveozdas1193
    @merveozdas1193 2 года назад

    I felt in love with this channel, his shares are reading my questions

    • @PhilsLab
      @PhilsLab  2 года назад

      Thank you, Merve!

  • @sakthivel_duraisamy
    @sakthivel_duraisamy 3 года назад +2

    Perfect explanation 👌this is called phills lab...

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you, Sakthivel! :)

  • @jithin_isaac
    @jithin_isaac 3 года назад +12

    Hey Philip, when will you be launching your PCB design course? in the pipeline?

    • @PhilsLab
      @PhilsLab  3 года назад +6

      Hey Jithin, I'm still working on the PCB design course. It's taken me a bit longer than expected but it's definitely on it's way - will post an update when I know more about the release date! :)

    • @jithin_isaac
      @jithin_isaac 3 года назад

      Okay Philip.. awaiting your course eagerly...

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 3 года назад

    Great content and not a single library needed. Nice brain workout. Thanks

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, very glad to hear that! :)

  • @sayantanmaiti2513
    @sayantanmaiti2513 3 года назад

    Thanks a lot for this sir. I have used ESP32 and utilised it's inbuild DAC to make a similar low pass filter using Tustin method / bilinear transformation

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thanks for watching :)

  • @marcoscuriel7741
    @marcoscuriel7741 3 года назад +2

    great job! thank you! this is the best youtube channel

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, Marcos!

  • @AB-uk4pd
    @AB-uk4pd Год назад

    this is so well explained. thank you for that!!!

  • @BalticLab
    @BalticLab Год назад +1

    So what would this look like with an integral part, i.e. an inductor?

  • @jacobrodgers8191
    @jacobrodgers8191 3 года назад

    Looking forward to the IIR filter video!

  • @Kefford666
    @Kefford666 3 года назад +2

    This is really interesting 👍🏻
    I’ve not used the BMI088 (yet!) but I’ve used a BMA accelerometer and it had selectable built-in digital filters you can adjust via the ACC_CONF register. I wonder how it compares doing it in your app software vs on the sensor itself, might be worth trying. The software approach seems more flexible and therefore easier to tweak with an update.

    • @PhilsLab
      @PhilsLab  3 года назад +2

      Thank you, Matthew! Yeah, the integrated digital filters are definitely a useful tool, as they'll offload the main processor a bit. But as you say, our own software implementation gives us a bit more flexibility.

  • @rust_embedded
    @rust_embedded 3 года назад

    Awesome and not overcomplicated! Thank you!

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you, Vitaly!

  • @JoaoPaulo-fw3zg
    @JoaoPaulo-fw3zg Год назад

    My advice: |Vout(f)|/|Vin(f)| must be at least 80dB below the máximum at f=1/T to practicaly overcome the aliasing.

  • @hansdietrich83
    @hansdietrich83 3 года назад

    This would be a perfect use of a ping ping buffer using the DMA half cplt callback. While the dma is filling the first half of the buffer, you filter the second half and then switch

  • @zetaconvex1987
    @zetaconvex1987 3 года назад

    Good stuff. I look forward to your next video.

  • @dandan-gf4jk
    @dandan-gf4jk 3 года назад

    A week ago I started reading about filtering in the frequency domain, and one very invasive thought I had was, What if you were to simulate the equivalent analogue circuit for filtering?
    To say I'm surprised how accurately that video fulfills my needs is an understatement.

    • @LiyangHU
      @LiyangHU 3 года назад +1

      The mind-blow is when you realise that the FIR coefficients is just the Fourier transform of the frequency response, and vice versa.
      Using analog components is just a shitty unreliable way of implementing a digital filter, but it's what we had at the time.
      (Though it has to be said, using a whole CPU just to implement a digital filter is also somewhat of a waste of resources.)

    • @PhilsLab
      @PhilsLab  3 года назад

      Haha glad to hear that the timing was right! Thanks for watching, Dan :)

  • @EmbeddedEnigma
    @EmbeddedEnigma 3 года назад +1

    can u make a video on how one can implement 2nd order Butterworth low pass filter in software ?

  • @randypeeters3931
    @randypeeters3931 3 года назад +2

    Really interesting thank you!

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you, Randy!

  • @sanketpatadiya8168
    @sanketpatadiya8168 3 года назад

    Superb explanation, brilliant 👍👍👏 Thank you.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, Sanket!

  • @cpuchip
    @cpuchip 3 года назад

    I'd love a crash course analog/digital course from you.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you! Hopefully will be putting more analog + digital content on the channel. Any topic in particular that you'd like to have covered?

    • @cpuchip
      @cpuchip 3 года назад

      @@PhilsLabI've been thinking about how to answer this question over the last few days
      I dont know if I know enough to give a good response! I think what I see lacking and really want to know more about is how to mix components like diodes and transistors, capacitors and coils in analog and digital electronics, like there's a billion different values for transistors and diodes, why did you select those. What effect do they have one the circuit? Id love to see practical examples. I really liked how you went through the steps of designing a digital filter in this video and then implemented it and showed the results! That was great!

  • @mohsenmazandarani7506
    @mohsenmazandarani7506 Год назад

    Thank you so much, great video .....
    I had a problem. The filter's output gets -Inf. from the 4th or 5th sample.

  • @agure
    @agure 3 года назад +1

    Hi Phil, great video as always - Thanks. Can you please make a video on dfu?

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you very much! At some point I might include DFU in a video but not sure if I'll make a video solely on that.

  • @maxtechlab1542
    @maxtechlab1542 3 года назад

    Thanks for your videos, I really like them. I was searching for a software similar to the serial oscilloscope, but did not found anything good. So thanks for mentioning:)

  • @Soupie62
    @Soupie62 3 года назад

    A great practical example of DSP. I need to check the rest of your videos now.
    One thing: for higher frequencies, you obviously need a faster sample rate. What is the limit using the STM32, and what are your options if you want to go faster?

  • @fir3w4lk3r
    @fir3w4lk3r 2 года назад

    Is there any simple board for digital filters? A good ADC -> MCU -> DAC

  • @thekaduu
    @thekaduu 3 года назад +1

    Funny... I have every single item on the schematic on hand (substituting BMI088 with BMA253 and BMP280 with BME280)... Small world :)

  • @Εὐκλείδης300
    @Εὐκλείδης300 Год назад

    Thank you so much!

  • @rikilshah
    @rikilshah 3 года назад

    Wow! I never understoof DSP this good. You made it really simple!

  • @_a_x_s_
    @_a_x_s_ 3 года назад

    Great. I am currently making a function generator. This filter can gonna help me. Just change RC for different frequencies, which will do the job. Will try that in my project.
    I was expecting you to talk about some window functions, IIR coefficient sequences, SNR performance, etc.
    This algorithm seems fast, efficient, and easy to be implemented.
    I am thinking of constructing a better analog filter circuit than a simple RC filter and convert its transfer function into a discretized form.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you! Yeah, this is kind of a 'pre-cursor' to a full IIR filtering video. There I'll be coming IIR filters in far more depth.
      Hope all goes well with your project :)

  • @EhsanAlnazi
    @EhsanAlnazi 3 года назад

    Really, I am like this video and like this guy.

  • @Krmpfpks
    @Krmpfpks 3 года назад

    Thank you so much for your clear expanation. Also nice to see you use units in your variable names, a practice that helps all too often in nightly debug sessions. Was there a particular reason why you stored two output values? For this formula one would have been enough.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you very much! Yeah, I think it's a good practice to include the units in these sorts of applications as well.
      I used two variables for the output values just for clarity (in my eyes it shows it a bit more directly that we are basing our computation on a previous output) - but yes, one output variable would of course have been enough :)

  • @chris_lynch
    @chris_lynch 3 года назад +1

    Great video. You should consider creating a udemy course on dsp, I would gladly pay. Likewise with control theory. Thanks

  • @osamadz5884
    @osamadz5884 3 года назад

    ❤ i can't find a perfect words to thank you for your videos u are hero to me you helped me a lot

    • @PhilsLab
      @PhilsLab  3 года назад +1

      That's very kind of you to say, thank you so much!

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you!

  • @fvgm
    @fvgm 3 года назад

    Thank you for this video.

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you for watching, Fernando!

  • @carygrove6
    @carygrove6 3 года назад

    Have you looked into a Kalman filter, specifically in context of an IMU/accelerometer?

    • @PhilsLab
      @PhilsLab  3 года назад

      Yes, there are some Kalman filter implementations on my Github page (github.com/pms67). I'll be making a video on Kalman filters in the near future.

  • @sigmaxi7822
    @sigmaxi7822 3 года назад

    I like how this video shows the simplicity of digital filtering. However, I don't quite get the "real-time" aspect. Which part of the implementation guarantees the timing deadlines that are essential for real-time systems?

    • @PhilsLab
      @PhilsLab  3 года назад +2

      Thank you! I put 'real-time' in the title to mean that this is an 'online'/'live' computation, rather than some form of post-processing.

    • @sigmaxi7822
      @sigmaxi7822 3 года назад

      @@PhilsLab I think it's a bit misleading, but maybe that's just due to my personal expectations. Anyways, great work as always!

  • @hamouz718
    @hamouz718 3 года назад +1

    We are waiting patiently or impatiently waiting, wait both, the point is we are dying to get hold of your pcb course, any good news??

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Hey Hamza, Thank you - yes, I'm still working on the PCB design course. It's been a busy few months so it's been dragging out a bit, but I will update soon on the channel :)

  • @checkm8606
    @checkm8606 3 года назад

    Do you have a playlist for this stuff? All stm32 pcb design and code where you start from the beginning (for behinners) to where you are right now?

    • @PhilsLab
      @PhilsLab  3 года назад

      I have a few smaller playlists which should be public on my channel. One for PCB design, then DSP, and also for STM32 firmware. This should cover everything up to the point you see in this video!

  • @blcouz
    @blcouz Год назад

    I discovered this channel too late.

    • @PhilsLab
      @PhilsLab  Год назад

      Glad you found it :)

  • @mekbots7607
    @mekbots7607 3 года назад

    Do you have stm32 programming course?

  • @M0XYM
    @M0XYM 3 года назад

    Hello Phil - this is really excellent - thank you. I just wondered if you would consider doing an additional software implementation in uPython - especially as the RP2040 chip used in the Raspberry Pico is gaining traction?

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Hey Kevin, Thank you very much! I'm not sure I'll be making additional implementations in other languages, as I think this should be pretty straightforward to convert and C is pretty much the only language I use these days. Maybe if you wanna give it a try and then share the results, that would be awesome!

    • @M0XYM
      @M0XYM 3 года назад

      @@PhilsLab Phil - I think I will actually do that - keep the vids coming!

  • @bhu1334
    @bhu1334 3 года назад

    I love your tutorials as you give us practical examples of every topic.
    I had a few questions, are there any advantages of having an actual analog low pass filter front end for adcs over digital filters?
    Also since you are already exploring imu stuff can you make tutorials for ahrs algorithms and maybe even sensor fusion using kalman filtering in the future. I would love to see those
    Thank you

    • @PhilsLab
      @PhilsLab  3 года назад +2

      Thank you very much! You will in most cases need an actual analog low-pass filter before the ADC input (sometimes this is included in the IC) and is known as an anti-aliasing filter. Furthermore, analog filtering prior to the conversion will often be useful if you want to reduce the bandwidth of the signal, remove a DC offset, or so forth.
      Yes, one of my next videos will actually be on the Extended Kalman Filter and how to implement it in real-time on an MCU. :)

    • @bhu1334
      @bhu1334 3 года назад

      @@PhilsLab I can't wait, thanks for the reply

  • @jcd2diablo100
    @jcd2diablo100 3 года назад

    amazing content

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, Mesbah!

  • @pietrogagliano4484
    @pietrogagliano4484 3 года назад

    Love this video! And just at the right time I recently designed my own version of this board using the repo and had it assembled by JLCPCB and it just came in 2 weeks ago and I've been working on the firmware since! This couldn't have been timed better! I just wanted to ask if you know approximately when the course you discussed in previous videos will be finished? I know you must be very busy and it's no rush at all I'm just very excited for that course. Great stuff! Thanks Phil!

    • @PhilsLab
      @PhilsLab  3 года назад

      Thank you so much, Pietro! What changes did you make to your board?
      Regarding the course, it'll take a bit longer - I've been quite busy with other work, so I've been pushing it back a tiny bit. But I'll put an update on the channel this month :)

    • @pietrogagliano4484
      @pietrogagliano4484 3 года назад

      @@PhilsLab No worries I completely understand the videos taking a bit longer. And my changes were fairly minor, I mostly experimented with a slightly different layout of some of the components to get the power related components closer to their adjacent components as I'm very particular about component placement and space saving. That was really most of the extent of the changes I made. I also tried routing the power using thicker traces as opposed to the pours as I still slightly prefer using just thicker traces on the top layer and leaving the power pour polygons for the middle layers for 3v3 and gnd. But it is essentially the same circuitry I didnt change any components or anything like that.
      I have started writing some firmware on my boards based on your firmware videos and the boards work really well!
      Thank you for your response I really appreciate it! I also know you announced at one time you would do a video for designing an fpga breakout board. Of course I completely understand if you've been too busy to get to it but I just wanted to know if there was any word on that as well. Thank you again for making such great content!

    • @pietrogagliano4484
      @pietrogagliano4484 3 года назад

      By routing the power I mean the top layer power components like the inductors and components that needed thicker power traces where you placed pours in your design. I still used the middle layers for 3v3 and GND and placed vias on the top layer at 3v3 and GND pads as usual.

    • @pietrogagliano4484
      @pietrogagliano4484 3 года назад

      I just remembered that I also wanted to ask if you would be able to put the open seneca board from one of your past videos on your repo as well as I thought it was interesting and had some types of components I haven’t used yet. So I also wanted to know if that was possible?

  • @andrewvoron4490
    @andrewvoron4490 3 года назад

    Why not we just deconstruct signal by frequency(getting spectrum by Fourier transform), drop uninteresting frequencies(high in our case), and combine back?

    • @argonathcirith
      @argonathcirith 3 года назад

      I guess because of higher computational cost of FT/IFT conpared to euler method

  • @JFrames
    @JFrames 3 года назад

    What is the nyquist limit?

    • @TheNewTimeNetwork
      @TheNewTimeNetwork 3 года назад

      When you have a signal with frequency f, then you need to sample it at a sample rate of at least 2*f, otherwise you will suffer aliasing. For example, CD audio is sampled at 44.1 kHz such that it can properly represent the human hearing range up to 22.05 kHz.
      The sample time T is the inverse of the sample rate, so to sample a signal of frequency f, chose a T

  • @TheGhost13X
    @TheGhost13X 3 года назад

    Can you please do next control system video?

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Yeah, I'd really like to continue on that. I've moved countries and don't have all my equipment with me here though :(

  • @RixtronixLAB
    @RixtronixLAB 3 года назад

    Nice info :)

  • @TheGiuse45
    @TheGiuse45 3 года назад

    Wow amazing, and my stupid ass thought FFT would be used and then recreate the signal...

    • @PhilsLab
      @PhilsLab  3 года назад +1

      Thank you! That is definitely another way of doing this but of course a bit more computationally intensive.

    • @TheGiuse45
      @TheGiuse45 3 года назад

      @@PhilsLab i feel like the way that you showed is a very elegant solution, I have never thought of emulating physics on a digital level and as a EE student i find it very fascinating

  • @euglossine_tristanwhitehill
    @euglossine_tristanwhitehill Год назад

    🙏 ❤

  • @sivuyilesifuba
    @sivuyilesifuba 2 года назад

    Wow :o

  • @cunningham.s_law
    @cunningham.s_law 3 года назад

    wow

  • @aquahoodjd
    @aquahoodjd Год назад

    😊

  • @jeetenderkakkar7570
    @jeetenderkakkar7570 3 года назад

    Ritesh 1000 analog

  • @natasha.
    @natasha. 3 года назад +2

    FIRSt!!!!1