PDA

View Full Version : Can Sharp GP2D12 proximity sensors be used with Prop chips without additional h



noobmuncher
12-24-2009, 04:00 PM
Hello,

So I have a few Sharp GP2D12 proximity sensors laying around and also a Digital Infra-Red Rangefinding (DIRRS+) (http://www.hvwtech.com/products_view.asp?ProductID=91) version.
Will both types work with the propeller chip without additional hardware? If so does anyone have code samples that will work with whichever will work?

:) Thank you!

Leon
12-24-2009, 06:58 PM
URLs?

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM

Mike G
12-24-2009, 09:13 PM
An analog to digital converter (A/D) is needed to convert the GP2D12 analog output to a distance reading. The GP2D12 datasheet has a lot of really good info.

There are several A/D examples on the object exchange http://obex.parallax.com/objects/category/9/

noobmuncher
12-25-2009, 03:19 AM
So these objects will work to convert it then? Or are they just to work with A/D converter?

noobmuncher
12-25-2009, 05:42 AM
Here is the code that I am trying to emulate in spin, this is a bs2 program to output the distance into a terminal window.

'{$STAMP BS2}
'********************************************
'HVW TECHNOLOGIES INC.
'DIRRS Plus demo software version 1.0
'Date: March 2000
'Author: Dan Henne
'www.HVWTech.com
'********************************************
'
'********************************************
'This software is used with the DIRRS Plus when it is configured
'for Original DIRRS mode. The input from the DIRRS Plus is
'triggered by a high low transition with the resulting
'distance measurement shifted into the DIST variable.
'********************************************


DIST VAR BYTE 'Variable used to store DIRRS result
T VAR BYTE
clock CON 1
datain CON 0

OUTPUT clock 'Pin 0 connects to Pin 2 of DIRRS Plus
INPUT datain 'Pin 1 connects to Pin 4 of DIRRS Plus

START:
High clock 'Start Vin must have high-low transition
Pause 3 'Wait for high to be recognized
Low clock
For T= 1 to 30 'Begin 30 ms wait
Pause 1
If IN0=1 Then JUMP
'If Vout is HIGH, measurement is complete -jump
Next 'Measurement not complete, wait another 1 ms

JUMP:
Shiftin datain,clock,2,[DIST\8]
'Shift 8 bits into DIST via pin P1, clocking with P0, MSB first
Debug "Distance= ", dec DIST,cr
'Display distance (in decimal form) in debug window
Goto START 'Start over

John Abshier
12-25-2009, 07:17 AM
That code is for a version of the Sharp sensors that had a digital output. It is not for a GP2D12. The output pin from the GP2D12 will be seen by a Propeller as transitioning from high/low at one fixed distance.

John Abshier

SRLM
12-26-2009, 10:35 AM
If you use the MCP3208 ADC chip then there are several good objects that you can use, depending on the number of channels that you need: obex.parallax.com/objects/search/?q=MCP3208 (http://obex.parallax.com/objects/search/?q=MCP3208)

Plus, Parallax sells the MCP3208 ADC chip.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm

noobmuncher
12-26-2009, 11:38 AM
John, yes I know it is, I have 1 digital output one which I linked to earlier in the thread and am trying to use as well. SRLM thanks i might order one of those so I can use these, one of the microcontrollers I used to use must have had A/D built in and I just didn't realize it.

But my question still remains, if anyone has any ideas for outputting distance to a terminal from a digital sharp sensors (such as this one www.hvwtech.com/products_view.asp?ProductID=91 (http://www.hvwtech.com/products_view.asp?ProductID=91)) it would be much appreciated. http://forums.parallax.com/images/smilies/smilewinkgrin.gif

Tubular
12-26-2009, 11:47 AM
noobmuncher,

This thread from a year ago involved interfacing 24 of the "analog" sharp sensors to the prop via 3 MCP3208's (as SRLM suggested).
http://forums.parallax.com/showthread.php?p=772040

There's code there too

noobmuncher
12-26-2009, 11:59 AM
This should work great, thanks you!

John Abshier
12-26-2009, 10:42 PM
I just looked at the link to the DIRRS+ page. I did not download the product manual. It supports asynchronous serial. For that you could use simple serial or full duplex serial. It also supports synchronous serial. That would use code similiar to what you posted earlier. The key is to read the DIRRS manual and the sample code.

John Abshier