Hobby Electronics Basics Looking to filter the noise on a Sharp IR sensor

Bookmark this page:  YahooMyWeb Yahoo!  Google Google  Windows Live Favorites Windows Live  del.icio.us del.icio.us  digg digg  Add to Netscape Netscape
Subject Author Date
Looking to filter the noise on a Sharp IR sensor Kasterborus 05-26-08
Posted by Kasterborus on May 26, 2008, 6:45 pm
Please log in for more thread options
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

Posted by Bob Monsen on May 26, 2008, 7:30 pm
Please log in for more thread options
>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


Posted by Tim Wescott on May 27, 2008, 12:50 am
Please log in for more thread options
Bob Monsen wrote:
>> 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
detector, and if the detector is really updating at 25Hz, and if you can
sample synchronously with that 25Hz update, then an anti-alias filter
probably won't do much good.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html

Posted by Kasterborus on May 27, 2008, 7:40 am
Please log in for more thread options
Thanks for the suggestions - I'll give them a try.

Posted by Bob Monsen on May 27, 2008, 7:21 pm
Please log in for more thread options
> Thanks for the suggestions - I'll give them a try.


Ah, one other thing, those sharp sensors take a big current spike when they
power the LED. Depending on your setup, you may actually be seeing the
spikes on your A/D input.

The solution for this is a big cap (like 100uF) near the power inputs for
the sensor, which will smooth the power supply.

Note that this only matters if you are using a small supply that can't keep
up. Scope the power input to see if it makes a difference.

Regards,
Bob Monsen


Similar ThreadsPosted
Looking to filter the noise on a Sharp IR sensor May 26, 2008, 6:45 pm
Power Noise Filter question January 25, 2005, 3:01 pm
Volume (decibel) Low-pass filter (NOT frequency filter) October 21, 2006, 5:11 am
sharp aquous hdtv October 3, 2006, 10:14 am
Simple audio band-pass filters with sharp cut-offs November 27, 2005, 12:48 pm
T LP filter and RC LP filter March 31, 2005, 9:33 pm
eni filter September 30, 2007, 11:27 pm
50Hz Filter August 4, 2004, 12:06 am
Filter USB power? July 12, 2006, 11:59 pm
FIR filter length March 16, 2007, 2:20 am
bandpass filter August 29, 2007, 10:23 am
Filter Phase October 10, 2007, 9:22 am
RF Filter PCBs November 3, 2007, 7:12 pm
low pass filter questions... January 20, 2005, 9:28 pm
Is this even possible? Filter/impedance question August 9, 2005, 12:12 am