Sharp GP2D15 and GP2D12 questions
haunteddansion
Posts: 68
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
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
http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
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
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
DEBUG DATA
Add this before the line:
PAUSE 2000
This way you could see what is being returned.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
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!
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