Shop OBEX P1 Docs P2 Docs Learn Events
Sharp GP2D15 and GP2D12 questions — Parallax Forums

Sharp GP2D15 and GP2D12 questions

haunteddansionhaunteddansion Posts: 68
edited 2007-05-22 00:01 in BASIC Stamp
I a trying to use the Sharp GP2D15 and GP2D12 which from what I have read have a digital output, which is exactly what I need. I would like to use these as a motion detector/ trigger giving me an open or closed trigger which I can use to open or close a relay with the BS1. How would I do this. Also what would the coding look like? Thanks

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-30 01:42
    Well... one of those puts out an analog voltage in relation to proximity sensed·and the other just changes states (on/off, hi/lo) when the proximity sensed crosses a threshold (which isn't configurable.)
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-04-30 02:10
    With the GP2D12 Would I be able to interface it easily with the BS to act as an object present / not present device?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-30 02:51
    The D15 is the "Distance judgement type" (their name).· The Datasheet states that the "judgement distance" is 24cm and -- that it is "adjustable within range of 10 to 80cm", afterall, but there is no information on how to do that.· All I can see is that it has three terminals (+V, GND, Out).· The drawing doesn't show an adjust pot or anything.· Maybe somebody has an Application note on this aspect.· Anyway, that's an easy interface.· You place a 10kohm resistor from Out to +5 and then connect that output pin to a Stamp input.

    Update -- The D12 is not quite so easy.· If nobody else chimes in with some means of interface for it, then I'll suggest one or two ways.· I recall this was a topic from not so long ago.· Try searching for it via www.search.parallax.com


    Post Edited (PJ Allen) : 4/30/2007 2:58:06 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-04-30 05:51
    The following article covers using the GP2D12 with a BS2 and an ADC0831. Take care.

    http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-04 23:14
    If I use the ADC0831 can I program the stamp to·read a trigger if the stamp get to a certain "cusp" voltage. For example, If the voltage from the sharp holds with nothing obstructing it at .21 volts can it turn on a led when it gets to .7 volts or whatever voltage variable I have, what would the code look like, is it possible with BS1? Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-06 00:48
    That’s just a matter of using a conditional on the resulting distance value to trigger a branch in the program, so yes. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-06 06:58
    How would that look? sounds complecated
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-06 17:07
    It shouldn’t be…At some point in your program you should be getting the distance back in cm (centimeters). Let’s say this variable is called ‘distance’. All you have to do is a line like:

    IF distance > 20 THEN Trigger

    Now your question refers to voltages and since our example used those to lookup a distance I covered that. With the raw voltage reading you’ll actually be getting a voltage back from the ADC from 0 through 255. Without knowing the reference voltage I can’t tell you what number you’ll want, but you could do something like:

    IF volts > 45 THEN Trigger

    Remember, 45 if the RAW value from the ADC, not necessarily the voltage, but you can either calculate or measure the voltage to get the correct value. It would help to see your code for this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-07 16:25
    I am working with the attached code, how can I output to turn the LED on when the adc gets a certain voltage?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-07 16:36
    Hello,

    I don’t see anything being done with the data at all. You really should be debugging the value of ‘DATA’ so you can see what values are being returned. Then you can use an IF…THEN to act based on the value of that variable. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-07 17:00
    I am new to the interfacing with the ADC, what would this look like with this code, Thanks soo much!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-07 19:24
    Well, you could start with adding:

    DEBUG DATA

    Add this before the line:

    PAUSE 2000

    This way you could see what is being returned.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-10 23:12
    That is working beautifully now, I have attached the working code for whomever would like it.

    My other big question now, is there a way to connect 3 of the sharp sensors in parallel or series so I have a wider cone of triggering space. I could put the three on a half circle so they fan out. Thanks for the help!
  • haunteddansionhaunteddansion Posts: 68
    edited 2007-05-21 19:47
    How would I hook up 3 sensors in parallel or series?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-05-22 00:01
    Series, Parallel -- wrong approach.

    A good way would be an ADC with multiple inputs (you'd select which source voltage to read via select lines.)· You could also use an analog switch IC (CD4066) to select voltage sources to feed into your present ADC.

    Update:
    Here are links to data sheets of an 8-input (selectable) ADC and the "4066".·
    This ADC has 8-bit resolution, but its output is parallel.· There's probably something like·it with a serial output, do some research.
    http://www.fairchildsemi.com/ds/CD/CD4066BC.pdf·
    http://www.jameco.com/Jameco/Products/ProdDS/10170.pdf

    And here is a 4-input ADC sold by good ol' Parallax:
    http://www.parallax.com/detail.asp?product_id=604-00027

    It's part of a "family" of similar devices (ADC0831, -32, -34, -38)
    http://www.national.com/ds/AD/ADC0831.pdf

    Post Edited (PJ Allen) : 5/22/2007 2:24:16 AM GMT
Sign In or Register to comment.