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.
@GiorgioLZ3 жыл бұрын
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.
@ndanilo3 жыл бұрын
Hey, I'm from the future. And yes he did a couple of videos on Kalman Filter
@MartinWolker3 жыл бұрын
I am use Kalman filter, which is more responsive for pressure data for exanple for variometer
@Gengh133 жыл бұрын
On platforms without division in HW I use exponents of 2 lengths and shifting to minimize computation time, and of course all integers.
@robmurg3 жыл бұрын
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.)
@alessi42493 жыл бұрын
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!
@myetis19903 жыл бұрын
Hi, Phil nice job. Kalman filter implementation would be appreciated. Especially for imu sensor data.
@suncrafterspielt94793 жыл бұрын
Great video, can’t wait for the iir video
@PhilsLab3 жыл бұрын
Thank you very much!
@charlesspringer47093 жыл бұрын
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 :-)
@hamouz7183 жыл бұрын
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 😭
@DonQuichotteLiberia3 жыл бұрын
The BluePhil, classic! :-D Excellent job, thank you for the video.
@PhilsLab3 жыл бұрын
Haha thank you!
@buscoparan17723 жыл бұрын
simple, yet very effective!
@PhilsLab3 жыл бұрын
Thank you!
@andreasmiller54482 ай бұрын
Great video!
@obregr3 жыл бұрын
you are one of the great youtuber
@PhilsLab3 жыл бұрын
Thank you, Gregor!
@masifamu3 жыл бұрын
thank you for this amazing demonstration, it really worked for me
@PhilsLab3 жыл бұрын
Thank you very much, Mohammad!
@charlesgalant82713 жыл бұрын
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
@EdwinFairchild3 жыл бұрын
reminds me of a complimentary filter.
@pablo_costas3 жыл бұрын
@@EdwinFairchild it tells you how pretty you are every 2 samples
@fano725 ай бұрын
Yeah the IIR approach is more feasible I think.
@MusaYmc Жыл бұрын
This is tremendous!
@PhilsLab Жыл бұрын
Thanks!
@ahmedalshalchi3 жыл бұрын
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 ...
@gpcm3 жыл бұрын
Good stuff! You should do a kalman filter next
@Εὐκλείδης300 Жыл бұрын
Thanks!
3 жыл бұрын
Thank you for sharing.
@Electronics_Dreams3 жыл бұрын
Amazing video again! Thanks!!
@PhilsLab3 жыл бұрын
Thank you, Gaston!
@lucvanhove96393 жыл бұрын
This is very interesting.
@PhilsLab3 жыл бұрын
Thank you!
@pietrogagliano44843 жыл бұрын
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-tw9bl3 жыл бұрын
same here! how is the course going?🙈
@JorgeSilva-em8pf2 жыл бұрын
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.
@mspinksosu2 жыл бұрын
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?
@matheuspimenta84863 жыл бұрын
would it be possible to do a sinc2 filter with the same approach of this moving average?
@IEEEclipse3 жыл бұрын
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 🙃
@NivagSwerdna3 жыл бұрын
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)...
@PhilsLab3 жыл бұрын
I've got a video on hardware/PCB design with KiCad + STM32, which goes over the necessary steps to get the JLCPCB assembly done.
@rpourzia3 жыл бұрын
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?
@richardamullens3 жыл бұрын
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.
@warpigs3303 жыл бұрын
The average includes the most recent sample, so it effects the output immediately, but not drastically.
@Ryezn50573 жыл бұрын
Great video. Are you using a blue yeti mic?
@PhilsLab3 жыл бұрын
Thank you, Mustafa! I'm using a fairly cheap 't-bone' mic from thomann.
@martinkjellstrand40713 жыл бұрын
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?
@PhilsLab3 жыл бұрын
Yeah, that's pretty much it - it's just an average of the last M samples!
@ikbendusan3 жыл бұрын
how does the performance of this compare to an infinite impulse response low pass filter? (which is similar to an RC filter)
@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_k2 жыл бұрын
Can you please share the IDE file?
@prashantajabe66363 жыл бұрын
Phill can you suggest books for learning signal and systems?
@thomasdeniffel21223 жыл бұрын
The book from Oppenheim is great and comes with the MIT OCW Course for free
@chasingcapsaicin3 жыл бұрын
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