Sharp GP2Y0A21YK0F reads random values

hi

 I am a newbie to building robots. I am trying to use the sharp GP2Y0A21YK0F IR sensor for reading distance values and I am hitting with two problems.

1. sensor reads very wide range of erratic values.

Eading IR value    100.00
REading IR value    140.00
REading IR value    103.00
REading IR value    153.00
REading IR value    115.00
REading IR value    133.00
REading IR value    97.00
REading IR value    84.00
REading IR value    66.00

REading IR value    85.00
REading IR value    114.00
REading IR value    135.00
REading IR value    103.00
REading IR value    32.00
REading IR value    43.00

These are with 100uF 35V cap

2. These values does not change even when I keep something in the middle.

I have connected red wire to the 5V(on Arduino), Black to GND and white to 5A

Browsed through the forum topics but could not find anything. Appreciate any responses.

thanks

-Avaneendra

Hi, I think you should read

Hi, I think you should read Dan’s tip about the Sharp sensors.

https://www.robotshop.com/letsmakerobots/node/31733

 

Sharps are notoriously

Sharps are notoriously unreliable with their readings. There are a couple of things I can suggest which may or may not help.They are not to my knowledge made for use in situations where they are moving but in fixed situations as like a photo interrupter to switch a tap or valve on or detect if a box is present on the conveyer belt. But you could try…

  • Take 3 readings and averaging them.
  • Make sure your servo is stopped when taking a reading and although impractical stop all movement while reading.
  • Temperature and light. Can give widely different results I’ve found between day and night and hot and cold.
  • If you can control the conditions as much as possible including the surfaces encountered you will improve repeatability in readings.
  • And lastly after you’ve exhausted all options don’t be surprised if you still can’t achieve the degree of accuracy you desire.

Check the wiring. Don’t

Check the wiring of the sensor cable. Don’t trust the colors of the cable. It could be the same problem like here. Here is a picture with the correct wiring looking to the back of the sensor from left to right (yellow=signal, black=GND, red=VCC)

gp2d12-2.jpg

hi I verified and the

hi

 I verified and the connections seems ok. As you specified. Not sure why it is still does not read correctly.

 

thanks