I'm in the process to implementing a sharp GP2Y0A02YK0F (20-150cm) ir distance sensor in my project. Reading around it draw much more current than 30mA medium when it fires and that make the sensor to return some heavy spikes on the power supply and consequently bad distance reading.
After reading a lot I saw some solution adding capacitors and resistors here and there, but I'm not sure how to do that and which one solution is correct.
Could someone help me making the right filter? Note that my arduino platform is powered by eight 1.2v rechargeable batteries. Could be a problem?
Please help me. I'm pretty sure about the arduino code, but have problem with electronics.
?Advice for the power supply • In order to stabilize power supply line, we recommend to insert a by-pass capacitor of 10?F or more between Vcc and GND near this product.
In your code you might also try calling analogRead() twice and only use the second result -- see if that gives a more reliable reading.
thank's a lot for answering. I know what the datasheet say but looking around there are some other suggestion for best results. Unfortunatly I don't know which is better and how to translate it in a schema for breadboard testing... (as I said I'm not expert in electronic).
In addition to the decoupling capacitor, In your second link there's a post that says you should also ground the black plastic case of the sensor. It would be something simple to try...
The Arduino makes 5V from the 9.6V by means of an LM7805 (voltage regulator) If you connect the rangefinder to the Arduino 5V pin it should work.
Have played with a rangefinder too, resulted in the multiMap() function for interpolation of the distances, see - Arduino Playground - MultiMap
might be usefull,
Mid to low 200 values are in the range of voltages which correspond to the bottom of the non-linear range of readings from the Sharp sensor. As a result, even moderate jumps in ADC values only correspond to relatively small changes in distance readings. Perform the conversion calculations and see what kind of variation you are getting in terms of actual distance readings.
If you're within +/- 1 cm in real world operation, you're doing excellent. If it's worse than around +/-3-5cm, then there's likely room for improvement. Don't expect too much from these sensors.
Here's a good resource for linearizing the output from these sensors:
Could you show the code and wiring schematic for your setup?
Those spikes seem excessive.
Are you switching ADC channels in between readings?
Is your ADC circuitry well isolated?
Can you average ADC readings to mitigate the spikes? (keep in mind that the sensor operates relatively slowly, about 40ms between readings. This provides ample time to take multiple readings and average them to reduce the impact of noise on the ADC line.
Also, the surface the IR sensor is reading against can influence the results. A textured or specular surface can cause larger variations in readings. Also, going from brighter to lighter surfaces will change the readings as well. I can't remember the direction, but a black matte surface will read as either closer or farther away than a white matte surface, both at the same actual distance.
These reading are strange and might be caused by a low supply voltage.
The sensor should work at 3.3V, but if you have a 5V Arduino board, I would advise to use the 5V Vcc.