"Kasterborus" <kasterborus at (no spam) yahoo.com> wrote in message
news:745aed1a-fbee-4b02-ad46-0f25d4e409e8 at (no spam) k37g2000hsf.googlegroups.com...
I just hooked up a Sharp GP2D12 IR range sensor to a scope and saw
that the output is very noisy. The sensor updates at 25Hz so I was
thinking that if I were to add some kind of 25Hz low pass filter to
the output that would clean things up.
Datasheet:
http://www.philohome.com/sensors/gp2d12/gp2d12-datasheets/gp2d12.pdf
The sensor also operates at 0-2.45v so a gain of 2 from the filter
would be useful to bring it in line with the 5v range of my ADC.
I thought about this circuit
http://www.radio-electronics.com/info/circuits/opamp_low_pass_filter/op_amp_lowpassfilter.php
But it is unity gain - could it be modified to give a higher gain?
Dave
You can use this page to design the analog filter:
http://www.analog.com/Analog_Root/static/techSupport/designTools/interactiveTools/filter/filter.html
It allows you to set the gain to be whatever makes sense, and computes
the right component values.
However, if you are interfacing with a microcontroller, then you might
want to use a digital filter instead. You can easily average the output
over time, and save on the external components. You still need an RC
filter to eliminate high frequency noise, since a digital filter will
alias frequencies higher than 1/2 the sampling frequency into the
baseband if you don't filter them out. You can control the gain with a
digital filter as well. There are websites that will design any kind of
digital filter for you (i.e., a java app). They usually use floating
point, though. For this application, I've used a simple RC filter, along
with an averaging loop like this:
forever {
while (!sample_available()) {
do_something_else();
}
average = (average << 3) - average + get_sample();
average >>= 3;
// do something with the average here
}
This gives each sample an exponential decay.
If that simple filter doesn't work, there are lots of others to choose
from. The choice of filter will depend on the application.
Regards,
Bob Monsen
Ditto all of this, except that if most of the noise is coming from the