learn to Design software filters - Page 1
Forum section: electronics / beginners

author: A2
author_rank: Contributor
timestamp: July 29, 2014, 04:32:03 pm
content: Hi,I want to learn how to design software filters in embedded. I have two scenario's in it:a). sample a ac signal with freq of 50Hz. So I need to design a band pass filter which can only allow freq around 50hz to pass through, rest all must be rejected.b). sample a dc signal i.e zero freq. So design a low pass filter which only allow freq near 0 Hz to pass.1. I am not asking anyone to design these for me.2. I want to learn them how to do that it in microcontroller.3. I tried to search them on on internet but they all take to DSP & I couldn't understand the relationship. as it includes complex maths & no where i see link to microcontroller.4. After some searching I found this:http://coactionos.com/embedded%20design%20tips/2013/10/04/Tips-An-Easy-to-Use-Digital-Filter/5. Can someone point to weblink where I can learn like if have to design a filter in context of applying i in a microcontrollera). At what freq should I sampleb). how many samples to takec). FIR or IIR, which will suit me?

author: Kremmen
author_rank: Super Contributor
timestamp: July 29, 2014, 05:48:06 pm
content: I don't wish to rain on your parade or piss in your beer or whatever a suitable saying might be. Nevertheless, you are asking a classical format rookie question that presupposes there is a boilerplate answer to your requirements. Unfortunately that is not the case.You say you want to _learn_ how to implement embedded software filters. Disregarding magic cookbook recipes where no learning is involved, the answer to that question is definitely rather involved - you first need to acquire the fundamentals of digital signal processing and then apply that knowledge to implement the filter. As a complete topic signal processing is a vast one, easily filling a lifetime. Fortunately digital filters can be - if not mastered then maybe at least apprenticed in less time than that. But make no mistake; it will be a considerable effort if you mean to actually understand what you are doing, instead just replicating a recipe by rote.Assuming you wish to understand, at minimum you need to familiarize with concepts such as signal spectra, sampling (in the information theory / signal processing sense, not circuit design), discrete Fourier transform and discrete _time_ Fourier transform, finite and infinite signal sequences, the complex exponential, Laplace and Z transforms, convolution, stability and the list goes on.I'm sure someone will comment that all of the above is not needed in order to implement a filter and maybe that is true. But then you will be cooking to a given recipe without true understanding. If that is enough then fine. If not, maybe this could be interesting:https://www.edx.org/course/ricex/ricex-elec301x-discrete-time-signals-1032#.U9fb_vmSyPE. Bear in mind that writing the actual code will be your least issue. It is controlling the behavior of the filter that you need all the boring theory for. The link you included has some elements of theory but nowhere enough for true understanding.But then not everyone has what it takes to acquire the true understanding - it is not easy.

author: Rory
author_rank: Frequent Contributor
timestamp: July 29, 2014, 08:01:31 pm
content: I'm going to second Kremmen's statement about needing to acquire the fundamentals of DSP before you can learn how to implement them. I'm going to add that you also need to understand the fundamentals of analog signal processing as well - for in many cases the DSP implementation closely correspond to its analog counterpart. Also understand that unless you can conquer some serious calculus, there is no way you will be able to decipher the algorithms the propellerheads proudly publish in order to impress each other.That being said, here's something to read if you want to get your feet wet.http://www.dspguide.com/

author: Rasz
author_rank: Super Contributor
timestamp: July 29, 2014, 08:23:13 pm
content: https://www.coursera.org/course/dsp

author: qno
author_rank: Frequent Contributor
timestamp: July 29, 2014, 09:00:15 pm
content: You can easily get some idea of filtering by try some stuff in excel.Make a graph of it and and you can see what happens to the signal.The big advantage of digital filters is that you can look forward or back in time.Take a table with data. By averaging 2, 3,4 etc samples you can make a low pass filter.By just plotting the difference between 2 samples you can make a high pass filter.Then you can goto to the cookbook and see what the more advanced algorithms will produce.Tweek some parameters and see what happens.

author: hamster_nz
author_rank: Super Contributor
timestamp: July 30, 2014, 12:01:25 am
content: The Scientist and Engineer's Guide to Digital Signal Processinghttp://www.dspguide.com/pdfbook.htmEsp chapters 14 thorugh 21.Just make a windowed sync filter of your dreams, > 70db in the stop bands, +/- 0.05HZQuotea) You are filtering for 50Hz, so you want a sample rate (S) such that the front end filter reduces frequencies of (S-50) well below the level of interest. E.g. if you sample at 1000 Hz any 950Hz signal will alias down to 50Hz, so the filter before the ADC needs to be -0db (or close) at 50Hz and -50db at 950Hz if you are using 8-bit samples (which have 48db of dynamic range)WIth that filter in place a full range 950Hz signal will introduce under one LSB of 'false' signal. This requires an analogue filter with at least a 10 db / ocatve cutoff in front of the ADC. Good luck with that :-)b) You need all of them, and you get 3db of dynamic range per bit (8 bits give 48 db range, 16 bits gives 96 db range). Once you have brick-wall filtered to just above 50Hz you can decimate samples down to something like sample rate of 150 S/s without losing information or introducing additional false signals.c) FIR if you can, IIR if you can't. FIR requires lots of horsepower but can give awesome results. If you push IIR too hard it will blow up on you (e.g. it gets unstable and small errors overwhelm the filter).

author: Kremmen
author_rank: Super Contributor
timestamp: July 30, 2014, 02:09:55 pm
content: Quote from: Rasz on July 29, 2014, 08:23:13 pmActually i did that one for fun. Usually i do aim for the certificate even though i have no use for them. This time work pressures prevented taking the time for homework for which i am still a bit miffed. But never mind, the course was good and if Prandoni and Vetterli decide to re-run it, i definitely recommend it.And i just recalled that there was a textbook associated with the course, freely downloadable fromhttp://www.sp4comm.org/getit.html. Perhaps the OP would like to look into that. Although it is not the end-all of signal processing it is a relatively coherent introduction to some of the core subtopics of the art.