Talk:Low-pass filter

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Discrete-time realization - How to derive the formula "(1-alpha)"?[edit]

How do you get from this:

to this:

??

I can't figure it out. --86.14.215.103 (talk) 23:21, 29 September 2012 (UTC)

It is simple algebra. Try working backwards, which has a more straightforward substitution. That is, substitute the expression for α into the second expression and the result should be the first expression. SpinningSpark 10:13, 30 September 2012 (UTC)
I tried working backwards but I still can't do it. I end up with two on the right hand side in the 2nd equation, but there is only one in the first equation. Can someone please show the steps to derive the "(1-α)" part. I'm also confused why it is -alpha instead of +alpha, when there are no negative terms in the first equation.--86.14.215.103 (talk) 13:45, 30 September 2012 (UTC)
We wish to show that,

 

 

 

 

(Eq. 1)

dividing top and bottom of the LHS by RC,

 

 

 

 

(Eq. 2)

From the definition of α, and dividing top and bottom by ΔT,

 

 

 

 

(Eq. 3)

Rearranging,
or,

 

 

 

 

(Eq. 4)

Substituting Eq. 4 into Eq. 2,

 

 

 

 

(Eq. 5)

as required.
SpinningSpark 15:15, 30 September 2012 (UTC)


Ah that's great, thanks! I think I understand now. The key point is your Equation #3. There may be an easier way to derive (1-alpha) without working backwards:

... Equation 6

Now from Equation 3:

 

 

 

 

(Eq. 3)

Rearrange Eqution 3:

... Equation 7

Substitute Equation 7 into equation 6:

as required.
Should this derivation be included in the article?

No. SpinningSpark 19:18, 30 September 2012 (UTC)

High attention cross reference needed?[edit]

Why do we need a "See also" notice in the beginning? Shouldn't it just be in the "See also" section? --Mortense (talk) 14:43, 24 December 2013 (UTC)

Don't see any particularly good reason for that, I have reverted it. Not sure we need it as a see also at all, it is already in the navbox at the bottom and is linked from the lede of the article. SpinningSpark 18:58, 24 December 2013 (UTC)

lowpass pseudocode[edit]

function lowpass(real[0..n] x, real dt, real RC)

   var real[0..n] y
   var real α := dt / (RC + dt)
   y[0] := α * x[0]
   for i from 1 to n
       y[i] := α * x[i] + (1-α) * y[i-1]
   return y

Shouldn't it be:

function lowpass(real[0..n] x, real dt, real RC)

   var real[0..n] y
   var real α := dt / (RC + dt)
   y[0] := x[0]
   for i from 1 to n
       y[i] := α * x[i] + (1-α) * y[i-1]
   return y  — Preceding unsigned comment added by 31.10.136.212 (talk) 22:18, 12 April 2020 (UTC) 

A more commonly accepted difference equation[edit]

My interest in this article stems from my participation in the Ardupilot project which implements a digital low-pass filter according to the "Discrete-time realization" section of this article. I immediately noticed that it disagreed with every other implementation I had encountered.

I have added several sections to derive the more commonly accepted difference equation for the low pass filter. I will be adding an "Error Analysis" section which appears to be missing from the current "Discrete-time realization" section. The major difference between the two difference equations is the value of α = ωT/(ωT + 1) vs. β = exp(-ωT). It should be noted that using β in the difference equation yields an exact reconstruction of the step response whereas using α yields an error based on the corner frequency, ω, and the sampling interval, T, making β more desirable.

One problem I am having is that I am not able to upload pictures to the article. It keeps complaining that it can't verify the picture's integrity or something like that. I would like to upload the Time Response graph of the low-pass filter so if anyone can help me with that I would appreciate it.

--Kraybill (talk) 18:49, 24 July 2020 (UTC)

I emailed you about how I might help on image upload. Or just say more here about what problem you are seeing. On the article changes, it would be nice to see a better integration, instead of duplicating a lot of stuff with a modified approach. I'm familiar with the impulse invariance method, but not with a step invariance method; is that an approach that you have sources on? Ah, yes, it is; here. I believe your result is also what one would get by the Matched Z-transform method, at least for this filter if not more generally. Dicklyon (talk) 19:25, 24 July 2020 (UTC)
Excellent link! I did not know the name of the step invariance method. Doing a Google search I found this paper on step and ramp invariant filters. If I have time, I may attempt the ramp invariant solution. For now, I will add a small error analysis section then move on to multiple pole analysis. Thanks for your input! One more concern, since we know that the "Discrete-time realization" section's difference equation is less accurate, should we challenge or delete that section? --Kraybill (talk) 21:02, 27 July 2020 (UTC)
I don't think "less accurate" is the right characterization. It's a different method of making a discrete-time filter from a continuous-time filter. Comparing a few methods might be good. Dicklyon (talk) 21:44, 27 July 2020 (UTC)
I should put some math behind my statement: Let's call the 2 methods α and β after their respective constants. Both have the same overall form so the only difference between them is the value of α vs. the value of β. Let's evaluate β first. The error is simply the difference between the step input time response, vout(t) = Vi(1 - exp(-ωt)), and the reconstructed output using the difference equation. We only need to evaluate the terms at t=T to determine the error. So the time response at t=T is Vi(1 - exp(-ωT)) which is equal to that of the β method yielding a 0% error for the β method. This should be no surprise since the β method was designed that way. On the other hand, at time t=T the α method produces a value of Vi*T/(RC + T) ≠ Vi(1 - exp(-ωT)). Since T > 0 there will always be an error in the reconstructed signal for the α method, hence the α method is always "less accurate". We can look at the α method as a low-pass filter with the wrong corner frequency! For example, with ω=2π (1 Hz) and T = 0.01 (100Hz) the α method yields an error of E = 100*(β - α)/β = 2.9%, whereas the β method yields 0% error. At minimum, the α section should be edited to point out the approximation xi - yi = RC y(i)-y(i-1)/T as xi - yi RC y(i)-y(i-1)/T, and include an expression for the difference equation's time response error. --Kraybill (talk) 15:29, 28 July 2020 (UTC)
Matching the step response is one method. Matching the impulse response is a different method (which actually yields a pole and zero in this case, if done correctly). Depending in what you want to match, you get different results. I'm not sure of the properties of the other method described at present, but it might be doing something good. Dicklyon (talk) 15:46, 28 July 2020 (UTC)