Author Topic: learn to Design software filters  (Read 3597 times)

0 Members and 1 Guest are viewing this topic.

Offline A2Topic starter

  • Contributor
  • Posts: 44
learn to Design software filters
« on: July 29, 2014, 04:32:03 pm »
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 microcontroller
a). At what freq should I sample
b). how many samples to take
c). FIR or IIR, which will suit me?
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: learn to Design software filters
« Reply #1 on: July 29, 2014, 05:48:06 pm »
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.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Rory

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: us
Re: learn to Design software filters
« Reply #2 on: July 29, 2014, 08:01:31 pm »
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/
 

Offline Rasz

  • Super Contributor
  • ***
  • Posts: 2616
  • Country: 00
    • My random blog.
Re: learn to Design software filters
« Reply #3 on: July 29, 2014, 08:23:13 pm »
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: learn to Design software filters
« Reply #4 on: July 29, 2014, 09:00:15 pm »
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.

Why spend money I don't have on things I don't need to impress people I don't like?
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: learn to Design software filters
« Reply #5 on: July 30, 2014, 12:01:25 am »
The Scientist and Engineer's Guide to Digital Signal Processing

http://www.dspguide.com/pdfbook.htm

Esp chapters 14 thorugh 21.

Just make a windowed sync filter of your dreams, > 70db in the stop bands, +/- 0.05HZ

Quote
a). At what freq should I sample
b). how many samples to take
c). FIR or IIR, which will suit me?

a) 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).
« Last Edit: July 30, 2014, 12:22:30 am by hamster_nz »
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: learn to Design software filters
« Reply #6 on: July 30, 2014, 02:09:55 pm »
https://www.coursera.org/course/dsp
Actually 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 from http://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.
Nothing sings like a kilovolt.
Dr W. Bishop
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf