Low Pass Filter in Software question

In summary, the conversation discusses implementing a low pass filter in software using an equation provided by Barry L. Dorr. The equation includes a filter strength, k, and an input term, x(n), which the speaker has trouble understanding. They also mention implementing a high pass filter and discuss the effects it may have on their data. The conversation also mentions the gain at low frequencies and suggests a different equation for the low pass filter to achieve a gain of 1 at low frequencies.
  • #1
preimmortal
13
0
Hi Everyone,
I read an article by Barry L. Dorr about how to implement a Low Pass Filter in software, however, the equation that he gave confused me as I didn't see any sort of convergence to the value desired.

So here is the equation:
y(n) = (1 - 2^(-k)) * y(n-1) + x(n)
x is the input, y is the output, n is the index, and k is the filter strength

So I understand how k works as it just makes it so that previous values affect the output less. But where I run into problems is the + x(n) term.

So taking the example where k = 4, I have the equation:
y(n) = 0.9375 * y(n-1) + x(n)

Then I will just create an arbitrary array with which I want to low-pass and smooth out.
So let's say, x(n) = {1, 5, 3, 2}

Then that means,
y(3) = .9375 * y(2) + x(3) = 8.031 + 2 = 10.031
y(2) = .9375 * y(1) + x(2) = 5.5664 + 3 = 8.5664
y(1) = .9375 * y(0) + x(1) = .9375 + 5 = 5.9375
y(0) = x(0) = 1

So at this point, I can see the the output array is not even converging to getting larger as time goes on, even though the maximum input to low-pass filter was 5.

Any insight on how this works would be great.
 
Engineering news on Phys.org
  • #2
You mean ths article? http://www.edn.com/article/465351-A...filter_suits_embedded_system_applications.php

He "forgot" to tell you that his simple filter has a gain at low frequences. If you see what happens when you filter a constant input signal with all the x(n) values equal to 1, the output values are
1
1 + .9375
1 + .9375 + .9375^2
1 + .9375 + .9375^2 + 9375^3
etc.
This is a geometric series. The output will rise "slowly" and then level off at the value of
1 / (1 - .9375) = 16.

Note: you will need to get about 50 output values to see the complete picture of what happens.

If you want the filter to have a gain of 1 at low frequencies, use
y(n) = 2^(-k)(1 - 2^(-k)) * y(n-1) + 2^(-k)x(n)
instead.
 
Last edited:
  • #3
Ah yes,
I did notice that when I was running it in my actual software. It would level off at around 16 if I passed in a large array. I will try implementing your low-pass filter with gain of 1 and see how it works out. Thanks.
 
  • #4
Okay I just implemented the low-pass filter and it does have the affect of "smoothing" out my data, now I want to implement a high pass filter for my data. My main question is,
What affect does a high pass filter have on my dataset?
For example, I know that the low pass smooths out data and passes low frequencies (changes?). So applying this logic, does the high pass filter converge more quickly to my data, (ie. pass large changes in data but not small?)
 
  • #5
Short answer: high pass leaves you with the part that low pass removes. If your data are the sum of a low-frequency "signal" and some higher-frequency "noise" then low-pass will tend to filter out the noise, while high-pass will leave you with the noise. (Of course, one person's noise is another person's data, etc., etc...)

The time derivative (changes) is weighted toward high frequencies in a sort of "ramp" rather than providing good "high pass."
 

1. What is a low pass filter in software?

A low pass filter is a digital signal processing technique used to eliminate high frequency components from a signal while allowing low frequency components to pass through. It is commonly used to remove noise or unwanted artifacts from a signal.

2. How does a low pass filter work?

A low pass filter works by attenuating or reducing the amplitude of high frequency components in a signal while passing through low frequency components with little to no attenuation. This is typically achieved by using a combination of resistors, capacitors, and inductors in an electronic circuit.

3. What are the applications of a low pass filter in software?

A low pass filter has a wide range of applications in software, including audio and video processing, image processing, data smoothing and noise reduction, and signal conditioning in communication systems. It is also commonly used in digital signal processing algorithms, such as in digital audio equalizers and audio effects.

4. How do I choose the right low pass filter for my software application?

Choosing the right low pass filter for your software application depends on several factors, including the desired cutoff frequency, the type of signal being processed, and the level of attenuation required. It is important to consider the filter's frequency response, phase response, and group delay to ensure it meets the requirements of your application.

5. Can I design my own low pass filter in software?

Yes, it is possible to design and implement a low pass filter in software using various programming languages and tools. However, it requires a good understanding of digital signal processing techniques and filter design principles. There are also many ready-to-use low pass filter libraries and modules available that can be incorporated into your software application.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
16
Views
965
  • Introductory Physics Homework Help
Replies
6
Views
646
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • General Engineering
Replies
1
Views
2K
  • Mechanical Engineering
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
1
Views
892
Replies
6
Views
1K
  • Electrical Engineering
Replies
6
Views
1K
  • General Math
Replies
1
Views
734
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
Back
Top