SmallBot
reconn's
reconn's
world
world
.com



Basic Stamp Sonar


Basic Stamp Book Just so you know, the following project is from the book: Programming and Customizing the Basic Stamp Computer. Click here, to read more about this title.

Note: This circuit requires the Basic Stamp 2, and 3 I/O ports of that Basic Stamp.

This project is best suited for use as a sensor on a robot. This circuit will actually allow you to measure distances from an object. It measures in a 'unit' and it's range is about 10 inches. As the receiver and transmitter, you will use an ultrasonic transmitter and receiver pair tuned to 40khz (see parts list below.) The circuit is very easy to build, and you can build it on whatever you have laying around. I assembled it onto a Radio Shack pre-etched circuit board - and it only took up about an inch and a half square.

parts:
Resistors (1/4 watt, 10% or better)
R1, R5, R6, R11, R19, R21 10K Jameco: 29911
DCkits: CF25-10K
R2, R7 47K Jameco: 31149
DCkits: CF25-47K
R3, R8 22K Jameco: 30453
DCkits: CF25-22K
R4, R9, R14, R18 100K Jameco: 29997
DCkits: CF25-100K
R10 18K Jameco: -------
DCkits: CF25-18K
R12, R13, R16, R17 220K Jameco: 30525
DCkits: CF25-220K
R20 1k Jameco: 29663
DCkits: CF25-1K
Other Components:
C1, C4 0.1uf ceramic cap 50WVDC Jameco: 151116
DCkits: 21ET100
RCVR, XMTR 40khz ultrasonic receiver and transmitter Jameco: 136653
DCkits: --------
U1 LM358AN dual op amp Jameco: 120862
DCkits: --------
U2 LM339N quad comparator Jameco: 23851
DCkits: LM339
XTAL 40khz quartz crystal Digikey: SE3316-ND


The schematics are below. Make sure you connect everything correctly, then after that is done move onto the basic stamp code below.
Click on the thumbnails to enlarge the schematics.
Sonar Trasmitter Circuit

Sonar Receiver Circuit

Sonar Comparator Circuit

Basic Stamp Code:

What will it do?
It will open a debug window in the basic stamp compiller, and display distance readings (in 'units') from the circuit.

Please note that the 'Free Stamp Pin' in the schematics refer to the basic stamp i/o port that you connect that part of the circuit to. You will need to look out for the the three (!!!! FREE STAMP PIN ' ' !!!!)'s in the code, and change the X's that accompany them to the correct i/o port number. Download the source code by

1.) Right-click on the link and select 'Save Target As..' (Windows)

2.) Click on the link, and hold it until a menu pops up, and select 'Save Target As...' (Mac)

bs2sonar.txt
OR
bs2sonar.bs2


Refer to the SmallBot Programs page to see how to implement this circuit as an ultrasonic sensor for your robot.






Site by Andrew Wilson. Copyright 1997-2006 All Rights Reserved unless otherwise noted.
Schematics in Schematics Depot were found on the internet and assumed to be in public domain. Contact webmaster if the copyright holder wants them pulled for any reason.