# How to smooth a signal with a higher order filter?

I know how higher order filter affects the system, theoretically. The slope of frequency Response becomes steeper as its order increases. I had some speed signals from work. I wanted to investigate more about this, So I designed a $N^{th}$ order $PT1^n$ filter(multiple PT1 filter concatenated in parallel) and a $N^{th}$ order Butterworth filter. I just cannot understand how the stuff I read theoretically applies here.

1st to 3rd order $PT1^n$ filter:

1st to 3rd order Butterworth filter:

Time is in seconds and the signal is in rpm.

These are real signals. It seems to me that as the order is being increased, it's increasing the phase shift to increase the noise reduction. I want to figure out if increasing the order of the filter is worth the hassle, as the order increases the complexity increases and needs more computational power, too.

The main purpose of my filtering is to smooth the signal and remove those steps. How much will I benefit I will get by increasing the order of the filter, mathematically and practically?

• What are the axes? – Chu Sep 28 '16 at 11:29
• Time(sec) and signal(rpm). – user5603723 Sep 28 '16 at 11:33
• Cross posting is uncool. – JRE Sep 28 '16 at 13:21
• why isn't it good? @JRE – Big6 Sep 28 '16 at 18:49
• Where have you set the poles of the filter? Why don't you give an FFT of the signal, make sure your axes labels are correct in frequency. If you want more filtering you'll have to set the poles of the filter lower than the frequencies of the steps if you want more smoothing. – laptop2d Sep 29 '16 at 15:53

As you increase the order of a 'conventional' low pass filter , like a Butterworth response for instance, keeping other things equal, you do increase the phase shift at any frequency.

You say you are trying to remove the steps. 'Remove the steps' describes the general effect of a lowpass filter. Unfortunately, it still doesn't provide a specification.

There are several parameters that describe a lowpass filter.

The first is bandwidth, the inverse of which is the 'length' of the impulse response for some definition of length. A small bandwidth has a long impulse response, which will 'smear out' the original signal.

The second is order, or steepness of rolloff in the stopband. Communication filters that must reject adjacent signals often have a high order. Data smoothing filters often have a low order.

The third, or should it be the zeroth, is the type of filter. Causal or acausal, Butterworth, Cheby, Gaussian, Elliptic or Bessel, FIR or IIR.

Sometimes, filters are designed by choosing a specification in terms of the above, and implementing it. Often though, especially with data smoothing, you don't know quite what you want, and need to see it to know whether it's right.

You seem to be troubled by the increasing delay as you increase the filter order. This makes me suspect that what you want is a filter with a flat group delay, this is, a centred response.

The very simplest of these is the so-called box-car filter. The output at point n is the average of all samples between points n-m and n+m, where m is an integer parameter you can tune for smoothness. Small m is little smoothing but features not smeared much, big m is much smoothing with features smeared out greatly. This is easy to implement in Excel for instance, if you know how to 'fill down' cells. This is not a computationally efficient way of doing it, but that rarely matters at this stage of the design process. Obviously the programming is trivial in your language of choice.

The next simplest is the triangular filter, which you can implement as a second iteration of the box-car. You could iterate more times, if you wanted, though I doubt you will find that's necessary. The filter response approaches Gaussian as the number of iterations approaches infinity BTW.

If you want to see the effect of a centred filter, and don't want to re-write whatever you have done too much, you could run your existing filter, reverse the output time series, and run it again. Such a filter is always symmetrical. Neat trick, huh?

• I wanted to do that, but i thought of creating some hypothesis about what should happen if i do that. And when i actually do that i can cross check if it actually happened or not. – user5603723 Sep 28 '16 at 13:39
• I am trying to smoothen the signal, like remove the step's. – user5603723 Sep 28 '16 at 16:58
• i have edited the question. Can you please check – user5603723 Sep 29 '16 at 7:22
• @user5603723 I have re-written my answer, can you please read. – Neil_UK Sep 29 '16 at 8:00
• Sorry for delayed response, I actually had this idea of using other filters which does the job little better. But the team wants to use the same filters i have mentioned. They just want a result of "is going higher order of low pass filter" benefiting for smoothing the steps. – user5603723 Sep 30 '16 at 6:02

Group Delay is defined as the rate of change of phase shift over a signal bandwidth.

Here you show a declining ramp with quantization noise added. Since a filter cannot predict what occurs in the next sample, it stores energy and gives a moving average according to the filter slope order in terms of 6 db/octave per N order of magnitude of filter in frequency domain which results in more phase shift rate of change and group delay.

If the actual noise is close to the half the sampling interval then it can introduce further error due to Nyquist Theory called aliasing and must be notched out and then rolled off steep below 1/2 the sampling rate to minimize the error on the ramp. Often 1/3 of quantization frequency is used for rolloff point.

If the noise is near the corner frequency of the filter of the LPF then maximally flat group delay filters are used such as BESSEL or LINEAR PHASE with EQUIRIPPLE ERROR of 0.05°.

If doing analysis by software, you can anticipate changes and do a moving average then move back in time by N samples being averaged in duration.