Shop OBEX P1 Docs P2 Docs Learn Events
sharp 2yoa2 1 — Parallax Forums

sharp 2yoa2 1

johnprokojohnproko Posts: 121
edited 2013-01-29 16:41 in Accessories
Hello. i am having problem with this ir sensor. i dont understand how to connect the pins and although i tried out the code from ping ultra sensor (pulsout-pulsin) it doesnt work of course. has anyone tried this sensor? can you post some pictures in order to understand how to connect the pins and an example code just to find the distance? thank you very much!

Comments

  • ctwardellctwardell Posts: 1,716
    edited 2013-01-06 09:42
    That device has an analog output that varies with distance. What are you connecting to, prop, bs2, etc.?

    C.W.
  • johnprokojohnproko Posts: 121
    edited 2013-01-10 07:23
    im using bs2.
    erco i have read that article about a million times but cant figure it out how to connect the pins... :-/
  • ercoerco Posts: 20,256
    edited 2013-01-11 10:50
    All the connections are pretty clearly drawn up at http://www.parallax.com/dl/docs/prod/acc/SharpGP2D12Snrs.pdf and the BS2 code is listed there.

    Which part is unclear? Be specific and we can give you specific help.
  • garyggaryg Posts: 420
    edited 2013-01-15 00:34
    I've been tempted to purchase Sharp 2YOA21 sensors for use on my Scarecrow platform project.
    In one of the other threads on the Parallax Fourm website, I noticed that Erco had used a ladder resistor circuit to control
    these without the AD converter.
    For the life of me, I can't find that thread.
    According to the Data sheet, you need to take several measurements, average them, and then try to divine the final output.
    What I want to accomplish:
    Set up Two of these sensors in the rear section looking forward.
    Maximum distance will be about 24"
    These sensors will be looking straight forward to the front of the platform.
    If the platform travels to break the beam of the sensor, the sensor will generate a High on one of my BS2 pins.
    I want to keep this signal very straight forward and simple.
    If the line of sight is blocked, steer my platform away from the blockage.

    Maybe I should have started a new thread with this question, but my question appears to apply to this thread.
    Thanks
  • ercoerco Posts: 20,256
    edited 2013-01-15 15:10
    garyg wrote: »
    I noticed that Erco had used a ladder resistor circuit to control
    these without the AD converter.
    For the life of me, I can't find that thread.

    Simple voltage divider worked fine with my GP2D120 sensor, post & code at http://forums.parallax.com/showthread.php/126312-Balancing-Bot?p=965087&viewfull=1#post965087
  • garyggaryg Posts: 420
    edited 2013-01-15 16:05
    Thanks
    I've ordered two of these sensors with the adapter cables so that I can plug them into my servo control power board.

    Erco
    The simplicity of what you did with the GP2d120 sensor is what got me to thinking about it.

    My hope is that I can use these two sensors to replace the whisker switches I made out of coat hanger wire and limit switches.
    The Coat hanger whiskers worked to a point, but they have no memory if impacted due to my simple prototype programming.
    Reshaping bent coat hanger wire gets to be a bit tedius.

    My next attempt at crash detection will be using these GP2D120 sensors.

    I'm intending that my 1st experiment will be to set up one of the sensors with the light path set up vertical.
    Then I'll see how wide the light path is.
    I'm planning on blocking the light path with a couple pieces of cardboard and keep narrowing the cardboard opening to determine exactly
    how far away from my platform I need to place them.

    This sounds like it could work.
    A simple voltage divider is my kind of circuit.

    Thanks
    I'll try to, in some manner, post my results.
    maybe on a separate thread.
  • ercoerco Posts: 20,256
    edited 2013-01-16 08:24
    You can also read the Sharp sensor as a digital sensor. Quick & simple, but the distance is fixed. Could reduce distance with a voltage divider, or perhaps increase with an op amp: http://www.youtube.com/watch?v=t_OF8XK53LY
  • garyggaryg Posts: 420
    edited 2013-01-16 16:46
    Thanks
    It looks as thought, after viewing your video, that the simple, straightforward sensor reading transitions
    from Low to high happen when your hand is about 8 to 10" in front of the sensor.
    I will absolutely use that information.
    Also
    If I want to trigger the sensor at a different dimension from the hand blockage, I will consider Op-amp or voltage divider.
    I'm also considering AD converter, but I'm thinking that it will take longer to read the AD converter than the time it takes to read a
    simple input.

    I like Simple.
  • ercoerco Posts: 20,256
    edited 2013-01-16 18:54
    Simple rocks!

    Yes, the (digital) triggering distance will vary by module voltage output. Looks like your 2yoa21 will be ~18 cm (@1.4V) :http://www.junun.org/MarkIII/datasheets/GP2Y0A21YK.pdf

    Whereas the 2yoa02yk looks to be ~45 cm: http://www.junun.org/MarkIII/datasheets/GP2Y0A02YK.pdf
  • garyggaryg Posts: 420
    edited 2013-01-29 16:41
    Hi
    I received my two 2yoa2 sensors and the distance measured at 1.4 volts ( approx 18cm) appears to be slightly too short for my
    Scarecrow application.
    SO:
    I set up an NPN 3904 transistor with 10K collector resistor to 5V+ and 2200 ohm resistor from the transistor base to the output of my sensor.
    I'm measuring the Transistor Collector voltage as my input to the BS2.
    This seemed to be the most simple way of expanding the digital distance to my BS2 controller input without setting up +-9V supply for
    OP-AMP use.
    With the transistor connected, I appear to get a pretty good digital output to about 50cm, which is right in the ballpark of where I need to be.
    My question is that after looking at all of the data sheet information available, the only specification I see concerning the output of these units
    is that the overall current consumption of the entire unit should not exceed 40ma.
    With the 2200 ohm resistor driving the transistor base, my current levels are still below 30ma.
    Is anyone familar with the output stage of these sensors?
    I wish to keep the majic smoke inside of my sensors so they keep working for a very long time.

    Thanks for any comments, suggestions.
    Garyg
Sign In or Register to comment.