Is it possible to use a sharp IR ranger with BS2 without an AD converter
vla7
Posts: 79
I bought a Sharp GP2D120 IR Ranger and want to connect to my BOE BOT to allow it to follow a wall in order to navigate through a maze.· I have no idea how to connect or program this thing.· I came across some literature by "Nuts and Volts" where they connect it to an analog-to-digital converter first (the ADC0831).· I dont have this converter and was wondering·if I really need one or is there a way to accomplish my task without an AD converter.· I would appreciate any advice someone can give on how to go about this task.
Thanks.
Thanks.
Comments
And if you do want the part, I found something very much like it for sell rather cheap:
ADC0831CCN
http://www.futurlec.com/ICADC.shtml
http://www.hvwtech.com/products_list.asp?CatID=114&SubCatID=148&SubSubCatID=0
Carl
Remember you will still have to "linearize" the readings (whether you use RCTIME or an ADC) -- the Sharps output a curve with respect to distance.
http://forums.parallax.com/showthread.php?p=698218
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Analog IR rangers let you get a very precise distances, at resolutions of less than a centimeter.
So you get a "yes/no" answer to the question: "is the obstacle closer than 10" or not?"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Have fun - Alec
The Sharp rangers that provide a SPI (using SHIFTIN) serial interface are a bit pricier (basically these rangers include an on-board ADC), and, in my humble opinion, have one serious weakness -- the time from initiating a reading to getting one back can be in the 50ms-70ms range -- in other words your Stamp will be waiting on the reading that whole time. Those rangers do have one big plus, though -- they use much much less current as they are only "on" when a reading has been initiated.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
without using an A/D converter, is to make the sensor look like a resistive sensor.
Here's a simple way to do this:
www.noisemantra.com/BASICStampAnalogInput.htm
With the circuit shown on this webpage, you can use the RCTIME
command to read data from the Sharp distance sensor.
- Chris
Your circuit should work, and your inclusion of that diode to cover the lower 0.6V of the output range is clever (assuming the sensor remains accurate with a 4.4V supply). But, as you point out in the linked-to page, the circuit is highly dependent on the transistor's gain, which can vary from device to device and with temperature. From my point of view, it's hard to understand any reluctance to incorporate an A/D converter for these kinds of apps. It's not like they're expensive or take up a lot of room (probably less room than the five discrete components in your schematic). Plus, you get something that's designed from the ground up to be accurate and stable.
-Phil
increases the temperature stability of the circuit (as long as the diode and transistor
are kept at the same ambient temperature).
Also I came up with a variation on the original circuit which will be
much less sensitive to component (and temperature) variations.
It is shown at the bottom of the same web page:
www.noisemantra.com/BASICStampAnalogInput.htm
Using an A/D converter may give you a lower part count, but probably not pin count,
and the code required to support one is significantly more complex.
If absolute accuracy is not needed, I still present this as a viable and easy solution.
- Chris
In the first circuit, couldn't the 100K resistor value be changed to account for differences in transistor gain ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
I presented·this/that circuit a year or two ago in a similar context.
The member asked if an ADC was essential and obviously it's not.
Post Edit -- I could point to a "circuit", on the Forum, where the guy is using an ADC to "read" the output of a comparator.
Post Edited (PJ Allen) : 3/8/2008 4:05:14 PM GMT
Have you tried your second circuit on the bench? I think it could run into trouble at high sensor outputs, in that the capacitor may not discharge fully enough to register as a low to the Stamp. PJ's selection of resistor values seems more dependable in that regard, though it is slightly more gain-sensitive.
Another way to reduce the gain sensitivity is to use a matched pair of transistors and bias one with a constant voltage. Then compare readings from both. But that's another Stamp pin and more parts...
-Phil
Total hardware cost for this circuit can be as low as fifty cents in quantity, possibly less. With an SOT23-5 comparator, the PCB footprint is minimal.
The Stamp sends various duty cycles to the pout pin, using PWM, until (by reading the cin pin) it's able to tell where the comparator inputs are nearly equal. From there, it can calculate an input voltage with eight-bit precision.
Here's a program that does this, using both a binary search and a linear search. The binary search is quicker, but the measured voltage must be constant during the entire measurement interval. The linear search is not so quick, especially with high sensor voltages, but it's more forgiving when that voltage varies slightly during the measurement interval.
I tried this code using a 500-ohm trimpot to produce the "sensor" voltage. The comparator was an LM393. I had to power it from Vin, since its input common mode range only goes up to the supply voltage - 1.5V. The results agreed rather well with the voltage measured via a voltmeter.
A true SAR ADC would include sample-and-hold circuitry for the voltage input, which one could easily do with an analog switch and another capacitor. But if you're going to go to all that trouble, you might as well use an integrated ADC.
-Phil
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
I did test both circuits on the bench and they worked for me; but you are right about the potential for problems at higher input voltages. Originally I left out the base resistor on the second circuit and, as you anticipate, at input voltages above about 2.3V the B-C junction becomes forward biased and the capacitor will never discharge to the required 1.3V. Your SAR circuit is a nice approach as well.
PJ,
I’m always happy to reinvent the wheel!
Was that circuit posted on a Parallax forum?
Dgswaner,
I’ve posted instructions on interfacing the BS2 to a PCF8591 I2C A/D D/A converter here:
astro.temple.edu/%7Ecvecchio/PCF8591%20I2C%20example.htm
But if anyone has examples or recommendations for interfacing with other A/D converters, I love to hear them.
I suspect that if I had used an SPI rather than an I2C A/D converter, it might have made the software end of things simpler.
- Chris
http://www.parallax.com/Portals/0/Downloads/docs/prod/appkit/ltc1298.pdf
I'm currently running several analog sensors in the Weather Station I'm building and have used 3 different ADC's in the process. The are fairly easy and cheap, also easy to calibrate.