Moving Average Filter - Theory and Software Implementation - Phil's Lab #21

  Рет қаралды 58,632

Phil’s Lab

Phil’s Lab

Күн бұрын

Пікірлер: 60
@sharkysharkerson
@sharkysharkerson 3 жыл бұрын
If you cache the sum and use a queue to keep track of your most recent n samples and subtract the oldest when you add the newest, you can have an arbitrarily long window size for the moving average that can be computed in constant time. Since at worst each step would involve one add, one subtract and one divide.
@GiorgioLZ
@GiorgioLZ 3 жыл бұрын
You are a genius, thanks for contributing your knowledge. Very well explained I would like to see a video of the Kalman filter in the future.
@ndanilo
@ndanilo 3 жыл бұрын
Hey, I'm from the future. And yes he did a couple of videos on Kalman Filter
@MartinWolker
@MartinWolker 3 жыл бұрын
I am use Kalman filter, which is more responsive for pressure data for exanple for variometer
@Gengh13
@Gengh13 3 жыл бұрын
On platforms without division in HW I use exponents of 2 lengths and shifting to minimize computation time, and of course all integers.
@robmurg
@robmurg 3 жыл бұрын
I had no idea that these little pressure sensors were sensitive enough to measure changes due to a few inches of height difference. Amazing! (The filter explanation was very interesting and useful too, thank you.)
@alessi4249
@alessi4249 3 жыл бұрын
Awesome! I just happened implemented an FIR like this today, I ended up using the arm_fir_f32 instead of implementing my own convolution for speed. Great video!
@myetis1990
@myetis1990 3 жыл бұрын
Hi, Phil nice job. Kalman filter implementation would be appreciated. Especially for imu sensor data.
@suncrafterspielt9479
@suncrafterspielt9479 3 жыл бұрын
Great video, can’t wait for the iir video
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you very much!
@charlesspringer4709
@charlesspringer4709 3 жыл бұрын
Hi Phil. Your videos are darn good stuff and you make me wish I had the energy I had 50 years ago but with 3D printers and all the good stuff of today. So, I will take issue with your claim of a simplest filter. I think a difference or derivative filter is much simpler. It is just the differences of successive pairs of numbers. It only has to "remember" the last point it read and the next point it reads. It is FIR in its nature. Of course, if you were a mathematician you would have said "The simplest filter is the identity filter." But isn't that too trivial for the rest of us. And in the same light you could say the next simplest filter is a gain filter that multiplies every point by some constant. Again kind of trivial although both these cases are mighty important if you are proving some set of operators forms a field. Or an algebra over some set, etc. I will have to change my claim to be the 3rd simplest and your moving average I submit will fall somewhere further down the list :-)
@hamouz718
@hamouz718 3 жыл бұрын
Great demonstration, the channel is just getting better and better, you are doing a superb work, a side question, any updates on the course, can't wait to see it 😭
@DonQuichotteLiberia
@DonQuichotteLiberia 3 жыл бұрын
The BluePhil, classic! :-D Excellent job, thank you for the video.
@PhilsLab
@PhilsLab 3 жыл бұрын
Haha thank you!
@buscoparan1772
@buscoparan1772 3 жыл бұрын
simple, yet very effective!
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you!
@andreasmiller5448
@andreasmiller5448 2 ай бұрын
Great video!
@obregr
@obregr 3 жыл бұрын
you are one of the great youtuber
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you, Gregor!
@masifamu
@masifamu 3 жыл бұрын
thank you for this amazing demonstration, it really worked for me
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you very much, Mohammad!
@charlesgalant8271
@charlesgalant8271 3 жыл бұрын
I wonder how this approach compares to my usual (lazy) way of doing it... y[n] = y[n-1]*0.9 + x[n]*0.1 modifying .9 and .1 as desired to shift responsiveness seems like less math / memory / instructions compared to how the FIR filter updates
@EdwinFairchild
@EdwinFairchild 3 жыл бұрын
reminds me of a complimentary filter.
@pablo_costas
@pablo_costas 3 жыл бұрын
@@EdwinFairchild it tells you how pretty you are every 2 samples
@fano72
@fano72 5 ай бұрын
Yeah the IIR approach is more feasible I think.
@MusaYmc
@MusaYmc Жыл бұрын
This is tremendous!
@PhilsLab
@PhilsLab Жыл бұрын
Thanks!
@ahmedalshalchi
@ahmedalshalchi 3 жыл бұрын
Very nice explanation of MA filter theory and implementation but I am an old engineer who hates Digital filtering moreover new generations of uC like STM32 .... Analog design is the real challenge world ...
@gpcm
@gpcm 3 жыл бұрын
Good stuff! You should do a kalman filter next
@Εὐκλείδης300
@Εὐκλείδης300 Жыл бұрын
Thanks!
3 жыл бұрын
Thank you for sharing.
@Electronics_Dreams
@Electronics_Dreams 3 жыл бұрын
Amazing video again! Thanks!!
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you, Gaston!
@lucvanhove9639
@lucvanhove9639 3 жыл бұрын
This is very interesting.
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you!
@pietrogagliano4484
@pietrogagliano4484 3 жыл бұрын
Hi Phil, love the video couldn't have come at a better time as I was just using my boards the other day and analyzing the barometric pressure sensor data. I'm gonna ask a question I'm sure you're tired of hearing but how is the course coming along I'm very excited for it
@Jose-tw9bl
@Jose-tw9bl 3 жыл бұрын
same here! how is the course going?🙈
@JorgeSilva-em8pf
@JorgeSilva-em8pf 2 жыл бұрын
Dear Phil. Your Vídeos are very good. I would suggest you one vídeo using "semihosting" on M0, not M3 or M4, on STM32 CUBE. This is due to the fact that M0 does not have TRACE, and semihosting would allow debugger using INPUT and OUTPUT files passing throught the implemented M0 program. Other way would be to use UART to input/output throught some program implementations. Those videos would be great. Regards.
@mspinksosu
@mspinksosu 2 жыл бұрын
I need more of your videos! I like it when I actually get to see the code. I don't quite understand the math sometimes, but I soon as I see the code, I can start piecing it together. I saw some code that implemented a exponential moving average filter. Which I think is a type of IIR filter. Do you have anything explaining an advantage of that type versus a regular moving average filter?
@matheuspimenta8486
@matheuspimenta8486 3 жыл бұрын
would it be possible to do a sinc2 filter with the same approach of this moving average?
@IEEEclipse
@IEEEclipse 3 жыл бұрын
Good job phil. In the next photo please implement dma transfers and offload cpu utilization using the cordic peripheral to demonstrate near zero three phase motor speed controllers 🙃
@NivagSwerdna
@NivagSwerdna 3 жыл бұрын
I've never had the nerve to try the JLPCB Assembly service as I'm not sure what steps are required for part alignment... would be interested in knowing how you got on with that part of the process... (I'm a KiCAD 5 user)...
@PhilsLab
@PhilsLab 3 жыл бұрын
I've got a video on hardware/PCB design with KiCad + STM32, which goes over the necessary steps to get the JLCPCB assembly done.
@rpourzia
@rpourzia 3 жыл бұрын
I don't see the moving average implementation as shown in the video in the github repository. Only the FIR filter. Has that code been pushed?
@richardamullens
@richardamullens 3 жыл бұрын
Thank you. If one implements a 10 point moving average filter (at least by averaging the 10 values and dividing by 10) then it will lag by 10 points from the raw data - but in your video they seem to be in step. How does one handle this ? Is it just a matter of suppressing the 9 most recent values in the raw data ? Of course it is no big issue if one just wants to display the air pressure if it is a delayed by a fraction of a second. A long time ago I read Digital Filters by R. W. Hamming - a nice elementary book in my opinion. In the book he covers smooth nonrecursive filters. Would you prefer one of those to a simple averaging ? I know that the coefficients are larger and this might cause overflow. I had not until today heard of the SPL06 - but perhaps it is cheaper than the MS5611 I have used in the past. Thank you for reviving my interest in pressure sensors and for this series of videos.
@warpigs330
@warpigs330 3 жыл бұрын
The average includes the most recent sample, so it effects the output immediately, but not drastically.
@Ryezn5057
@Ryezn5057 3 жыл бұрын
Great video. Are you using a blue yeti mic?
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you, Mustafa! I'm using a fairly cheap 't-bone' mic from thomann.
@martinkjellstrand4071
@martinkjellstrand4071 3 жыл бұрын
So - question: What would be the difference between this and just having an average of the last 10 samples? Or am I missing the point?
@PhilsLab
@PhilsLab 3 жыл бұрын
Yeah, that's pretty much it - it's just an average of the last M samples!
@ikbendusan
@ikbendusan 3 жыл бұрын
how does the performance of this compare to an infinite impulse response low pass filter? (which is similar to an RC filter)
@odissey2
@odissey2 Жыл бұрын
The Moving Average filter is a second worst after Exponential filter. The frequency response of the EF of the with alfa=1/N, is about the same as for MA filter of length 2N. However, the MA filter settles in a finite time 2N, while EF takes ~8xN to settle (8-bit). The EF goes into the limit cycle for large N, the MA has no such problem. The MA filter has linear phase response, and EF is a nonlinear phase. MA filter is symmetrical, EF is not, etc..
@uma_k_k
@uma_k_k 2 жыл бұрын
Can you please share the IDE file?
@prashantajabe6636
@prashantajabe6636 3 жыл бұрын
Phill can you suggest books for learning signal and systems?
@thomasdeniffel2122
@thomasdeniffel2122 3 жыл бұрын
The book from Oppenheim is great and comes with the MIT OCW Course for free
@chasingcapsaicin
@chasingcapsaicin 3 жыл бұрын
seems to pick up your voice, convoluted microphone, probably wouldn't sound like a voice but would be neat to output to an audio of some sort
@NuttyforNissan
@NuttyforNissan 3 жыл бұрын
I thought the same, small changes in pressure.
Z-Transform - Practical Applications - Phil's Lab #27
26:02
Phil’s Lab
Рет қаралды 55 М.
FIR Filter Design and Software Implementation - Phil's Lab #17
30:35
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 22 МЛН
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 72 МЛН
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 14 МЛН
6 Horribly Common PCB Design Mistakes
10:40
Predictable Designs
Рет қаралды 217 М.
Moving Average Filters in DSP
10:51
dspGuru
Рет қаралды 10 М.
[#5] IIR Filters - Audio DSP On STM32 with I2S (24 Bit / 96 kHz)
26:33
YetAnotherElectronicsChannel
Рет қаралды 78 М.
Experimenting with Buses and Three-State Logic
18:43
Sebastian Lague
Рет қаралды 617 М.
Overview of FIR and IIR Filters
12:27
Barry Van Veen
Рет қаралды 352 М.
How To Improve Your PCB Designs (Common Mistakes) - Phil's Lab #18
9:27
Top 5 Beginner PCB Design Mistakes (and how to fix them)
12:52
Altium Academy
Рет қаралды 237 М.