PDA

View Full Version : Sharp GP2D15 and GP2D12 questions



haunteddansion
04-30-2007, 04:04 AM
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

PJ Allen
04-30-2007, 08:42 AM
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.)

haunteddansion
04-30-2007, 09:10 AM
With the GP2D12 Would I be able to interface it easily with the BS to act as an object present / not present device?

PJ Allen
04-30-2007, 09:51 AM
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 (http://www.search.parallax.com)


Post Edited (PJ Allen) : 4/30/2007 2:58:06 AM GMT

Chris Savage
04-30-2007, 12:51 PM
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

haunteddansion
05-05-2007, 06:14 AM
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 Savage
05-06-2007, 07:48 AM
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

haunteddansion
05-06-2007, 01:58 PM
How would that look? sounds complecated

Chris Savage
05-07-2007, 12:07 AM
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

haunteddansion
05-07-2007, 11:25 PM
I am working with the attached code, how can I output to turn the LED on when the adc gets a certain voltage?

Chris Savage
05-07-2007, 11:36 PM
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

haunteddansion
05-08-2007, 12:00 AM
I am new to the interfacing with the ADC, what would this look like with this code, Thanks soo much!

Chris Savage
05-08-2007, 02:24 AM
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

haunteddansion
05-11-2007, 06:12 AM
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!

haunteddansion
05-22-2007, 02:47 AM
How would I hook up 3 sensors in parallel or series?

PJ Allen
05-22-2007, 07:01 AM
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.fairchildsemi.com/ds/CD/CD4066BC.pdf)·
http://www.jameco.com/Jameco/Products/ProdDS/10170.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 (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 (http://www.national.com/ds/AD/ADC0831.pdf)

Post Edited (PJ Allen) : 5/22/2007 2:24:16 AM GMT