I am in the process of building a track robot with the capability of using the SHARP89 2Y0A700 IR. I have begun testing the IR but have been getting back very noisy results. My question for you is how to reduce the noise produced from lights, sunlight etc.
I have heard about using a sort of tubing for the receiver and transmitters as well as some sort of RC filter.
Thank you for your help and sorry if this question has been asked in the past.
How are you powering the sensor, and how are you measuring the noise? In my experience, these sensors are largely immune to noise from ambient IR; are you sure this is the source of your trouble? Have you added the suggested 10+ uF cap across power and ground somewhere near the sensor?
I have just connected the 10uF cap and I am able to obtain desired results but it is unstable. I am using Arduino ATMEGA 328 Duemilanove in addition to MATLAB and Arduino 1.0.1.
Here is the MATLAB code I’m using;
% The pin number where the sensor is connected
analogPin = 0;
% The amount of measurements to record
sampleSize = 100;
% Set up an array to hold the digital numbers and time
data = zeros(100,2);
% Grab an initial reading to set the bounds of the graph
initialReading = a.analogRead(analogPin);
upperBounds = initialReading + 70;
lowerBounds = initialReading - 70;
% Start the timer
timer = tic;
for n = 1:sampleSize
data(n,1) = a.analogRead(analogPin);
data(n,2) = toc(timer);
plot(data(:,2), data(:,1)), axis([0 (sampleSize*0.05) lowerBounds upperBounds]);
hist(data(:,1)), axis([lowerBounds upperBounds 0 sampleSize])
Can you be more specific than “it is unstable”? Can you verify how you have everything connected? Do you have access to an oscilloscope?
I have the IR connected to the Arduino at 5v, Ground and Analog Reading (0) respectively. The Arduino is run through MATLAB.
When I use a.analogRead(0)
I get results that are expected, around 1000. But then I also get instances wherein I get 0 readings. What I believe should happen is stable 1000 readings at all times.
I do have access to an oscilloscope.
I’m skeptical that the sensor output is really dropping to zero periodically. Can you hook the output up to your scope and see what the signal actually looks like?
I have now connected the capacitor through the analog pin and have stopped getting the 0 readings. I have attached my output in the file for you to look at.
How does it look to you?
If you have access to an oscilloscope and are concerned about sensor noise, it does not make sense to involve your Arduino or custom code. Please put the cap back across the sensor power and ground (as suggested in the datasheet), disconnect the output from your Arduino, and look at it with your oscilloscope. If it looks strange, I’d be interested to see some screen captures (if the scope supports that) or photos of the display.