0
$\begingroup$

I tried to use bessel filter from here, but in the case of a large dataset, I have overshoot. Since I know a bessel filter shouldn't have overshoot, is this code wrong or am I doing something else wrong?

// Sample rate : 1e9
// Cut off Frequency : 50e6

int s=50000;
double[] sample = new double[s];

for(int i=s/2; i<s; i++) {
  sample[i] = 1.0;
}

for (int i = 0; i<sample.length; i++) {
    xv[0] = xv[1];
    xv[1] = xv[2];
    xv[2] = xv[3]; 
    xv[3] = sample[i] / GAIN;
    yv[0] = yv[1]; 
    yv[1] = yv[2]; 
    yv[2] = yv[3]; 
    yv[3] = (xv[0] + xv[3]) + 3 * (xv[1] + xv[2])
          + (  0.3402988787 * yv[0]) 
          + ( -1.4152725242 * yv[1])
          + (  2.0223552191 * yv[2]);
    filteredValue[i] = yv[3];
}

All coefficients have been calculated based on source on given website, it might been messy because its used for chebyshev and butterworth filters as well.

$\endgroup$
4
  • $\begingroup$ More information would be helpful. Do you have example code or at least a plot that could show what you're asking about? $\endgroup$
    – Jason R
    Commented Aug 14, 2012 at 15:21
  • $\begingroup$ example of code you have on website what i used, it automatically generated filter for given parameters. In my case parameters does not different, my graph has large overshoot if i use large dataset (100k elements, for smaller set (50 elements) overshoot is smaller, barely noticeable $\endgroup$
    – user902383
    Commented Aug 15, 2012 at 10:29
  • $\begingroup$ You need to provide much more information than you've given in order to get a good answer. We can't tell if you've done something wrong unless we see some indication of what you've actually done. While the linked page does generate C code that can implement a filter, it is not complete. A full example, or at the bare minimum, plots of what you're seeing would be needed. $\endgroup$
    – Jason R
    Commented Aug 15, 2012 at 12:48
  • $\begingroup$ unfortunately i cant add plot because i dont have required reputation $\endgroup$
    – user902383
    Commented Aug 15, 2012 at 14:59

1 Answer 1

5
$\begingroup$

It's not exactly clear what you mean by overshoot. Let's define it as "when filtering a square wave, the max of of the the output should not exceed the steady state of max of the square wave".

In this case your statement "as i know bessel filter shouldnt have overshoot" is wrong. A bessel filter will indeed overshoot. A few first order filters will not overshoot (butterworth, chebychev, ...) but any filter of order > 1 will overshoot.

$\endgroup$
3
  • 1
    $\begingroup$ +1: A Bessel filter does overshoot. However, there are a few other filters of order >1 that don't overshoot. $\endgroup$
    – David Cary
    Commented Aug 20, 2012 at 15:46
  • $\begingroup$ Gaussian filters don't overshoot (but also require predicting the future) $\endgroup$
    – endolith
    Commented Mar 29, 2016 at 0:03
  • $\begingroup$ Bessel filters tend to have a very slight overshoot which is "felt" for the lower orders. As higher orders come into play, the overshoot converges towards zero, more precisely the filters converges towards an ideal delay, exp(-s). Here's a step response for a sweep from N=2..20: imgur.com/SVgSse0 . Gaussian filters do not overshoot, but precise matching is required for any of its approximations of any order (though matching is true for any filter). $\endgroup$ Commented Sep 30, 2016 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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