on the first reply i said is analog, then on the second reply i do have this file can you show me some examples how will i communicate with the SHARP ir in basic stamp code an example of writing i mean
This is what I use with this setup. The Pins on the ADC0831 are IR_CS, IR_Data and IR_CLK for the chip select, data and clock respectively.
'IR Rangefinder Constants from the Sharp datasheet
m CON 3200
b CON 3
k CON 4
Get_IR_Detectors: · AvgReading = 0 · FOR counter = 1 TO 3 ' Average reading ··· GOSUB ADC0831_Reading ' Get 8 bit data from ADC. ··· AvgReading = AvgReading + (ADResult/3) ··· PAUSE 50 · NEXT · IR_Range = (m /(AvgReading + b)) - k ' Get ADC0831 distance
RETURN
' Get ADC0831 8 bit data
ADC0831_Reading: · LOW IR_CS ' Activate the ADC. · SHIFTIN IR_Data,IR_CLK, ' Get data bits from. · MSBPOST,[noparse][[/noparse]ADResult\9] ' ADC0831 · HIGH IR_CS ' Deactivate the ADC.
RETURN
Comments
http://www.parallax.com/dl/docs/prod/acc/SharpGP2D12Snrs.pdf
http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
'IR Rangefinder Constants from the Sharp datasheet
m CON 3200
b CON 3
k CON 4
Get_IR_Detectors:
· AvgReading = 0
· FOR counter = 1 TO 3 ' Average reading
··· GOSUB ADC0831_Reading ' Get 8 bit data from ADC.
··· AvgReading = AvgReading + (ADResult/3)
··· PAUSE 50
· NEXT
· IR_Range = (m /(AvgReading + b)) - k ' Get ADC0831 distance
RETURN
' Get ADC0831 8 bit data
ADC0831_Reading:
· LOW IR_CS ' Activate the ADC.
· SHIFTIN IR_Data,IR_CLK, ' Get data bits from.
· MSBPOST,[noparse][[/noparse]ADResult\9] ' ADC0831
· HIGH IR_CS ' Deactivate the ADC.
RETURN
Post Edited (MSDTech) : 9/26/2008 8:34:10 PM GMT
http://www.crustcrawler.com/downloads/datasheet/dsadc0831.pdf
http://www.crustcrawler.com/downloads/datasheet/gp2d12.pdf
http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html