Using sharp sensors on a robot

Hi everyone,

For a school project, we'll need to use Sharp sensors (GP2Y0A21YK0F) on a robot, which will fight another robot and get into collisions with it. I've already made a first code that shows the distance from the nearest obstacle for each sensor.

I have two questions :

  1. Since the graph of the distance/output voltage looks like this : courbe-tension-distance hosted at ImgBB — ImgBB
    I don't know what will happen if there's for example an output of 2V : does it mean it detects 13 cm or 4cm ?

  2. Is there any way we can know that the sensors are detecting less than 6 cm (which is the inferior limit of the detection of this sensor) ? Because since values of the tension related to less than 6 cm of distance correspond also to other values of distance which are more than 6 cm, how could we know that it is detecting less than 6 cm when the robots will collide ?

Thanks a lot for you responses!

This is the data sheet for your sensor.

Since the measuring distance range is 10 cm to 80 cm An output od ~2.0 volts would be a distance of about 12 or 13 cm. If you read the linked data sheet page 6 gives you a method and illustrations allowing you to get good calibration dope. Also note the use of a by-pass capacitor of 10 uF or greater.

Ron

Ron_Blain:
This is the data sheet for your sensor.

https://global.sharp/products/device/lineup/data/pdf/datasheet/gp2y0a21yk_e.pdf

Since the measuring distance range is 10 cm to 80 cm An output od ~2.0 volts would be a distance of about 12 or 13 cm. If you read the linked data sheet page 6 gives you a method and illustrations allowing you to get good calibration dope. Also note the use of a by-pass capacitor of 10 uF or greater.

Ron

Thanks for your help!

But I was thinking too, what would be the output voltage when an object gets too close (less than 10 cm) to the sensor ? It would be an output of 0 V ?

Steclow:
what would be the output voltage when an object gets too close (less than 10 cm) to the sensor ? It would be an output of 0 V ?

You already answered that question in your first post: a distance of 4cm would be 2V.

But it's irrelevant: the data sheet (as Ron_Blain already said, and as you already seem to know) says the lower limit of the range is 10cm. If you expect your item to be closer than that, and need to know the distance, you have the wrong sensor. Sharp obviously specify the lower range as 10, for the exact reason you point out, and it's up to their customers to ensure there's no ambiguity.

Perhaps you need two sensors?- one for close, one for far...

gp2y datasheet.PNG

gp2y datasheet.PNG

Place your sensor in a way that it is physically impossible for the other robot to be closer than 10 cm when you have a collision.