# Help choosing coefficients for a simple FIR filter to extract DC component

I am a beginner in design of digital filters... I have just completed Coursera's Linear Circuits course!

I have a signal which is sampled at 50 Hz where the DC component has a value of 800000 and there is some noise with a standard deviation of around 200. The DC component should remain constant but it may change very slowly over time.

I want to design a simple FIR filter to obtain the DC component: would a simple weighted average algorithm be most appropriate? How do I go about choosing suitable coefficients?

## 1 Answer

MA is almost never a "most appropriate" algorithm (it's only advantage is simplicity). My advice is to choose Gaussian filter which has least possible group delay. Calculate its coefficients keeping in mind that cut-off frequency of a Gaussian filter is $$f_0 = \frac{1}{2 \pi \sigma}$$ Estimate which variances of low frequency component you'd like to preserve in your application, which are acceptable to be attenuated to 50%, this will give you desirable cut-off frequency.

• Thanks for this idea. I tried playing around with gaussdesign in Matlab, which has 3 parameters: BT (3-dB bandwidth-symbol time product), SPS (samples per symbol) and span. The filter size is equal to SPS*span + 1. For example, parameters (0.05,2,8) produces a filter which gives reasonably good results. But I am still selecting parameters by trial and error. I plan to do the DSP course on Coursera to try to improve my understanding of the theory but in the meantime any pointers on how to select parameters in a more principled way are welcome! – Slithy May 5 '15 at 10:05
• Exact parameters are based on specific requirements of your application. If you don't have anything specific, "reasonably good results" is fine. Remember that you make trade-offs between noise suppression and sensitivity to DC component variations. When both are acceptable, you're done. – Yuri Nenakhov May 6 '15 at 18:57