Sharp IR Sensor Distance
stuartX
Posts: 88
I have a question in reference to the Sharp IR Sensor. It states that it has a range of 10cm - 80cm. But when I hook it up, the maximum distance it detected was less than 10cm.
Am I doing something wrong?
I used the code below:
The IR is connected to pin 9
Thanks ( in advance).
Am I doing something wrong?
I used the code below:
The IR is connected to pin 9
irDetectLeft VAR Bit DO irDetectLeft = IN9 DEBUG HOME, "irDetectLeft = ", BIN1 irDetectLeft PAUSE 100 LOOP
Thanks ( in advance).
Comments
Take a look at this page http://www.acroname.com/robotics/info/articles/sharp/sharp.html for a tutorial on the Sharp sensors. Other good information can be found at other sites found with Google.
John Abshier
thank you Sir.
John Abshier
P.S. -- if you want to just have a binary (yes/no) detector with the IR ranger, you could run the output through a voltage divider into your micro pin -- adjusting the values in the voltage divider would let you set a threshold (corresponding to some distance between 10cm - 80cm) and get a "1" or "0" depending on whether the target is closer than the set value or further.
The Stamp's input pin high/low transition voltage is ~1.4V, and you can use that like a simple comparator if you want a digital go/no-go input. You can use a voltage divider to scale voltages higher than 1.4 down. I have also used an 8-resistor voltage divider string with a Sharp sensor and 8 IO pins to resolve distance in 8 different zones for a balancing robot.
It's becoming more clear. It will be even more so, when I test it out with the chip.
USPS shipping is cheap.
Ebay Thailand is still $4 and a 2-week wait! http://www.ebay.com/itm/ADC0831-ADC0831CCN-8-Bit-A-D-Converter-IC-/250866258051?pt=LH_DefaultDomain_0&hash=item3a68cb5083
I was hoping to use the Sharp sensor in place of the PING))) sensor.
then as I'm hooking up the sensor I see the comments about it being analog.
I'm using the Homework board and I assume that I need this converter but honestly not sure how/why I'd set it up.
I just want the sensor to recognize movement between 3-6 feet in front of the senor and if something is there send a signal. a simple yes/no
but still not entirely sure what I'm doing. will do some more research until I hopefully hear back.
i was just reading that thread. and wondering the same thing. no extra resistors needed if I just use the same PING))) code but use sep pins for puls out and puls in? (normal 4 pin mode rather than 3)
Hmmm. A soda, or a sensor? Same price.
ordered today
I'm getting there, it's slow going but moving in the right direction
got sensor in, ordered just 't one from amazon. yes i know it was more expensive but I didn't want to wait weeks for it and currently I just need 1.
anyway,
I have tried several different forms of code. i first modified my current setup (old PING))) sensor. I changed pulsout(trig) and pulsin(echo) to the correct pins for the new sensor.
i just get zero on the two lines and the everything fires like there is an object in the way.
so I switch to
and all i get is inches = 000
gives me time of 00001 or 00002 without any correlation to anything.
finally I tried adding a 10k and 1k resistor as detailed here, and i get no improvement
if I simply reset pulsout and pulsin to same pin and swap in my PING))) my setup works fine. I assume it's a bad sensor
all I get is zeros
I think you may have your I/O pins swapped, based on your comments. Connect pin 14 to TRIG on the sensor and pin 15 to ECHO. Once you get some numbers coming back, you can throw your math back in to calibrate for inches & cm.
double checked pins and they are connected as you suggested. (when I was troubleshooting I think I tried them both ways honestly, not sure I updated the comments)
but no.
shortened code didn't work
your code also a no go. guess I should have ordered more than one.
thanks for going through the trouble of testing the code. I'll order some more and just use my PING))) till they arrive.
Shawn
eric
and thank you so much!
so I got a bad one initially.
Thanks for all the help
Shawn
That makes TWO somewhat different meanings for the abbreviation f/u .