1
$\begingroup$

I'm looking for a tool\method which allows me to design a filter without involving the frequency response at all.
Specifically, I'm trying to design a simple FIR smoothing filter for an emmbedded system which reads different analog sensors. My sampling rate is 1kHz and I'd like to generate an FIR filter with 0-overshoot and a smoothing effect (e.g. in attached pic). enter image description here

The different tools I found (including MATLAB) all involved a design around a LP filter, which means I have to analyze the frequency response of my system.

Any relevant tools\methods out there?

$\endgroup$
2
$\begingroup$

For linear filters, binomial filters, which can be considered as FIR approximation to Gaussians, are very simple. Their coefficients are given by: $$ h_k=\frac{ \binom{n}{k}}{2^n} \,.$$ For instance, you can get $H_3 = [ \frac{1}{4},\frac{1}{2},\frac{1}{4}]$, or $H_5 = [ \frac{1}{16},\frac{1}{4},\frac{3}{8},\frac{1}{4},\frac{1}{16}]$. Since their coefficients are positive, they do not overshoot.

Here are graphs for $n = 5,17,25,31$:

Step responses

Savitzky-Golay filters, performing polynomial interpolation, are interesting too, but tend to overshoot with higher degrees.

Do not fool yourself though: as long as the filters are linear, there is a notion of frequency very close behind.

$\endgroup$
  • $\begingroup$ Thats helpful, but still doesn't reference the step response of the filter. $\endgroup$ – user1843913 Mar 2 '16 at 8:34
  • 1
    $\begingroup$ @user1843913 : "Step response" is only referenced in your question title. Laurent's answer has shown all the step responses for various values of $n$. What more do you want? $\endgroup$ – Peter K. Mar 2 '16 at 15:20
  • 1
    $\begingroup$ @Peter K. from computed step responses, one could compute some figures like rise time, overshoot (though I am not sure there are universally acceted formulae). One might want to do the reverse: from those figures, find the optimal (shortest) FIR. I am feeling dry right now on the topic, and am prone to brute force... $\endgroup$ – Laurent Duval Mar 2 '16 at 16:51
1
$\begingroup$

Designing an FIR filter with a given step response is very easy. Since

$$a[n]=\sum_{k=-\infty}^nh[k]\tag{1}$$

where $a[n]$ is the step response, and $h[n]$ is the impulse response, the impulse response can be obtained from the given step response by

$$h[n]=a[n]-a[n-1]\tag{2}$$

For a causal filter, you have $a[-1]=0$ as initial condition for the recursion $(2)$. So you get

$$h[0]=a[0]\\h[1]=a[1]-a[0]\\h[2]=a[2]-a[1]\\\vdots$$

$\endgroup$
  • $\begingroup$ You are correct, but that's not what I was looking for. I'm looking for a way to build the entire step response (and corresponding filter) using only the step response parameters, such as overshot and rise time. $\endgroup$ – user1843913 Mar 1 '16 at 21:48
  • 2
    $\begingroup$ @user1843913: It might be a good idea to reformulate your question because I think it's no coincidence that both answer don't answer your actual question. In your question you said you wanted zero overshoot and you showed an example of a desired step response. You have to think about your design goal. How do you define your error that you want to minimize? Overshoot and rise time are just side constraints, but they can't be used as the only design parameters because they will leave you with infinitely many filters satisfying your constraints. $\endgroup$ – Matt L. Mar 2 '16 at 9:09
  • $\begingroup$ You may be right.. Anyway, from wiki step response: Instead of frequency response, system performance may be specified in terms of parameters describing time-dependence of response. The step response can be described by the following quantities related to its time behavior, overshoot rise time settling time ringing. And any filter that works for this specs will do. $\endgroup$ – user1843913 Mar 2 '16 at 13:47
  • $\begingroup$ @user1843913: I think you haven't understood that you can dream up absolutely any step response and realize it with zero error using the procedure outlined in my answer. If the only design criteria are the ones you named then you can realize anything that you like with a FIR filter. However, this shows you that your design criteria are insufficient. How will you guarantee that the realized filter is a good smoothing filter? As I said previously, you need some error criterion which you minimize, subject to constraints on the step response. $\endgroup$ – Matt L. Mar 4 '16 at 11:39
0
$\begingroup$

You might want to check into the formula for and naming of the binomial coefficients. It threw me off when I tried to reproduce your results until I realized the problem. My post is in the spirit of helping others who read it.

H0 is the first row of the Pascal's triangle, containing only a single '1'. H1 contains '1 1', H2 contains '1 2 1' and so on. Thus, H4 contains '1 4 6 4 1', yielding the coefficients that you specified for H5. I think that the expression should be

  hk = (n-1 pick k)/2^(n-1) for v from 0 to n-1

where n is the number of coefficients that you want in the filter. This would give your answers above.

The issue is is that both k = 0 and k = n-1 are included and so (n, pick k) for k from 0 to n yields n+1 coefficients, and so this belongs to Hn+1, not Hn.

Alternatively, you could redefine what you mean by Hn but this is less intuitive. H5 meaning 5 coefficients seems natural to me, as apparently it did to you.

Best regards,

Peter

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.